# Algebraic normal form

Variadic XOR (left) and AND (right)
From ANF to truth table
From truth table to ANF

The algebraic normal form (ANF) is a canonical normal form of a Boolean function.

It is a XOR formula of AND formulas, like this:

${\displaystyle a\oplus b\oplus \left(a\land b\right)\oplus \left(a\land b\land c\right)}$

Here it shall be abbreviated like this:

${\displaystyle {\Bigl [}\left(a\right),\left(b\right),\left(a,b\right),\left(a,b,c\right){\Bigr ]}}$

Both operators are variadic, i.e. they can have any number of arguments, including none or one.
XOR without arguments is false (empty sum 0). AND without arguments is true (empty product 1).

The empty XOR is false:

${\displaystyle {\Bigl [}~{\Bigr ]}~~\iff ~~0}$

XOR containing empty AND is true:

${\displaystyle {\Bigl [}\left(~\right){\Bigr ]}~~\iff ~~1}$

XOR containing unary AND is an atomic statement:

${\displaystyle {\Bigl [}\left(a\right){\Bigr ]}~~\iff ~~a}$

The presence of empty AND works as a negator:

${\displaystyle {\Bigl [}\left(~\right),\left(a\right){\Bigr ]}~~\iff ~~\neg a}$

So the negation of the introductory example is this:

${\displaystyle {\Bigl [}\left(~\right),\left(a\right),\left(b\right),\left(a,b\right),\left(a,b,c\right){\Bigr ]}}$

