sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.37k stars 469 forks source link

is_nilpotent is broken in BooleanPolynomialRings #23311

Open 0adfa02f-507d-46c6-aa3b-f2437a2a5873 opened 7 years ago

0adfa02f-507d-46c6-aa3b-f2437a2a5873 commented 7 years ago
sage: B.<a,b,c> = BooleanPolynomialRing(); B
Boolean PolynomialRing in a, b, c
sage: (a+b).is_nilpotent()
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-57-dbf2beaed57d> in <module>()
----> 1 (a+b).is_nilpotent()

src/sage/rings/polynomial/multi_polynomial.pyx in sage.rings.polynomial.multi_polynomial.MPolynomial.is_nilpotent (src/build/cythonized/sage/rings/polynomial/multi_polynomial.c:29775)()
   2347         # This generalizes easily to the multivariate case, by considering
   2348         # K[x,y,...] as K[x][y]...
-> 2349         d = self.dict()
   2350         return all(c.is_nilpotent() for c in d.values())
   2351 

[...]

AttributeError: 'sage.rings.polynomial.pbori.BooleanPolynomial' object has no attribute 'dict'

The code looking for self.dict is from trac [ticket:22454], that implemented is_unit and is_nilpotent for multivariate polynomial rings. It looks like BooleanPolynomialRings inherit that method but do not implement the dictionary.

As only 0 is nilpotent in these rings it should be simple to fix.

Component: algebra

Issue created by migration from https://trac.sagemath.org/ticket/23311

0adfa02f-507d-46c6-aa3b-f2437a2a5873 commented 7 years ago
comment:1

Boolean polynomial elements inherit from MPolynomial, but do not implement the dict, exponents, or _derivative methods, so many other methods also break: coefficients, truncate, derivative, polynomial, gradient, jacobian_ideal, newton_polytope, content, map_coefficients, sylvester_matrix, denominator, numerator, weighted_degree, nth_root, and specialization.