Opened 19 months ago

Last modified 4 months ago

#31198 new defect

Add dict method for boolean polynomials

Reported by: slelievre Owned by:
Priority: major Milestone: sage-9.7
Component: commutative algebra Keywords:
Cc: slelievre Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by slelievre)

Boolean polynomials lack a dict method available for other polynomials.

This prevents expressing a multivariate polynomial as a polynomial in one if its variables.

Define a boolean polynomial:

sage: P = BooleanPolynomialRing(8, 'x')
sage: x = P.gens()
sage: p = x[1] * x[2] + x[1] * x[3] * x[5] + x[3] + x[7] * x[2]
sage: p
x1*x2 + x1*x3*x5 + x2*x7 + x3

Before this ticket:

sage: p.dict()
Traceback (most recent call last)
...
AttributeError: 'sage.rings.polynomial.pbori.pbori.BooleanPolynomial'
object has no attribute 'dict'

sage: p.polynomial(x[1])
Traceback (most recent call last)
...
AttributeError: 'sage.rings.polynomial.pbori.pbori.BooleanPolynomial'
object has no attribute 'dict'

Compare with polynomials over ZZ:

sage: P = PolynomialRing(ZZ, 8, 'x')
sage: x = P.gens()
sage: p = x[1] * x[2] + x[1] * x[3] * x[5] + x[3] + x[7] * x[2]
sage: p.dict()
{(0, 1, 0, 1, 0, 1, 0, 0): 1,
 (0, 1, 1, 0, 0, 0, 0, 0): 1,
 (0, 0, 1, 0, 0, 0, 0, 1): 1,
 (0, 0, 0, 1, 0, 0, 0, 0): 1}
sage: p.polynomial(x[1])
(x3*x5 + x2)*x1 + x2*x7 + x3

Initial report:

Change History (5)

comment:1 Changed 19 months ago by slelievre

  • Description modified (diff)

Boolean polynomials also lack floor division and mod.

Define

sage: P = BooleanPolynomialRing(8, 'x')
sage: x = P.gens()
sage: p = x[1] * x[2] + x[1] * x[3] * x[5] + x[3] + x[7] * x[2]
sage: p
x1*x2 + x1*x3*x5 + x2*x7 + x3

Then:

sage: p // x[1]
Traceback (most recent call last)
...
TypeError: unsupported operand parent(s) for //:
'Boolean PolynomialRing in x0, x1, x2, x3, x4, x5, x6, x7' and
'Boolean PolynomialRing in x0, x1, x2, x3, x4, x5, x6, x7'

sage: p % x[1]
Traceback (most recent call last)
...
NotImplementedError:

But in fact / performs floor division:

sage: p / x[1]
x2 + x3*x5

comment:2 Changed 18 months ago by mkoeppe

  • Milestone changed from sage-9.3 to sage-9.4

Setting new milestone based on a cursory review of ticket status, priority, and last modification date.

comment:3 Changed 13 months ago by mkoeppe

  • Milestone changed from sage-9.4 to sage-9.5

comment:4 Changed 8 months ago by mkoeppe

  • Milestone changed from sage-9.5 to sage-9.6

comment:5 Changed 4 months ago by mkoeppe

  • Milestone changed from sage-9.6 to sage-9.7
Note: See TracTickets for help on using tickets.