On Fri, 23 Jan 2015 16:44:16 +0100 Vincent Delecroix <20100.delecr...@gmail.com> wrote:
> I found out that we have problems with elements of ZZ(x): > > sage: x = polygen(ZZ) > sage: p = (-1)/(-x) > sage: q = 1/x > sage: p > -1/-x > sage: q > 1/x > sage: p == q > True > sage: hash(p) == hash(q) > False > > One good challenge for the bug days. If no ticket is yet open about > it, I will do that shortly. Tickets http://trac.sagemath.org/ticket/16993 and http://trac.sagemath.org/ticket/16268 would be related. Here're my two cents, which you can probably ignore since I don't have time to work on this, and which is most likely naive: For nice rings, I think the problem could be solved by picking a distinguished representative for every equivalence class of associated elements, and using that in the denominator. This then yields a unique fraction representation (among representations with comaximal numerator and denominators, I think), which automatically solves the hash problem. This distinguished associate function can easily be extended to polynomial rings by picking the leading or trailing coefficient to be distinguished. For non-nice rings, I think it might be good to embed into a ring where there is a distinguished fraction representation and take the hash there. For instance Q(R[X]) might be embedded in Q(Q(R)[X]), which is better since Q(R)[X] is Euclidean. Regards, Erik Massop -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.