Proofs: Equal-degree factorization
These are the human proofs of Equal-degree factorization, at full length.
EQUAL-DEGREE returns the irreducible factors and stops with probability one full
This proof shows: correctness.
Let be a prime, , , and with distinct monic irreducible of degree . Let be a field with elements. For odd , . For , .
Lemma 1 (pieces). Every polynomial on the stack and in the output is monic and is the product of a nonempty set of the , and the sets of all polynomials on the stack and in the output form a partition of .
Proof. This holds after line L1. Line L3 removes and either line L4 moves it to the output, or line L6 or line L9 pushes and , or line L9 pushes back. In line L6 and line L9, is a monic divisor of with and (in line L6, since and ). As is square-free, is the product of a nonempty proper subset of the factors of , and is the product of the rest.
Output. By Lemma 1, each output with is a product of of degree , so it is exactly one . When the stack is empty, Lemma 1 says that the output is a partition of into single factors, so it lists each exactly once.
Lemma 2 (Chinese remainder theorem). Let as in Lemma 1. The map is a ring isomorphism from onto , and each factor is a field with elements. So if is uniform among the polynomials of degree less than , the residues are independent and uniform in fields with elements.
Proof. The are pairwise coprime, so this is the Chinese remainder theorem for . Both sides have elements, so the bijection maps the uniform distribution to the uniform distribution on the product. Each is irreducible of degree , so is a field with elements.
Lemma 3 (the values of ). Let be a field with elements and .
- If is odd, then ; only for , and for exactly values of .
- If , then , and for exactly values of .
Proof. (1) The group is cyclic of even order . For , , so , and since is odd. The map is a group homomorphism from to . With a generator , because the order of is , so the map is onto and its kernel has elements.
(2) In characteristic , is additive, so is additive, and , since in . So is a root of , which means . is a polynomial in of degree , so it has at most roots, and is not zero. So is an onto additive map from to , and each of its two values is taken times.
Lemma 4 (one attempt). Let be a piece with factors, and uniform among the polynomials of degree less than , drawn again while is constant. Then the attempt at lines L5 to L9 pushes a proper factorization of with probability at least .
Proof. Let and let be uniform over all polynomials of degree less than , constants included, with residues . Let be the event that the values (or for ) are all equal, and for odd also all .
A nonconstant that fails lies in . By Lemma 2, (or ) has residues (or ) modulo , so is the product of the with , and line L9 splits unless all are equal. If , line L6 splits , since and give . So for odd a failure needs , that is, all , and all equal.
The probability of . For odd , by Lemma 3 each is nonzero with with probability , and the same holds for . By the independence of Lemma 2, . For , each is or with probability exactly , so .
Drawing again while is constant. Then is distributed as given that is not constant. Let be the probability that is constant and the probability that is a constant in . A constant has equal residues, so every nonzero constant is in , and for also ; hence . The failure probability is at most .
Termination. Each attempt on a piece with factors succeeds with probability at least , independently of earlier attempts. So the number of attempts on that piece until it splits is at most a geometric random variable with mean , and it is finite with probability . Each split increases the number of pieces by one, and there are at most pieces, so there are splits and outputs in all. Pieces with one factor have degree and are output at line L4 without an attempt. So the algorithm stops with probability , after an expected number of at most attempts, and by the part on the output it then returns .