Ask Your Question

Boolean Polynomial Ring

asked 2021-07-14 09:47:05 +0200

Sanu gravatar image

Dear all, I am working polynomial ring of 100 binary variables. Sometime I get polynomial with only 4 variables. I want to study these polynomials. My following code is giving error:

from sage.crypto.boolean_function import BooleanFunction
V = BooleanPolynomialRing(100,['x%d'%(i) for i in range(100)])
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2021-07-14 11:21:48 +0200

rburing gravatar image

It seems that the BooleanPolynomialRing constructor doesn't accept a map object as a list of variable names, only strings and lists and tuples. It doesn't recognize map(str, xx), so it converts it to a string, which yields '<map object at 0x7f9a3205e400>', which is not alphanumeric, so it says it's not valid as a name of a variable.

Instead, you can pass list(map(str, xx)).

An easier option is just P = BooleanPolynomialRing(l, f.variables()). The constructor converts all the elements of f.variables() to strings, to be used as the names of variables in P.

By the way, instead of inject_variables you can also do x = V.gens(), and then x[0] will be x0, etc. This is useful in library code, where you don't want to inject variables. In user code, injecting variables is fine.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2021-07-14 09:47:05 +0200

Seen: 40 times

Last updated: Jul 14