Proofs: Berlekamp's factorization algorithm
These are the human proofs of Berlekamp's factorization algorithm, at full length.
BERLEKAMP returns the irreducible factors of a square-free polynomial full
This proof shows: correctness.
Let be a prime, , and monic of degree with distinct monic irreducible . Let , and identify a polynomial of degree less than with its coefficient vector and with its class in . The Berlekamp algebra is .
Lemma 1 ( is the left null space). , so .
Proof. In characteristic , , and for by Fermat's little theorem. So . Reducing modulo replaces by row of , so .
Lemma 2 (structure). The map is a bijection from onto , where is the set of constants in each . In particular .
Proof. The are pairwise coprime, so by the Chinese remainder theorem is a ring isomorphism from onto , and holds in exactly when it holds in every . Each is a field, so has at most roots in , and the constants are roots by Fermat's little theorem. So the solutions in are exactly the constants, and . is -linear, so .
Write for the constant with .
Lemma 3 (one gcd step). Let be a monic product of some of the , and . Then the nonconstant for are the products over the values that occur, so they form a partition of the factors of .
Proof. For , exactly when . As is square-free, is the product of the with . Each lies in exactly one of these gcds.
Basis. Line L2 returns vectors that form a basis of the left null space, which is by Lemma 1 and has dimension by Lemma 2. The vector is in , since row of is ; the elimination returns it first because column of is zero.
Invariant. After each pass of the loop at line L4, with the basis vectors used so far, the list of pieces is a list of monic polynomials that partitions , and two factors are in the same piece if and only if for all .
Proof. Before the loop, the list of pieces is , and the condition over an empty set of is true. In a pass with , Lemma 3 replaces each piece by its parts with equal , which refines the partition exactly by the new condition. A piece of degree that the implementation keeps unchanged has one factor, so it satisfies the condition trivially.
The loop stops with irreducible pieces. If the loop runs through all , then two factors in the same piece would have for all , including , where . Since the span , for every . But by Lemma 2 there is with , the vector with at and elsewhere, which has . So every piece has one factor. If the loop stops early because there are pieces, then the partition into nonempty parts of a set of size also has one factor per piece. The loop has at most passes, and each pass computes finitely many gcds, so it stops, and line L10 returns .