On 03/12/2009 04:34 AM, Robert Bradshaw wrote:
> Wow, this thread has generated a lot of discussion! :)

I am sorry for having started this. :-)

> On Mar 11, 2009, at 12:29 PM, Ralf Hemmecke wrote:
> 
>> Some more oil for the fire...
>>
>> sage: K=NumberField(x^2+1, 'a'); K
>> Number Field in a with defining polynomial x^2 + 1
>> sage: a = K.0
>> sage: a
>> a
>> sage: a*a
>> -1
>> sage: a<1
>> False
>> sage: a>1
>> True
>> sage: 1<a
>> False
>> sage: 1>a
>> True
>> sage: version()
>> 'Sage Version 3.3, Release Date: 2009-02-21'
>>
>> Do I do something wrong or is autocoercion doing something strange  
>> here?
>> In fact, I would have expected an error telling me that I cannot  
>> compare
>> an element of K with any other thing.

> This is nothing to do with coercion.

Really?

sage: parent(1)
Integer Ring
sage: parent(a)
Number Field in a with defining polynomial x^2 + 1

Are you saying that I can compare an integer with an element of K 
without coercion. Where can I find the code for this?

 > Coercion is what allows on to
> write 1 < 3/2 < 2. On the other hand,

Why is 'a' so different from 3/2?

> sage: K=NumberField(x^2+1, 'a'); K
> Number Field in a with defining polynomial x^2 + 1
> sage: a = K.0
> sage: one = K(1)
> sage: a*a
> -1
> sage: one < a
> False
> sage: one > a
> True
> sage: one != a
> True

> The issue here is that comparison is useful outside of the purely  
> mathematical context

Aha... that means Sage just consideres K as an ordered set, but the 
order is not necessarily compatible with operations K. Of course K is 
not an ordered field.

By the way... there is a bug already mentioned earlier in this thread.

sage: a>one
True

So > is not even an order on the *set* K, because a is not the same as one.

> --for example if one wants to sort a list (for  
> printing or searching) or use elements in sets or as keys in  
> dictionaries

OK.

> or simply throw an error on an illegal value like 0.

That has to do with a zero-test not ordering.

Ralf

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to