Each AND formula corresponds to a set of integers, which can be interpreted as a binary number.
Thus each XOR formula also corresponds to a set of integers, which can also be interpreted as a binary number.

 ${\displaystyle 0}$ ${\displaystyle {\Bigl [}~{\Bigr ]}}$ ${\displaystyle {\Bigl \{}~{\Bigl \}}}$ ${\displaystyle {\Bigl \{}~{\Bigl \}}}$ empty sum 0 ${\displaystyle 0}$ ${\displaystyle 1}$ ${\displaystyle {\Bigl [}\left(~\right){\Bigr ]}}$ ${\displaystyle {\Bigl \{}\{~\}{\Bigl \}}}$ ${\displaystyle {\Bigl \{}0{\Bigl \}}}$ ${\displaystyle 2^{0}}$ ${\displaystyle 1}$ ${\displaystyle a}$ ${\displaystyle {\Bigl [}\left(a\right){\Bigr ]}}$ ${\displaystyle {\Bigl \{}\{0\}{\Bigl \}}}$ ${\displaystyle {\Bigl \{}1{\Bigl \}}}$ ${\displaystyle 2^{1}}$ ${\displaystyle 2}$ ${\displaystyle \neg a}$ ${\displaystyle {\Bigl [}\left(~\right),\left(a\right){\Bigr ]}}$ ${\displaystyle {\Bigl \{}\{~\},\{0\}{\Bigl \}}}$ ${\displaystyle {\Bigl \{}0,1{\Bigl \}}}$ ${\displaystyle 2^{0}+2^{1}}$ ${\displaystyle 3}$ ${\displaystyle b}$ ${\displaystyle {\Bigl [}\left(b\right){\Bigr ]}}$ ${\displaystyle {\Bigl \{}\{1\}{\Bigl \}}}$ ${\displaystyle {\Bigl \{}2{\Bigl \}}}$ ${\displaystyle 2^{2}}$ ${\displaystyle 4}$ ${\displaystyle \neg b}$ ${\displaystyle {\Bigl [}\left(~\right),\left(b\right){\Bigr ]}}$ ${\displaystyle {\Bigl \{}\{~\},\{1\}{\Bigl \}}}$ ${\displaystyle {\Bigl \{}0,2{\Bigl \}}}$ ${\displaystyle 2^{0}+2^{2}}$ ${\displaystyle 5}$ ${\displaystyle a\oplus b}$ ${\displaystyle {\Bigl [}\left(a\right),\left(b\right){\Bigr ]}}$ ${\displaystyle {\Bigl \{}\{0\},\{1\}{\Bigl \}}}$ ${\displaystyle {\Bigl \{}1,2{\Bigl \}}}$ ${\displaystyle 2^{1}+2^{2}}$ ${\displaystyle 6}$ ${\displaystyle a\leftrightarrow b}$ ${\displaystyle {\Bigl [}\left(~\right),\left(a\right),\left(b\right){\Bigr ]}}$ ${\displaystyle {\Bigl \{}\{~\},\{0\},\{1\}{\Bigl \}}}$ ${\displaystyle {\Bigl \{}0,1,2{\Bigl \}}}$ ${\displaystyle 2^{0}+2^{1}+2^{2}}$ ${\displaystyle 7}$ ${\displaystyle a\land b}$ ${\displaystyle {\Bigl [}\left(a,b\right){\Bigr ]}}$ ${\displaystyle {\Bigl \{}\{0,1\}{\Bigl \}}}$ ${\displaystyle {\Bigl \{}3{\Bigl \}}}$ ${\displaystyle 2^{3}}$ ${\displaystyle 8}$ ${\displaystyle \neg a\lor \neg b}$ ${\displaystyle {\Bigl [}\left(~\right),\left(a,b\right){\Bigr ]}}$ ${\displaystyle {\Bigl \{}\{~\},\{0,1\}{\Bigl \}}}$ ${\displaystyle {\Bigl \{}0,3{\Bigl \}}}$ ${\displaystyle 2^{0}+2^{3}}$ ${\displaystyle 9}$ ${\displaystyle a\land \neg b}$ ${\displaystyle {\Bigl [}\left(a\right),\left(a,b\right){\Bigr ]}}$ ${\displaystyle {\Bigl \{}\{0\},\{0,1\}{\Bigl \}}}$ ${\displaystyle {\Bigl \{}1,3{\Bigl \}}}$ ${\displaystyle 2^{1}+2^{3}}$ ${\displaystyle 10}$ ${\displaystyle \neg a\lor b}$ ${\displaystyle {\Bigl [}\left(~\right),\left(a\right),\left(a,b\right){\Bigr ]}}$ ${\displaystyle {\Bigl \{}\{~\},\{0\},\{0,1\}{\Bigl \}}}$ ${\displaystyle {\Bigl \{}0,1,3{\Bigl \}}}$ ${\displaystyle 2^{0}+2^{1}+2^{3}}$ ${\displaystyle 11}$ ${\displaystyle \neg a\land b}$ ${\displaystyle {\Bigl [}\left(b\right),\left(a,b\right){\Bigr ]}}$ ${\displaystyle {\Bigl \{}\{1\},\{0,1\}{\Bigl \}}}$ ${\displaystyle {\Bigl \{}2,3{\Bigl \}}}$ ${\displaystyle 2^{2}+2^{3}}$ ${\displaystyle 12}$ ${\displaystyle a\lor \neg b}$ ${\displaystyle {\Bigl [}\left(~\right),\left(b\right),\left(a,b\right){\Bigr ]}}$ ${\displaystyle {\Bigl \{}\{~\},\{1\},\{0,1\}{\Bigl \}}}$ ${\displaystyle {\Bigl \{}0,2,3{\Bigl \}}}$ ${\displaystyle 2^{0}+2^{2}+2^{3}}$ ${\displaystyle 13}$ ${\displaystyle a\lor b}$ ${\displaystyle {\Bigl [}\left(a\right),\left(b\right),\left(a,b\right){\Bigr ]}}$ ${\displaystyle {\Bigl \{}\{0\},\{1\},\{0,1\}{\Bigl \}}}$ ${\displaystyle {\Bigl \{}1,2,3{\Bigl \}}}$ ${\displaystyle 2^{1}+2^{2}+2^{3}}$ ${\displaystyle 14}$ ${\displaystyle \neg a\land \neg b}$ ${\displaystyle {\Bigl [}\left(~\right),\left(a\right),\left(b\right),\left(a,b\right){\Bigr ]}}$ ${\displaystyle {\Bigl \{}\{~\},\{0\},\{1\},\{0,1\}{\Bigl \}}}$ ${\displaystyle {\Bigl \{}0,1,2,3{\Bigl \}}}$ ${\displaystyle 2^{0}+2^{1}+2^{2}+2^{3}}$ ${\displaystyle 15}$ ${\displaystyle \left(\neg a\lor \neg b\lor \neg c\right)\land \left(a\lor b\right)}$ ${\displaystyle {\Bigl [}\left(a\right),\left(b\right),\left(a,b\right),\left(a,b,c\right){\Bigr ]}}$ ${\displaystyle {\Bigl \{}\{0\},\{1\},\{0,1\},\{0,1,2\}{\Bigl \}}}$ ${\displaystyle {\Bigl \{}1,2,3,7{\Bigl \}}}$ ${\displaystyle 2^{1}+2^{2}+2^{3}+2^{7}}$ ${\displaystyle 142}$ ${\displaystyle \left(a\land b\land c\right)\lor \left(\neg a\land \neg b\right)}$ ${\displaystyle {\Bigl [}\left(~\right),\left(a\right),\left(b\right),\left(a,b\right),\left(a,b,c\right){\Bigr ]}}$ ${\displaystyle {\Bigl \{}\{~\},\{0\},\{1\},\{0,1\},\{0,1,2\}{\Bigl \}}}$ ${\displaystyle {\Bigl \{}0,1,2,3,7{\Bigl \}}}$ ${\displaystyle 2^{0}+2^{1}+2^{2}+2^{3}+2^{7}}$ ${\displaystyle 143}$

In short, there is a bijection between the non-negative integers and algebraic normal forms.
While the truth tables for a given arity can be interpreted as integers, truth tables in general can only be assigned rational values between 0 and 1.
The ANF allows to assign every Boolean function (regardless of its arity) a unique integer, which shall be called its Zhegalkin index.

It has the interesting property, that its parity corresponds to the just mentioned fraction:
Boolean functions with an even (odd) Zhegalkin index have a rational value below (above) ${\displaystyle {\tfrac {1}{2}}}$.
Here is a list of examples: v:Studies of Euler diagrams/list

The Zhegalkin indices of Boolean functions in the same permutation equivalence class have the same binary weight.

For a specific arity each Boolean function can be interpreted as an integer.
So the map from integers to Boolean functions becomes a map from integers to integers, which is the Zhegalkin permutation.