Ask Your Question

Revision history [back]

Differentiation of boolean polynomials themselves is not implemented, so what diff does is: first convert to a symbolic expression and then take the derivative. The resulting object is a symbolic expression, which explains the different behavior of the degree method on the result.

What you can do instead is convert your boolean polynomial to an ordinary polynomial (lift it to the cover ring), then take the derivative, and then convert back to a boolean polynomial, like so:

sage: C = R.cover_ring()
sage: X = R(diff(C(S[64]), C(S_128[21]))); X
s6 + s53 + s76*s91 + s97 + k6 + 1
sage: X.degree()
2

I guess that is what you want to do.

Beware that $\frac{\partial}{\partial x_i}\bigl(x_i^2 + x_i\bigr)=2x_i+1=1$ in $\mathbb{F}_2[x_1,\ldots,x_n]$, so the meaning/sense of differentiating a boolean polynomial, which is an element of $\mathbb{F}_2[x_1,\ldots,x_n]/\langle x_1^2+x_1, \ldots, x_n^2+x_n \rangle$, is questionable.