# Algebraic normal form

In Boolean algebra, the algebraic normal form (ANF), ring sum normal form (RSNF or RNF), Zhegalkin normal form, or Reed–Muller expansion is a way of writing propositional logic formulas in one of three subforms:

• The entire formula is purely true or false:
${\displaystyle 1}$
${\displaystyle 0}$
• One or more variables are combined into a term by AND (${\displaystyle \land }$), then one or more terms are combined by XOR (${\displaystyle \oplus }$) together into ANF. Negations are not permitted:
${\displaystyle a\oplus b\oplus \left(a\land b\right)\oplus \left(a\land b\land c\right)}$
• The previous subform with a purely true term:
${\displaystyle 1\oplus a\oplus b\oplus \left(a\land b\right)\oplus \left(a\land b\land c\right)}$

Formulas written in ANF are also known as Zhegalkin polynomials and Positive Polarity (or Parity) Reed–Muller expressions (PPRM).[1]

## Common uses

ANF is a canonical form, which means that two logically equivalent formulas will convert to the same ANF, easily showing whether two formulas are equivalent for automated theorem proving. Unlike other normal forms, it can be represented as a simple list of lists of variable names—conjunctive and disjunctive normal forms also require recording whether each variable is negated or not. Negation normal form is unsuitable for determining equivalence, since on negation normal forms, equivalence does not imply equality: a ∨ ¬a isn't reduced to the same thing as 1, even though they're logically equivalent.

Putting a formula into ANF also makes it easy to identify linear functions (used, for example, in linear-feedback shift registers): a linear function is one that is a sum of single literals. Properties of nonlinear-feedback shift registers can also be deduced from certain properties of the feedback function in ANF.

## Performing operations within algebraic normal form

There are straightforward ways to perform the standard boolean operations on ANF inputs in order to get ANF results.

XOR (logical exclusive disjunction) is performed directly:

(1 ⊕ x) ⊕ (1 ⊕ x ⊕ y)
1 ⊕ x1 ⊕ x ⊕ y
1 ⊕ 1 ⊕ x ⊕ x ⊕ y
y

NOT (logical negation) is XORing 1:[2]

¬(1 ⊕ x ⊕ y)
1 ⊕(1 ⊕ x ⊕ y)
1 ⊕ 1 ⊕ x ⊕ y
x ⊕ y

AND (logical conjunction) is distributed algebraically[3]

(1x)(1 ⊕ x ⊕ y)
1(1 ⊕ x ⊕ y)x(1 ⊕ x ⊕ y)
(1 ⊕ x ⊕ y) ⊕ (x ⊕ x ⊕ xy)
1 ⊕ x ⊕ x ⊕ x ⊕ y ⊕ xy
1 ⊕ x ⊕ y ⊕ xy

OR (logical disjunction) uses either 1 ⊕ (1 ⊕ a)(1 ⊕ b)[4] (easier when both operands have purely true terms) or a ⊕ b ⊕ ab[5] (easier otherwise):

(1 ⊕ x) + (1 ⊕ x ⊕ y)
1 ⊕ (1 ⊕ 1 ⊕ x)(1 ⊕ 1 ⊕ x ⊕ y)
1 ⊕ x(x ⊕ y)
1 ⊕ x ⊕ xy

## Converting to algebraic normal form

Each variable in a formula is already in pure ANF, so you only need to perform the formula's boolean operations as shown above to get the entire formula into ANF. For example:

x + (y ⋅ ¬z)
x + (y(1 ⊕ z))
x + (y ⊕ yz)
x ⊕ (y ⊕ yz) ⊕ x(y ⊕ yz)
x ⊕ y ⊕ xy ⊕ yz ⊕ xyz

## Formal representation

ANF is sometimes described in an equivalent way:

 ${\displaystyle f(x_{1},x_{2},\ldots ,x_{n})=\!}$ ${\displaystyle a_{0}\oplus \!}$ ${\displaystyle a_{1}x_{1}\oplus a_{2}x_{2}\oplus \cdots \oplus a_{n}x_{n}\oplus \!}$ ${\displaystyle a_{1,2}x_{1}x_{2}\oplus \cdots \oplus a_{n-1,n}x_{n-1}x_{n}\oplus \!}$ ${\displaystyle \cdots \oplus \!}$ ${\displaystyle a_{1,2,\ldots ,n}x_{1}x_{2}\ldots x_{n}\!}$
where ${\displaystyle a_{0},a_{1},\ldots ,a_{1,2,\ldots ,n}\in \{0,1\}^{*}}$ fully describes ${\displaystyle f}$.

### Recursively deriving multiargument Boolean functions

There are only four functions with one argument:

• ${\displaystyle f(x)=0}$
• ${\displaystyle f(x)=1}$
• ${\displaystyle f(x)=x}$
• ${\displaystyle f(x)=1\oplus x}$

To represent a function with multiple arguments one can use the following equality:

${\displaystyle f(x_{1},x_{2},\ldots ,x_{n})=g(x_{2},\ldots ,x_{n})\oplus x_{1}h(x_{2},\ldots ,x_{n})}$, where
• ${\displaystyle g(x_{2},\ldots ,x_{n})=f(0,x_{2},\ldots ,x_{n})}$
• ${\displaystyle h(x_{2},\ldots ,x_{n})=f(0,x_{2},\ldots ,x_{n})\oplus f(1,x_{2},\ldots ,x_{n})}$

Indeed,

• if ${\displaystyle x_{1}=0}$ then ${\displaystyle x_{1}h=0}$ and so ${\displaystyle f(0,\ldots )=f(0,\ldots )}$
• if ${\displaystyle x_{1}=1}$ then ${\displaystyle x_{1}h=h}$ and so ${\displaystyle f(1,\ldots )=f(0,\ldots )\oplus f(0,\ldots )\oplus f(1,\ldots )}$

Since both ${\displaystyle g}$ and ${\displaystyle h}$ have fewer arguments than ${\displaystyle f}$ it follows that using this process recursively we will finish with functions with one variable. For example, let us construct ANF of ${\displaystyle f(x,y)=x\lor y}$ (logical or):

• ${\displaystyle f(x,y)=f(0,y)\oplus x(f(0,y)\oplus f(1,y))}$
• since ${\displaystyle f(0,y)=0\lor y=y}$ and ${\displaystyle f(1,y)=1\lor y=1}$
• it follows that ${\displaystyle f(x,y)=y\oplus x(y\oplus 1)}$
• by distribution, we get the final ANF: ${\displaystyle f(x,y)=y\oplus xy\oplus x=x\oplus y\oplus xy}$