Proofs: Pratt certificate
These are the human proofs of Pratt certificate, at full length.
Correctness of the Pratt certificate checker full
This proof shows: correctness, termination, error.
We prove that VERIFY-PRATT accepts only primes (soundness), that every prime has a list it accepts (completeness), that it stops, and that it has no error. We also bound the size of the list.
Lemma 1 (Lucas). Let and be integers with and for every prime . Then is prime.
Proof. From , is a unit modulo . Let be its order in the group of units ; then . If , pick a prime dividing ; then and , which is false. So , and the powers are distinct units. So all of are units, no with divides , and is prime.
Lemma 2 (Crandall and Pomerance, Theorem 4.1.8). Let be odd, and suppose and for every odd prime . Then is prime. Conversely, every primitive root of an odd prime meets these conditions.
Proof. Squaring gives . Since is odd and , and , so ; this is the condition of Lemma 1 for . Let be an odd prime factor of ; then , since is even. Put and suppose . As is odd, . But , so , against the hypothesis. So for every prime , and Lemma 1 shows that is prime.
For the converse, let have order modulo the odd prime . Then satisfies and , and modulo a prime the only roots of are , so . If for an odd prime , then , against the order of .
Soundness. We show by induction on the number of entries processed that every element of the set proven is prime. At the start, proven . Suppose that before an entry all elements of proven are prime, and that the entry passes lines L5 to L9. By line L6 every listed is prime. By line L5 the listed exponents are at least 1 and , so by unique factorization the listed are exactly the prime factors of . Also is odd and . Lines L7 to L9 check the conditions of Lemma 2 for each odd prime factor of , since means . So is prime by Lemma 2, and line L10 keeps the invariant. When the loop ends, line L11 returns true only if proven, so is prime. Lines L1 and L2 return true only for .
Completeness. Let be prime. If , line L1 accepts the empty list. Otherwise let be the set of odd primes in the Lucas tree of : , and if then every odd prime factor of is in . List the elements of in increasing order, each with a primitive root (which exists because is cyclic) and the factorization of . Every odd prime factor of satisfies , so its entry comes earlier and is in proven when the entry of is checked; the prime 2 is in proven from the start. Line L5 passes by construction, and lines L7 to L9 pass by the converse in Lemma 2. So every entry passes, is added at the end, and line L11 returns true.
Termination. The loop of line L4 runs once for each entry, and each entry does at most one product per listed prime, one membership test per listed prime and modular powers, where is the number of listed primes. Each of these stops, so the checker stops on every finite list.
Error. The checker is deterministic, so for a fixed input its answer is fixed. By soundness it never accepts a composite, and by completeness every prime has an accepted list. There is no error probability.
Size. Let be the number of odd primes, counted with repeats, in the Lucas tree of an odd prime . We show by strong induction on (Crandall and Pomerance, proof of Theorem 4.1.9). For , . If is a power of 2, then . Otherwise let be the distinct odd prime factors of . Their product divides , so
So the list built in the completeness proof has fewer than entries.