1 | initial version |
Use a dictionary for substitutions.
The following should achieve the goal in the question.
sage: nvar = 10 # number of variables
sage: B = BooleanPolynomialRing(nvar, 'x', order='degrevlex')
sage: var = B.gens()
sage: var_sub = var[nvar - 1]
sage: var_sub
x9
sage: B.inject_variables()
sage: f = x0 + x1 + x7*x6*x9*x2*x0 + x6*x4*x3*x1 + x9*x7
sage: f.subs({var_sub: B.zero()})
Note that it prints out a deprecation warning about using order "degrevlex"
with BooleanPolynomialRing
.
DeprecationWarning: using 'degrevlex' in Boolean polynomial rings is deprecated.
If needed, reverse the order of variables manually and use 'degneglex'
See http://trac.sagemath.org/13849 for details.
Side comment: sing B.zero()
is slightly neater (and faster) than using B(0)
.