Algorithm Search⌘K

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 p>1p > 1 and aa be integers with ap−1≡1(modp)a^{p-1} \equiv 1 \pmod p and a(p−1)/q≢1(modp)a^{(p-1)/q} \not\equiv 1 \pmod p for every prime q∣p−1q \mid p - 1. Then pp is prime.

Proof. From ap−1≡1a^{p-1} \equiv 1, aa is a unit modulo pp. Let dd be its order in the group of units Zp∗\mathbb{Z}_p^*; then d∣p−1d \mid p - 1. If d<p−1d < p - 1, pick a prime qq dividing (p−1)/d(p-1)/d; then d∣(p−1)/qd \mid (p-1)/q and a(p−1)/q≡1a^{(p-1)/q} \equiv 1, which is false. So d=p−1d = p - 1, and the powers a,a2,…,ap−1a, a^2, \ldots, a^{p-1} are p−1p - 1 distinct units. So all of 1,…,p−11, \ldots, p - 1 are units, no jj with 1<j<p1 < j < p divides pp, and pp is prime. □\square

Lemma 2 (Crandall and Pomerance, Theorem 4.1.8). Let p>1p > 1 be odd, and suppose a(p−1)/2≡−1(modp)a^{(p-1)/2} \equiv -1 \pmod p and a(p−1)/(2q)≢−1(modp)a^{(p-1)/(2q)} \not\equiv -1 \pmod p for every odd prime q∣p−1q \mid p - 1. Then pp is prime. Conversely, every primitive root aa of an odd prime pp meets these conditions.

Proof. Squaring gives ap−1≡1a^{p-1} \equiv 1. Since pp is odd and p>1p > 1, p≥3p \ge 3 and −1≢1-1 \not\equiv 1, so a(p−1)/2≢1a^{(p-1)/2} \not\equiv 1; this is the condition of Lemma 1 for q=2q = 2. Let qq be an odd prime factor of p−1p - 1; then 2q∣p−12q \mid p - 1, since p−1p - 1 is even. Put m=a(p−1)/(2q)m = a^{(p-1)/(2q)} and suppose a(p−1)/q=m2≡1a^{(p-1)/q} = m^2 \equiv 1. As qq is odd, mq=(m2)(q−1)/2 m≡mm^q = (m^2)^{(q-1)/2} \, m \equiv m. But mq=a(p−1)/2≡−1m^q = a^{(p-1)/2} \equiv -1, so m≡−1m \equiv -1, against the hypothesis. So a(p−1)/q≢1a^{(p-1)/q} \not\equiv 1 for every prime q∣p−1q \mid p - 1, and Lemma 1 shows that pp is prime.

For the converse, let aa have order p−1p - 1 modulo the odd prime pp. Then x=a(p−1)/2x = a^{(p-1)/2} satisfies x2≡1x^2 \equiv 1 and x≢1x \not\equiv 1, and modulo a prime the only roots of x2−1x^2 - 1 are ±1\pm 1, so x≡−1x \equiv -1. If a(p−1)/(2q)≡−1a^{(p-1)/(2q)} \equiv -1 for an odd prime qq, then a(p−1)/q≡1a^{(p-1)/q} \equiv 1, against the order of aa. □\square

Soundness. We show by induction on the number of entries processed that every element of the set proven is prime. At the start, proven ={2}= \{2\}. Suppose that before an entry (p,a,{q:e})(p, a, \{q: e\}) all elements of proven are prime, and that the entry passes lines L5 to L9. By line L6 every listed qq is prime. By line L5 the listed exponents are at least 1 and ∏qe=p−1\prod q^e = p - 1, so by unique factorization the listed qq are exactly the prime factors of p−1p - 1. Also pp is odd and p≥3p \ge 3. Lines L7 to L9 check the conditions of Lemma 2 for each odd prime factor of p−1p - 1, since a(p−1)/2 mod p=p−1a^{(p-1)/2} \bmod p = p - 1 means a(p−1)/2≡−1a^{(p-1)/2} \equiv -1. So pp is prime by Lemma 2, and line L10 keeps the invariant. When the loop ends, line L11 returns true only if n∈n \in proven, so nn is prime. Lines L1 and L2 return true only for n=2n = 2.

Completeness. Let nn be prime. If n=2n = 2, line L1 accepts the empty list. Otherwise let TT be the set of odd primes in the Lucas tree of nn: n∈Tn \in T, and if p∈Tp \in T then every odd prime factor of p−1p - 1 is in TT. List the elements of TT in increasing order, each with a primitive root apa_p (which exists because Zp∗\mathbb{Z}_p^* is cyclic) and the factorization of p−1p - 1. Every odd prime factor qq of p−1p - 1 satisfies q<pq < p, so its entry comes earlier and qq is in proven when the entry of pp 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, nn 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 1+k1 + k modular powers, where kk 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 N(p)N(p) be the number of odd primes, counted with repeats, in the Lucas tree of an odd prime pp. We show N(p)<lg⁡pN(p) < \lg p by strong induction on pp (Crandall and Pomerance, proof of Theorem 4.1.9). For p=3p = 3, N(3)=1<lg⁡3N(3) = 1 < \lg 3. If p−1p - 1 is a power of 2, then N(p)=1<lg⁡pN(p) = 1 < \lg p. Otherwise let q1,…,qkq_1, \ldots, q_k be the distinct odd prime factors of p−1p - 1. Their product divides (p−1)/2(p - 1)/2, so

N(p)=1+∑i=1kN(qi)<1+∑i=1klg⁡qi≤1+lg⁡p−12<lg⁡p.N(p) = 1 + \sum_{i=1}^{k} N(q_i) < 1 + \sum_{i=1}^{k} \lg q_i \le 1 + \lg \frac{p - 1}{2} < \lg p.

So the list built in the completeness proof has fewer than lg⁡n\lg n entries. ■\blacksquare

Back to Pratt certificate