Ask Your Question
4

About Boolean Function

asked 8 years ago

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)?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
0

answered 8 years ago

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.

Preview: (hide)
link

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: 8 years ago

Seen: 852 times

Last updated: Oct 26 '16