Boolean Functions and Algebraic Normal Form (ANF)
- •
What it is
- •
ANF expresses a Boolean function as XORs of products of input bits. It makes exact identities, algebraic degree, annihilators, and linear approximations visible.
- •
- •
When to apply
- •
A filter or combiner is written with XOR, AND, and NOT, and you need to compare its outputs to algebraic or linear expressions.
- •
- •
Symbols and assumptions
- •
Inputs . In the Boolean ring, , . ANF is with bit coefficients .
- •
- •
Math — step by step
- •
- Replace XOR by addition, AND by multiplication, and NOT x by 1+x. OR requires unless its two terms cannot both be 1.
- •
- Expand products, remove pairs of identical monomials, and replace powers of a variable by that variable. The largest remaining monomial size is the algebraic degree.
- •
- For a small input count, enumerate every input and evaluate the function. A six-input filter has only rows: exhaustive checking can prove an identity for all possible local input tuples.
- •
- A linear approximation is a different object from an identity. Define Walsh sum . Agreement count is ; a nonzero W means bias under uniform inputs.
- •
- •
Worked example
- •
Checks and pitfalls
- •
LFSR Destroyer’s pasted function F has degree 5, but the actual emitted bit is z=1 XOR F. Complementing the output flips every Walsh correlation sign and changes which side of an annihilator identity applies.
- •
Exhaustive local truth tables prove identities and uniform-input agreement counts. They do not establish independence of temporally overlapping LFSR samples.
- •
- •
- •
Python
- •
from itertools import product def truth_table(f, n): return {x: f(*x) for x in product((0, 1), repeat=n)} OR = truth_table(lambda x, y: x ^ y ^ (x & y), 2) assert list(OR.values()) == [0, 1, 1, 1]
- •