Ask Your Question

# About Boolean Function

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 close merge delete

## 1 Answer

Sort by ยป oldest newest most voted

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.

more

## Your Answer

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

Add Answer

## Stats

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

Seen: 775 times

Last updated: Oct 26 '16