Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Dividing Boolean Polynomials in Sage.

Hi all,

I'm working in a Boolean Polynomial Ring. I have an equation generator. My objective is to divide the highest possible monomial by the leading monomial of my equations.

NUMBER_OF_VARIABLES = 15
B = BooleanPolynomialRing(NUMBER_OF_VARIABLES,'x', order = 'degrevlex')

Each equation that I generate looks something like this.

f = x6*x2*x1 + x6*x5*x4 + x9*x5*x4 + x9*x6*x0 + x10*x2*x1 + x10*x4*x1 + x11*x9*x7 + x11*x10*x0 + x12*x4*x0 + x12*x7*x3 + x12*x9*x0 + x12*x10*x3 + x12*x10*x5 + x13*x7*x0 + x13*x7*x5 + x13*x8*x6 + x13*x10*x9 + x13*x11*x2 + x14*x5*x4 + x14*x11*x5 + x14*x13*x12 + x6*x3 + x7*x2 + x9*x1 + x10*x9 + x14*x8 + x14*x13 + x3 + x7 + x8 + 1

Getting the leading monomial of f:

print f.lm()
>>> x6*x2*x1

Getting the highest possible monomial of my ring (15 variables)

print f.set().vars()
>>> x14*x13*x12*x11*x10*x9*x8*x7*x6*x5*x4*x3*x2*x1*x0

But somehow I get an error when I try to divide them.

f.set().vars()/f.lm()
>>> bad operand type for unary ~: 'sage.rings.polynomial.pbori.BooleanMonomial'

I checked the documentation and nothing seems to work. I have tried all of the methods below and they do not work.

f.set().vars().divide(f.lm()) 
# http://doc.sagemath.org/html/en/reference/polynomial_rings/sage/rings/polynomial/pbori.html
f.set().vars().reduce(Ideal([f.lm()]))
# https://stackoverflow.com/questions/35233406/multivariate-polynomial-division-in-sage

I'm really at a loss here. I've seen answers whereby the code q,r = dividend.maxima_methods().divide(divisor) is used, but this seems like such a simple thing to do. Surely I'm missing something out. Why isn't division working? Multiplication and addition works, so why shouldn't division work?