axiom-developer
[Top][All Lists]

## [Axiom-developer] Re: conditionally defined functions

 From: Martin Rubey Subject: [Axiom-developer] Re: conditionally defined functions Date: Fri, 17 Sep 2004 11:30:01 +0000

```Dear Manuel, Ralf, Tim, William, *,

I'm struggling with something, maybe you are able to help. If not please tell
me so.

As you might know, I'm experimenting with fixes of the following, superficially
strange behaviour:

(1) -> (1/x)::UP(x, FRAC POLY INT)

1
(1)  -
x
Type: UnivariatePolynomial(x,Fraction Polynomial Integer)

Well, I think that this is calling for trouble. So, one way to fix this is to
make coerce(coef:R)-> % of UP, MPOLY and the like (in fact, are there others?)
check whether or not coef contains one of the variables -- in this case x. In
fact, I believe this is the "right" approach.

In principle, this is not too difficult. However, there is a slight subtlety:
Currently not all domains that contain variables provide such a function, in
particular, FRAC does not. Instead, there is a package RF that provides this
functionality. Well, no problem:

* move the operation variables from RF and POLYCATQ to QFCAT :

if S has variables: S -> List Symbol then
variables: % -> List Symbol
variables f ==
mymerge(variables(numer(f)), variables(denom(f)))

and add the following to UP and MPOLY :

if R has variables: R -> List Symbol then
coerce(r:R):% ==
if member?(x, variables(r)) then
error "coefficient contains variable"
else coerce(r)\$Rep

This works, it seems. However, there are two things I don't like about this
"fix":

* the function "variables" thus (conditionally) provided in QFCAT is only one
of many. I don't know of an example, but POLYCAT (which defines variables
originally) defines variables : % -> VarSet (which is a member of the
Category OrderedSet). So, for example, since SUP specialises VarSet to be
SingletonAsOrderedSet, FRAC UP won't have a function variables.

* philosophically, this is not very beautiful. But I don't see another way to
overcome the problem.

Now a mail of William comes in. He wrote, quite some time ago:
> Actually, there is a more general request for ages: that is, each
> CONSTRUCTOR in Axiom should provide the means to return ALL the parameters.
> This
> would have to be built like OutputForm form the bottom up because of nesting.
> Lots of editing and a total rebuilt. Currently, when writing a constructor,
> there is no way one can "descend" inside its parameters other than finding
> their
> categorical property or attributes.

However, I don't really see how this could be used. I modified POLYCAT to
contain a function

varset: () -> OrderedSet
varset () == VarSet

but I was not able to do anything useful with this. Of course, what I'd like to
say in QFCAT would be

I'd like to be able to say in QFCAT something like:

if S has varset: () -> OrderedSet then
variables: % -> List varset()
variables f ==
mymerge(variables(numer(f)), variables(denom(f)))

But this looks fishy.

So, in more general terms, here's my question:

Suppose you have a category A, taking as parameter a domain P and providing an
operation f: % -> P. Furthermore, you have a category (or a domain, a package)
B, taking as parameter a domain Q. Now you want to achieve the following:

If Q is a domain in A, provide a function g: % -> P, using f.

Of course, it is not possible to provide P as a parameter of B, since B should
also be defined for Q's that are not domains in A...

I suspect that this is the reason for making RationalFunction a
package. However, this does not provide the full functionality, as you can see
from the problem above.

Did I get something backwards, is there another solution?

Thanks,

Martin

```

reply via email to