Proofs: Pollard's p-1 algorithm
These are the human proofs of Pollard's p-1 algorithm, at full length.
Correctness of Pollard's p-1 algorithm full
This proof shows: correctness, termination.
Let , and . Write .
Lemma 1. , where runs over the primes at most and is the largest integer with .
Proof. Let be the product on the right. For each and each prime power , we have and , so . So is a common multiple of . Conversely each factor is one of the numbers , so divides every common multiple, and these factors are pairwise coprime, so divides every common multiple. Hence is the least common multiple.
Invariant. Let be the primes at most . After passes of the loop of lines L2 to L4, .
Proof. Before the loop, , which is the empty product case . If the claim holds after passes, line L3 computes and line L4 replaces by , which is congruent to .
Termination. The loop runs once for each of the primes, line L3 is a finite loop because , and line L4 is a modular exponentiation with a finite exponent. So the algorithm stops.
The output. By the invariant and Lemma 1, after the loop, so line L5 returns , which is a positive divisor of (if , then and ).
Theorem. (a) Let be a prime factor of with , and suppose that every prime power that divides is at most . Then .
(b) Let be the exact power of a prime that divides . If , then , so .
(c) If the hypotheses of (a) and (b) both hold, then and is a proper factor of .
Proof. (a) Every prime power has , so and by Lemma 1. These prime powers are pairwise coprime, so . By Fermat's little theorem, , so , and divides and , so .
(b) If , then , against the hypothesis. Since and , .
(c) By (a), , and by (b), .