Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Is there a way in sagemath's BooleanPolynomialRing Change the value in the boolean function through the variable in the list

when we can not determine which variable will be determine by a constant,i use a list use a list to store variables ,but the BooleanPolynomialRing do not support change the BooleanPolynomial by variables in list, It seems that it can only be changed by using the variable name; but when we encounter this situation ,is there another way to solve this problem ``` from sage.crypto.boolean_function import BooleanFunction R=BooleanPolynomialRing(4,"a,b,c,d")

R.inject_variables()

S=R.gens() print(S) f=ab+bc

print(f(a=1))

print(f(S[0]=1)) ```

Is there a way in sagemath's BooleanPolynomialRing Change the value in the boolean function through the variable in the list

when When we can not cannot determine which variable will be determine determined by a constant,i use a list constant, I use a list to store variables ,but variables, but the BooleanPolynomialRing do not BooleanPolynomialRing does not support change the BooleanPolynomial BooleanPolynomial by variables in list, list.

It seems that it can only be changed by using the variable name; name; but when we encounter this situation ,is situation, is there another way way to solve this problem ``` problem?

sage: from sage.crypto.boolean_function import BooleanFunction
R=BooleanPolynomialRing(4,"a,b,c,d")

sage: R = BooleanPolynomialRing(4, "a, b, c, d") sage: R.inject_variables() Defining a, b, c, d sage: S = R.gens() sage: print(S) (a, b, c, d)

R.inject_variables()

sage: f = a*b + b*c sage: print(f(a=1)) b*c + b

S=R.gens() print(S) f=ab+bc

print(f(a=1))

sage: print(f(S[0]=1)) ```

File "<ipython-input-9-504c2572fec0>", line 1 print(f(S[Integer(0)]=Integer(1))) ^ SyntaxError: expression cannot contain assignment, perhaps you meant "=="?

Is there a way in sagemath's BooleanPolynomialRing Change the value in the boolean function through the variable in the list

When we cannot determine which variable will be determined by a constant, I use a list to store variables, but the BooleanPolynomialRing does not support change the BooleanPolynomial by variables in list.

It seems that it can only be changed by using the variable name; but when we encounter this situation, is there another way to solve this problem?

sage: from sage.crypto.boolean_function import BooleanFunction
sage: R = BooleanPolynomialRing(4, "a, b, c, d")

sage: R.inject_variables()
Defining a, b, c, d
sage: S = R.gens()
sage: print(S)
(a, b, c, d)

sage: f = a*b + b*c
sage: print(f(a=1))
b*c + b

sage: print(f(S[0]=1))
  File "<ipython-input-9-504c2572fec0>", line 1
    print(f(S[Integer(0)]=Integer(1)))
            ^
SyntaxError: expression cannot contain assignment, perhaps you meant "=="?