Ask Your Question
4

About Boolean Function

asked 2016-10-26 13:30:47 +0100

sageuser1 gravatar image

I want to find the Algebraic Normal Form of a boolean function.

For example:

sage: R.<x1,x2,x3> = BooleanPolynomialRing(3, order='degneglex')
sage: x3>x1
True

sage: L = BooleanFunction(x1+x2*x3)

sage: L.truth_table()
(False, True, False, True, False, True, True, False)

sage: L.algebraic_normal_form()
x0 + x1*x2

Unfortunately, Algebraic Normal Form of this specific boolean function is not correct (x0 should be x3, x1 should be x2 and x2 should be x1). The answer of the ANF() method is in order='lex' (not as I desired in order = 'degneglex'). Furthermore, the ANF() form is calculated out of this ring (x0 involved?)

How should I extract the ANF() in correct syntax (where x3>x2>x1)?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-10-27 15:15:19 +0100

slelievre gravatar image

An import statement is needed to make your code work in Sage 7.4.

sage: R.<x1,x2,x3> = BooleanPolynomialRing(3, order='degneglex')
sage: x3>x1
True
sage: L = BooleanFunction(x1+x2*x3)
Traceback (most recent call last)
...
NameError: name 'BooleanFunction' is not defined
sage: from sage.crypto.boolean_function import BooleanFunction
sage: L = BooleanFunction(x1+x2*x3)
sage: L.algebraic_normal_form()
x0 + x1*x2

You can access the documentation for algebraic_normal_form with

sage: L.algebraic_normal_form?

and the whole source code with

sage: L.algebraic_normal_form??

Maybe you could suggest how the code should be amended to take variable names and ordering into account.

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

Stats

Asked: 2016-10-26 13:29:16 +0100

Seen: 824 times

Last updated: Oct 26 '16