Re: [sage-devel] Re: hash for algebraic field

2014-06-12 Thread Ralf Hemmecke
>>> I'll second this. Are there *any* computer algebra systems (or >>> programming languages for that matter) out there such that 4/2 != 2 != >>> 2.0? Code would simply be too hard to write. >> >> Ada, I guess. It should give error if you try to compare integer with float. > > Ah, no wonder it's s

Re: [sage-devel] Re: hash for algebraic field

2014-06-12 Thread Robert Bradshaw
On Thu, Jun 12, 2014 at 10:19 AM, Vincent Delecroix <20100.delecr...@gmail.com> wrote: > 2014-06-12 19:13 UTC+02:00, Robert Bradshaw : >> On Thu, Jun 12, 2014 at 12:50 AM, Marc Mezzarobba >> wrote: >> >>> But here is a similar example right from the Sage library (adapted from >>> http://wiki.sagem

Re: [sage-devel] Re: hash for algebraic field

2014-06-12 Thread Volker Braun
On Thursday, June 12, 2014 6:44:44 PM UTC+1, William wrote: > > > sage: sum(FiniteEnumeratedSet([0,1,2])) > > 3 > > sage: FiniteEnumeratedSet(GF(3)) > > sage: sum(FiniteEnumeratedSet([0,1,2])) > > 0 > > But I would rather blame the use of caching rather than equality > testing. The issue i

Re: [sage-devel] Re: hash for algebraic field

2014-06-12 Thread William Stein
On Thu, Jun 12, 2014 at 10:19 AM, Vincent Delecroix <20100.delecr...@gmail.com> wrote: > 2014-06-12 19:13 UTC+02:00, Robert Bradshaw : >> On Thu, Jun 12, 2014 at 12:50 AM, Marc Mezzarobba >> wrote: >> >>> But here is a similar example right from the Sage library (adapted from >>> http://wiki.sagem

Re: [sage-devel] Re: hash for algebraic field

2014-06-12 Thread Vincent Delecroix
2014-06-12 19:13 UTC+02:00, Robert Bradshaw : > On Thu, Jun 12, 2014 at 12:50 AM, Marc Mezzarobba > wrote: > >> But here is a similar example right from the Sage library (adapted from >> http://wiki.sagemath.org/EqualityCoercion): >> >> sage: FiniteEnumeratedSet(GF(3)) >> {0, 1, 2} >> sage: add(Fi

Re: [sage-devel] Re: hash for algebraic field

2014-06-12 Thread Vincent Delecroix
2014-06-12 19:10 UTC+02:00, Robert Bradshaw : > On Thu, Jun 12, 2014 at 8:41 AM, Nils Bruin wrote: >> On Thursday, June 12, 2014 12:48:37 AM UTC-7, Marc Mezzarobba wrote: >>> >>> Sure. But why not have >>> >>> sage: bool(sin(x)^2+cos(x)^2==1) >>> True >>> >>> return False as well, and let the user

Re: [sage-devel] Re: hash for algebraic field

2014-06-12 Thread Robert Bradshaw
On Thu, Jun 12, 2014 at 12:50 AM, Marc Mezzarobba wrote: > But here is a similar example right from the Sage library (adapted from > http://wiki.sagemath.org/EqualityCoercion): > > sage: FiniteEnumeratedSet(GF(3)) > {0, 1, 2} > sage: add(FiniteEnumeratedSet([0,1,2])) > 0 Um, isn't that what you

Re: [sage-devel] Re: hash for algebraic field

2014-06-12 Thread Robert Bradshaw
On Thu, Jun 12, 2014 at 8:41 AM, Nils Bruin wrote: > On Thursday, June 12, 2014 12:48:37 AM UTC-7, Marc Mezzarobba wrote: >> >> Sure. But why not have >> >> sage: bool(sin(x)^2+cos(x)^2==1) >> True >> >> return False as well, and let the user test that >> >> (rhs-lhs).simplify_full() == 0 > > That

Re: [sage-devel] Re: hash for algebraic field

2014-06-10 Thread Volker Braun
On Tuesday, June 10, 2014 12:16:46 AM UTC+1, Nils Bruin wrote: > > Also, if we'd actually have the category as "Category of subsets of GF(5)" > we would probably end up with the memory leaks that parametrized categories > tend to cause. Still, it may be worth investigating how such containers >

Re: [sage-devel] Re: hash for algebraic field

2014-06-10 Thread Vincent Delecroix
Hi Nils, > Also, if we'd actually have the category as "Category of subsets of GF(5)" > we would probably end up with the memory leaks that parametrized categories > tend to cause. Still, it may be worth investigating how such containers > should interact with the category framework. Do we want/ne

Re: [sage-devel] Re: hash for algebraic field

2014-06-09 Thread Vincent Delecroix
2014-06-10 1:16 UTC+02:00, Nils Bruin : > On Monday, June 9, 2014 3:50:06 PM UTC-7, Volker Braun wrote: >> >> This seems like it would be a good solution in Sage, namely provide >> associative containers that participate in coercion and ensure that all >> elements have the same type. E.g. >> >> sag

Re: [sage-devel] Re: hash for algebraic field

2014-06-09 Thread Erik Massop
On Mon, 9 Jun 2014 15:50:06 -0700 (PDT) Volker Braun wrote: > On Monday, June 9, 2014 11:08:33 PM UTC+1, Nils Bruin wrote: > > > At any particular moment, though, an associative array has an index > > universe, so as long as equality and hash are consistent within that > > universe > > > > Th

Re: [sage-devel] Re: hash for algebraic field

2014-06-09 Thread Nils Bruin
On Monday, June 9, 2014 3:50:06 PM UTC-7, Volker Braun wrote: > > This seems like it would be a good solution in Sage, namely provide > associative containers that participate in coercion and ensure that all > elements have the same type. E.g. > > sage: s = SageSet([3, 8]); s # universe = ZZ

Re: [sage-devel] Re: hash for algebraic field

2014-06-09 Thread Volker Braun
On Monday, June 9, 2014 11:08:33 PM UTC+1, Nils Bruin wrote: > At any particular moment, though, an associative array has an index > universe, so as long as equality and hash are consistent within that > universe > This seems like it would be a good solution in Sage, namely provide associative

Re: [sage-devel] Re: hash for algebraic field

2014-06-09 Thread Nils Bruin
On Monday, June 9, 2014 2:19:32 PM UTC-7, William wrote: > I wanted to understand what you just claimed, so in Magma [1] I typed > this: > > 5 eq GF(7)!5 > > but it output "true".So clearly I completely misunderstood your > claim. Can you be more precise? > Sorry, you didn't misunde

Re: [sage-devel] Re: hash for algebraic field

2014-06-09 Thread Vincent Delecroix
Hi, > and as discussed there, it's a compromise that was considered the least > bad. The main problem is that if you want, for all integers a,b and > distinct primes p,q, that > > GF(p)(a) == GF(p)(b) implies a == GF(p)(b) and > GF(q)(a) == GF(q)(b) implies a == GF(q)(b) I do not want that! Consi

Re: [sage-devel] Re: hash for algebraic field

2014-06-09 Thread William Stein
On Mon, Jun 9, 2014 at 2:14 PM, Nils Bruin wrote: > The consistent solution, and one that is mathematically defendable, would be > to have a != GF(p)(a) for integers a (i.e., always force explicit coercion > for equality to hold). So that is making "==" strict enough to allow hash to > meet its re

Re: [sage-devel] Re: hash for algebraic field

2014-06-09 Thread Nils Bruin
On Monday, June 9, 2014 1:44:41 PM UTC-7, Erik Massop wrote: > > On Mon, 09 Jun 2014 16:48:09 +0200 > leif > wrote: > > > Volker Braun wrote: > > > On Monday, June 9, 2014 12:54:56 AM UTC+1, vdelecroix wrote: > > > > > > sage: {3, AA(3)} > > > {3, 3} > > > > > > > > > IMHO you shou

Re: [sage-devel] Re: hash for algebraic field

2014-06-09 Thread Volker Braun
On Monday, June 9, 2014 9:44:41 PM UTC+1, Erik Massop wrote: > > IMHO this should be disallowed. All objects that implement __hash__ > should live up to contract of __hash__, which is that a==b implies > hash(a)==hash(b) I totally agree that the situation is currently unsatisfactory, but the s

Re: [sage-devel] Re: hash for algebraic field

2014-06-09 Thread Erik Massop
On Mon, 09 Jun 2014 16:48:09 +0200 leif wrote: > Volker Braun wrote: > > On Monday, June 9, 2014 12:54:56 AM UTC+1, vdelecroix wrote: > > > > sage: {3, AA(3)} > > {3, 3} > > > > > > IMHO you should never put sage objects with different parents into an > > associative container. > > Altho