On Nov 2, 2006, at 8:54 PM, William Stein wrote:

> On Thu, 02 Nov 2006 20:06:34 -0800, David Harvey
> <[EMAIL PROTECTED]> wrote:
>> This is much harder. I agree it would be nice, but how would you
>> handle something like
>>
>> sage: R.<x> = ZZ["x"]
>> sage: S.<y> = ZZ["y"]
>> sage: x*y
>
> The result would be in either ZZ['x,y'] or ZZ['y,x'], or even jn the
> noncommutative ring FreeAlgebra(ZZ,2,'x,y'),
> These are three different rings in SAGE, and the produce makes
> sense naturally in all three.   The problem with chosing a ring
> for the product of two elements, when it isn't either parent is
> that the choice is way too arbitrary.  Even in mathematics this
> would be very confusing.  If I defined two polynomial rings
> R = ZZ[x] and S = ZZ[y] in a math paper and considered f = x^2 +  
> y^3 - 1,
> you might complain.  And if I wrote g = x*y - y*x, you would
> probably complain even more.

On this point I agree.

> Robert said:
>> Right now something like
>> sage: R.<x> = ZZ['x']
>> sage: (1/2) * (x^2-x)
>> throws an "unable to find a common parent" type error. I am  
>> wondering if
>> there are any (many) other cases where there is an unambiguous common
>> parent that is not the parent of either "sibling." I think
>
> I've been refusing to think about this problem in order to have a
> coercion system that can be understand and 100% remembered by mere
> mortals.  For the record, the latest version of MAGMA also doesn't
> do anything with the above:
>
> sage: magma.eval('R<x> := PolynomialRing(Integers());')
> ''
> sage: magma.eval('(1/2)*(x^2 + 1)')
> error...
>>> (1/2)*(x^2 + 1);
>          ^
> Runtime error in '*': Bad argument types
> Argument types given: FldRatElt, RngUPolElt[RngInt]
>
> ---
>
> Even if we do decide to define (1/2) * (x^2-2), the definition
> could be ambiguous in that it could depend on time.  E.g.,
> today the best choice for the product is QQ[x].  But in a
> month maybe somebody will implement ZZ[1/2] and the best choice
> becomes  (ZZ[1/2])[x].  So it's a slippery slope.  With
> the coercion rules we've agreed on so far, things on much
> clearer.

I disagree on this being ambiguous. For q in Q and P in ZZ[x], qP  
would always be in QQ[x]. Only if q were in ZZ[1/2] would qP be  
(hypothetically) in ZZ[1/2][x].

To me, allowing (1/2) * (x^2+1) is "more" natural than allowing (1/2)  
+ (x^2+1) as the former can be viewed as extending the action of 1/2  
on the coefficients to an action on the polynomial. To put it another  
way, if multiplication is well defined on the coefficents of a  
polynomial/series (or entries of a vector/matrix) I think it should  
be allowed on the more complex structure.

As a counterpoint, I do think this might be bad as in it might make  
the following code legal:

sage: R.<x> = ZZ['x']
sage: 1/2 * x^2 + 1/4 * x - 1/3

whereas currently the error tells you that x is a generator for ZZ 
['x'] only.

>> Also, I guess you want T to be minimal in some sense.
>
> Except that there is no good notation of minimality on the
> set of all rings.  There are lots of minimal rings containing
> any two rings, especially if you allow non-commutative rings,
> which we certainly should do.
>
>> One thing I definitely don't like about this is that the  
>> multiplication
>> operator has to conjure up a whole new ring. But I guess this already
>> happens for things like this:
>> sage: R.<x> = PolynomialRing(ZZ)
>> sage: (x/2).parent()
>> Fraction Field of Univariate Polynomial Ring in x over Integer Ring
>
> Divides is a constructor for elements of the fraction field of the
> unique canonical ring associated to the numerator and denominator, and
> Frac(R) is well defined.
>
>   -- William
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to