Hi!

> On Sat, Mar 14, 2009 at 3:38 AM, William Stein wrote:
> > teragon:papers wstein$ sage -python
> > Python 2.5.2 (r252:60911, Mar 12 2009, 23:58:30)
> > [GCC 4.0.1 (Apple Inc. build 5488)] on darwin
> > Type "help", "copyright", "credits" or "license" for more information.
> >>>> a = 10**22; b = 10**22+1; c = complex(a)
> >>>> a == c
> > True
> >>>> b == c
> > True
> >>>> a == b
> > False

Impressive!

Since the topic now changed into "is Sage implementing Mathematics":
IMHO it is frankly impossible for *any* CAS to implement a
mathematically meaningful notion of == that is both useful and
rigorous.

If you simply say "a == b should return True only of a and b are the
same objects (i.e. same address in memory)" then you'd use a *non-
mathematical* notion of ==. Namely, this would depend on the
implementation, and without Sage's concept of caching Parents, you
would then even have "ZZ[x] != ZZ[x]" (without uniqueness of parent
structures, the two ZZ[x] would be two different objects).

Side note: You can alway use "A is B" instead of "A==B" if you really
need A and B to be identical objects.

A mathematically meaningful and useful notion of == must involve some
concept of mathematical equivalence (which is not identity!) between
objects. However, there are lots of mathematically natural
equivalences that are undecidable (equality of finitely presented
groups, for starters); hence, this can not be implemented in a
rigorous way. Moreover, the 'obvious' equivalence relation will depend
on the nature of objects under consideration.

So, the best one can hope for is to have a reasonable heuristics,
where "reasonable" is in the eye of the beholder.
E.g.: Take an element A of some algebraic structure (such as the
integers) and an element B of a "numerical something" (e.g. RR, which
is even not a ring AFAIK).
 What is a reasonable comparison of A and B?
1. From the viewpoint of A, one must refuse the idea that A and B can
be equal, since B is only defined up to some error margin, that would
be inacceptable for A
2. From the viewpoint of B, one must take into account the error
margin subject to which B is defined. If A is within this margin, then
A and B are "sufficiently equal".

And I think you will certainly find both supporters of 1. and of 2.,
and you will find both situations in which 1. or 2. is the natural way
of thinking.

Sure, this can be a reason for bugs that are hard to detect. But I
don't think there is a natural and rigorous way to avoid bugs of that
kind.

Cheers,
  Simon
--~--~---------~--~----~------------~-------~--~----~
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