Proofs: Pollard-Strassen algorithm
These are the human proofs of Pollard-Strassen algorithm, at full length.
Correctness of the Pollard-Strassen algorithm full
This proof shows: correctness, termination.
Let , let be the least integer with , and write . For let . The blocks are disjoint and their union is . Let be the least prime factor of .
Termination. Lines L2 and L3 run a fixed number of polynomial operations, each a finite loop. Lines L4 to L6 are loops over at most blocks of elements. So the algorithm stops.
Lemma 1 (division by a monic polynomial). Let be monic of degree . For every there are unique with and .
Proof. Existence, by induction on . If , take , . Otherwise let be the leading coefficient of and . Then has degree less than , because is monic, and the induction hypothesis applies to it. Uniqueness: if , then . If , the left side has degree , because the leading coefficient of is and so the leading coefficient of is that of , which is not zero. The right side has degree less than . So and .
Write for this . The map is -linear, and exactly when .
Lemma 2 (remainders and evaluation). (a) For , . (b) If and are monic and , then .
Proof. (a) Write with a constant, by Lemma 1. Substitute : . (b) Write with , and . Then , so , by linearity.
Lemma 3 (the remainder tree). Let be the subproduct tree of the monic polynomials : each inner node is the product of its children, and each node is monic and divides its parent. Put at the root, and at each child the remainder of its parent's value modulo the child. Then the value at the leaf is .
Proof. By induction down the tree, the value at each node is . This holds at the root. If it holds at a parent with a child , then , and the value at is , by Lemma 2(b). At a leaf , Lemma 2(a) gives . A node that is copied to the next level because it has no partner has itself as its only child, and .
Lemma 4 (the implementation of division). For monic of degree and of formal degree , the implementation computes correctly.
Proof. Write for the reversal of a polynomial of formal degree . From with and , reversal gives for some polynomial . The constant term of is , because is monic, so is invertible modulo and . Since , this congruence determines , hence , and .
The inverse comes from Newton's iteration: if and , then . Starting from , which is correct modulo , the iteration doubles the precision until it reaches . The schoolbook branch is the existence step of Lemma 1 applied coefficient by coefficient from the top.
Polynomial products use either the schoolbook sum or Kronecker substitution. In the latter, the coefficients are written as digits in base , where for the lengths . Each coefficient of the integer product of the polynomials is a sum of at most terms below , so . Hence the product of the packed integers has the digits with no carries, and unpacking and reducing modulo gives the product in .
Lemma 5 (the block values). For each , .
Proof. In , evaluated at is . Reduction modulo is a ring homomorphism that commutes with evaluation, so the polynomial of line L2 satisfies . Line L3 computes by Lemmas 3 and 4.
Lemma 6 (a gcd above 1). if and only if some has .
Proof. By Lemma 5, , since and the product differ by a multiple of . If a prime divides and the product, then divides some factor , so . Conversely, if divides and some , it divides the product.
Lemma 7 (nothing below ). Every integer with has .
Proof. If , then some prime divides both, so and , against the choice of as the least prime factor. For the gcd is .
Theorem. The algorithm returns .
Proof. Case 1: . Let be the index with . Then , so by Lemma 6. For , every satisfies , so by Lemma 7, and by Lemma 6. So the loop of line L4 reaches line L6 first at . There, every with is not a divisor of : a divisor of has a prime factor that divides and is at most , so . And divides . So line L6 returns .
Case 2: . Then . If were composite, then with , so , a contradiction. So is prime and . Every satisfies , so by Lemmas 6 and 7 no block has a gcd above , and line L7 returns .
In both cases the output is the least prime factor of .
For the full factorization, each pass of the driver divides out every power of the least prime factor of what is left. All prime factors of the cofactor are then larger than . If , then cannot have two prime factors, each above , so is prime. The cofactor decreases at every pass, so the driver stops, and the primes collected multiply to the input.