1 | initial version |

I can't see any method for adding new variables to a boolean polynomial ring. I think you have to define a new ring with additional variables. There seems to be nothing like substitute_expressions. So I used replacing sub-strings as a workaround.

```
F0 = BooleanPolynomialRing(4,'x')
F0.inject_variables()
eqns = [x0 + x1*x2 + x3 + 1, x0 + x1*x2*x3, x0 + 1]
print eqns, eqns[0].parent()
# defining new ring with additional variable y
F1 = BooleanPolynomialRing(5, 'x0,x1,x2,x3,y')
F1.inject_variables()
# changing ring for all equations
eqns1 = [F1(eq) for eq in eqns]
print eqns1, eqns1[0].parent()
# replacing expressions
eqns2 = [eval(str(eq).replace('x1*x2','y')) for eq in eqns1]
# defining new ring by removing variables
F2 = F1.remove_var(x1,x2)
# changing ring for all equations
eqns2 = [F2(eq) for eq in eqns2]
print eqns2, eqns2[0].parent()
```

2 | No.2 Revision |

I can't see any method for adding new variables to a boolean polynomial ring. I think you have to define a new ring with additional variables. There seems to be nothing like substitute_expressions. So I used replacing sub-strings as a workaround.

```
F0 = BooleanPolynomialRing(4,'x')
F0.inject_variables()
eqns = [x0 + x1*x2 + x3 + 1, x0 + x1*x2*x3, x0 + 1]
print eqns, eqns[0].parent()
# defining new ring with additional variable y
F1 = BooleanPolynomialRing(5, 'x0,x1,x2,x3,y')
F1.inject_variables()
# changing ring for all equations
eqns1 = [F1(eq) for eq in eqns]
print eqns1, eqns1[0].parent()
# replacing expressions
eqns2 = [eval(str(eq).replace('x1*x2','y')) for eq in eqns1]
# defining new ring by removing variables
F2 = F1.remove_var(x1,x2)
# changing ring for all equations
eqns2 = [F2(eq) for eq in eqns2]
print eqns2, eqns2[0].parent()
```

updated answer:

```
def add_variables(R,new_vars):
"""
R - BooleanPolynomialRing
new_vars - string of comma- or space separated variable names
"""
if ',' in new_vars:
new = new_vars.split(',')
else:
new = new_vars.split(' ')
R_new = BooleanPolynomialRing(R.n_variables()+len(new),list(R.variable_names())+new)
R_new.inject_variables()
return R_new
```

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.