hashing broken for univariate Laurent polynomials?

29 views
Skip to first unread message

Tracy Hall

unread,
Aug 17, 2016, 5:48:50 PM8/17/16
to sage-support
I was trying to create sets of immutable matrices of univariate Laurent polynomials over the integers, and strangely was getting duplicate copies of the same matrix depending on they were computed, which is exactly what I wanted to avoid. Digging a little further, I seem to have uncovered a fundamental problem in the hashing for univariate Laurent polynomials, both on the current version at SageMathCloud and using 7.0 on my own computer.

Minimal reproducible example follows:

sage: version()
'SageMath Version 7.0, Release Date: 2016-01-19'

sage: P.<t> = LaurentPolynomialRing(ZZ); P
Univariate Laurent Polynomial Ring in t over Integer Ring

sage: a = P(0); a
0

sage: b = t - t; b
0

sage: a.__class__
<type 'sage.rings.polynomial.laurent_polynomial.LaurentPolynomial_univariate'>

sage: b.__class__
<type 'sage.rings.polynomial.laurent_polynomial.LaurentPolynomial_univariate'>

sage: a._fraction_pair()
(0, 1)

sage: b._fraction_pair()
(0, 1)

sage: a == b
True

hash(a)
0

hash(b)
1

Is this a known issue? I wasn't able to find it in any current tickets. I know that hashing of mathematical objects is a difficult area, and in fact should be disabled except for objects with a quickly computable canonical form (like, say, univariate Laurent polynomials over the integers), but it seems that when two objects both call themselves zero they ought to have the same hash.

—Tracy Hall

Vincent Delecroix

unread,
Aug 17, 2016, 5:52:59 PM8/17/16
to sage-s...@googlegroups.com
Indeed this is a bug! Thanks for the report. It is tracked at

https://trac.sagemath.org/ticket/21272
Reply all
Reply to author
Forward
0 new messages