Ask Your Question

Revision history [back]

Here is a way to follow @kcrisman's advice to move to polynomials over the field with two elements.

First define the expression from your question:

sage: s_0_0, s_0_4 = var('s_0_0 s_0_4')
sage: 2*s_0_0 + s_0_4 + 3
2*s_0_0 + s_0_4 + 3
sage: a = 2*s_0_0 + s_0_4 + 3
sage: a
2*s_0_0 + s_0_4 + 3

This expression lives in Sage's symbolic ring:

sage: a.parent()
Symbolic Ring

Turn it into a polynomial over GF(2) (the finite field with two elements):

sage: a.polynomial(GF(2))
s_0_4 + 1

Note that we could also define a polynomial ring:

sage: R = PolynomialRing(GF(2), names='s_0_0, s_0_4')
sage: R
Multivariate Polynomial Ring in s_0_0, s_0_4 over Finite Field of size 2

and force a into R:

sage: R(a)
s_0_4 + 1