axiom-developer
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Axiom-developer] RE: [sage-devel] Re: MAGMA question


From: Page, Bill
Subject: [Axiom-developer] RE: [sage-devel] Re: MAGMA question
Date: Wed, 18 Oct 2006 16:05:52 -0400

William and William, ...

I hope you don't mind my adding a little of Axiom's point
of view to this subject. Declaring the types of objects
like this is something that we Axiom users tend to talk about
a lot. :-) But if you find this discussion of types in Axiom
rather off-topic, then please excuse my interjection. But
I hope that my comments might be relevant to both Axiom and
Sage users to better understand the relationship between these
systems at a fundamental level. I think this is especially
important since we now have the initial release of an interface
for Axiom in Sage.

> 
> On Wed, 18 Oct 2006 10:16:30 -0700, William Hart wrote:
> > Even something like:
> >
> > declare(x);
> >
> > or
> >
> > local(x);
> >
> > or
> >
> > indet(x);
> >
> > would be better. To declare it as an
> > indeterminate/symbol/whatchamacallit.

In the Axiom interpreter (but not in the compiler, in the
compiler all types are explicit and it has no default types
or type inference), unless otherwise stated all symbols are
assumed to be variables denoted by that symbol

(1) -> a

   (1)  a
                                          Type: Variable a

The domain (type) constructor Variable denotes a class
whose sole member, also denoted by a, can stand for some
other value. But once I assign it a value it also acquires
a new Type:

(2) -> a := -1

   (2)  - 1
                                             Type: Integer

On Wednesday, October 18, 2006 2:11 PM William Stein wrote:
> 
> All three of the examples you give above would be illegal
> in most programming languages, including Python.  They are
> illegal since they are functional calls that take x as input,
> and I think we are assuming that x hasn't been defined yet.
>

In Axiom the concept of type is separate from the concept of
value, so for example we can declare x to be of type Polynomial
with Integer coefficients (POLY and INT are standard short
forms):

(3) -> x:POLY(INT)
                                                 Type: Void

The type Void means there is no value association with this
declaration. But if was ask about 'x' then Axiom now knows
it's type:

(4) -> x

   (4)  x
                                    Type: Polynomial Integer

and in this case it also has a value again denoted by 'x'.
The fact that symbols directly denote values in some domains,
i.e. "symbolic" domains such as polynomials, can be a little
confusing at first to some users but I think it (more or less)
corresponds to usual conventions in mathematics.

> What about
> 
>      x = polygen()
> 
> Then the resulting x can be used to *create* "classical"
> polynomials just as you suggest in your previous email.
> I think I could implement something like that very easily.

This seems very similar to Axiom except in Sage/Python normally
types are *only* associated with values and variables acquire
their type dynamically by assignment of a value. The net effect
however in this case appears to be the same. But in Axiom I
can now make a new assignment of a value to x

(5) -> x:=1

   (5)  1
                                   Type: Polynomial Integer

and the result is still a Polynomial with Integer coefficients
but it is now a different member of this domain and x now
stands for that member

(8) -> x

   (8)  1
                                    Type: Polynomial Integer

> 
> > It saves typing
> >
> > R<x> := polynomialRing(Integers());
> >
> > which is just mindless.
> 
> I don't consider that mindless.  However, I'm not at all
> opposed to having some much easier shorthands.
> 
> Incidentally, SAGE already has a useful shorthand for the
> above:
> 
> sage: x = polygen(ZZ)
> sage: parent(x)
> Univariate Polynomial Ring in x over Integer Ring
>

I think you need to define the semantics very carefully here.
As an Axiom user I want to interpret the Sage expressions
above in a slightly different language. What you mean is that
x is now a member of a certain class, i.e. it's "parent" and
polygen is a generator of members of this class. Here the
value is explicit by the type of the result, i.e. parent, is
implicit. This is sort of the opposite of the convention used
in Axiom.

In Sage how would I create a symbol whose value is the Integer
1 considered as a Polynomial? E.g. (5) above.
 
> And, everything above is standard in SAGE (e.g., polygen and
> ZZ are defined for all SAGE installs).
> 
> > Pari does get around it altogether. You never have to
> > tell it you are declaring a polynomial or specify a
> > ring. Of course it doesn't support many rings, can't
> > do algebra as such and doesn't have the limitations
> > you are working with in Python.
> 
> I'm not sure I like PARI polynomials.  The precedence of
> variable names (and even the choice of names) is hard coded
> into the system.  It's only good for smallish toy situation.
> I wouldn't want to write a 100,000 line program built out of
> such a thing.

I agree. That was one reason I was surprised when I saw that
Sage treats

  sage: x+1

and

  sage: y+1

differently if these are the first two statements entered in a
Sage session. However it is now more clear to me dynamic typing
makes this convention fairly natural and (mostly) harmless. In
contrast to a system like Axiom, nothing is stopping us from
simply using x and y in different ways. But in Axiom if we write

(9) -> x:=sin(y)

   Cannot convert right-hand side of assignment
     sin(y)
   to an object of the type Polynomial Integer of the
   left-hand side.

We are prevented by Axiom's static type rules.

> 
> Of course, in SAGE you can use PARI polynomials:
> 
> sage: x = pari('x')
> sage: y = pari('y')
> sage: f = x*(y^2+7/3)
> sage: f^3
> (y^6 + 7*y^4 + 49/3*y^2 + 343/27)*x^3
>

And now you can do the same think using Axiom :-)

address@hidden page]$ sage
--------------------------------------------------------
| SAGE Version 1.4, Build Date: 2006-10-05             |
| Distributed under the GNU General Public License V2. |
--------------------------------------------------------

experimental

sage: x = axiom('x')
sage: y = axiom('y')
sage: f = x*(y^2+7/3)
sage: f^3

   3 6     3 4   49  3 2   343  3
  x y  + 7x y  + -- x y  + --- x
                  3         27
 
Type: Polynomial Fraction Integer

sage:

> > Anyhow, it is just one pet peeve in MAGMA which seems
> > easy enough to relieve somehow.
> 
> What do you think of
>      x = polygen(ZZ)      for x in ZZ[x]
> and
>      x = polygen()        for a formal x (whose properties 
> are yet to be determined)
> 

What would be the value of parent(x) for the second case?

Regards,
Bill Page.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]