Prime Numbers
Prime Numbers Prime Numbers
178 Chapter 4 PRIMALITY PROVING Since n is prime, this must be a trivial factorization of n, thatis, c1 + tF −|u| =0, which implies c4 = t. Butc4 ≥ F ≥ n 3/10 ≥ 214 3/10 > 5 ≥ t, a contradiction. So if (1) fails, n must be composite. It is obvious that if n is prime, then (2) holds. ✷ As with Theorem 4.1.5, if Theorem 4.1.6 is to be used as a primality test, one should use Algorithm 9.2.11 as a subroutine to recognize squares. In addition, one should use Newton’s method or a divide and conquer strategy to search for integral roots of the cubic polynomial in condition (2) of the theorem. We next embody Theorems 4.1.3-4.1.6 in one algorithm. Algorithm 4.1.7 (The n − 1 test). Supposewehaveanintegern ≥ 214 and that (4.2) holds with F ≥ n 3/10 . This probabilistic algorithm attempts to decide whether n is prime (YES) or composite (NO). 1. [Pocklington test] Choose random a ∈ [2,n− 2]; if(a n−1 ≡ 1(modn)) return NO; // n is composite. for(prime q|F ) { g =gcd (a (n−1)/q mod n) − 1,n ; if(1
4.1 The n − 1 test 179 4.1.3 Succinct certificates The goal in primality testing is to quickly find a short proof of primality for prime inputs p. But how do we know that a short proof exists? Any search will necessarily be in vain if p does not have a short primality proof. We now show that every prime p has a short proof of primality, or what V. Pratt has called a “succinct certificate.” In fact, there is always a short proof that is based on the Lucas Theorem 4.1.1. This might appear obvious, for once you have somehow found the complete prime factorization of p − 1 and the primitive root a, the conditions (4.1) may be quickly verified. However, for the proof to be complete, one needs a demonstration that we indeed have the complete factorization of p − 1; that is, that the numbers q appearing in (4.1) really are prime. This suggests an iteration of the method, but then arises the possibility that there may be a proliferation of cases. The heart of the proof is to show in the worst case, not too much proliferation can occur. It is convenient to make a small, and quite practical, modification in the Lucas Theorem 4.1.1. The idea is to treat the prime q = 2 differently from the other primes q dividing p − 1. In fact, we know what a (p−1)/2 should be congruent to (mod p) ifitisnot1,namely−1. And if a (p−1)/2 ≡−1(modp), we do not need to check that a p−1 ≡ 1(modp). Further, if q is an odd prime factor of p − 1, let m = a (p−1)/2q .Ifm q ≡−1(modp) andm 2 ≡ 1(modp), then m ≡−1(modp) (regardless of whether p is prime or composite). Thus, to show that a (p−1)/q ≡ 1(modp) it suffices to show a (p−1)/2q ≡−1(modp). Thus we have the following result. Theorem 4.1.8. Suppose p>1 is an odd integer and a (p−1)/2 ≡−1(modp), a (p−1)/2q ≡−1(modp) for every odd prime q|p − 1. (4.11) Then p is prime. Conversely, if p is an odd prime, then every primitive root a of p satisfies conditions (4.11). We now describe what might be called a “Lucas tree.” It is a rooted tree with odd primes at the vertices, p at the root (level 0), and for each positive level k, aprimer at level k is connected to a prime q at level k − 1ifandonly if r|q − 1.Forexample,hereistheLucastreeforp = 1279: 1279 ✓❙ ✓✓ ❙❙71 3 ✓❙ ✓✓ ❙❙7 5 ✓ level 0 level 1 level 2 ✓✓ 3 level 3
- Page 140 and 141: 3.2 Sieving 127 } S = S \ (pS ∩ [
- Page 142 and 143: 3.3 Recognizing smooth numbers 129
- Page 144 and 145: 3.4 Pseudoprimes 131 } g =gcd(s, x)
- Page 146 and 147: 3.4 Pseudoprimes 133 Theorem 3.4.4.
- Page 148 and 149: 3.5 Probable primes and witnesses 1
- Page 150 and 151: 3.5 Probable primes and witnesses 1
- Page 152 and 153: 3.5 Probable primes and witnesses 1
- Page 154 and 155: 3.5 Probable primes and witnesses 1
- Page 156 and 157: 3.6 Lucas pseudoprimes 143 The Fibo
- Page 158 and 159: 3.6 Lucas pseudoprimes 145 Because
- Page 160 and 161: 3.6 Lucas pseudoprimes 147 use (3.1
- Page 162 and 163: 3.6 Lucas pseudoprimes 149 gcd(n, 2
- Page 164 and 165: 3.6 Lucas pseudoprimes 151 Theorem
- Page 166 and 167: 3.7 Counting primes 153 Label the c
- Page 168 and 169: 3.7 Counting primes 155 for b ≥ 2
- Page 170 and 171: 3.7 Counting primes 157 The heart o
- Page 172 and 173: 3.7 Counting primes 159 t =Im(s) ra
- Page 174 and 175: 3.7 Counting primes 161 Indeed, the
- Page 176 and 177: 3.8 Exercises 163 3.3. Prove that i
- Page 178 and 179: 3.8 Exercises 165 3.12. Show that a
- Page 180 and 181: 3.8 Exercises 167 3.28. Show that t
- Page 182 and 183: 3.9 Research problems 169 with W (n
- Page 184 and 185: 3.9 Research problems 171 3.50. The
- Page 186 and 187: 174 Chapter 4 PRIMALITY PROVING Rem
- Page 188 and 189: 176 Chapter 4 PRIMALITY PROVING sma
- Page 192 and 193: 180 Chapter 4 PRIMALITY PROVING Let
- Page 194 and 195: 182 Chapter 4 PRIMALITY PROVING Rec
- Page 196 and 197: 184 Chapter 4 PRIMALITY PROVING (mo
- Page 198 and 199: 186 Chapter 4 PRIMALITY PROVING pol
- Page 200 and 201: 188 Chapter 4 PRIMALITY PROVING if
- Page 202 and 203: 190 Chapter 4 PRIMALITY PROVING 4.3
- Page 204 and 205: 192 Chapter 4 PRIMALITY PROVING j =
- Page 206 and 207: 194 Chapter 4 PRIMALITY PROVING The
- Page 208 and 209: 196 Chapter 4 PRIMALITY PROVING The
- Page 210 and 211: 198 Chapter 4 PRIMALITY PROVING Rem
- Page 212 and 213: 200 Chapter 4 PRIMALITY PROVING pos
- Page 214 and 215: 202 Chapter 4 PRIMALITY PROVING Alg
- Page 216 and 217: 204 Chapter 4 PRIMALITY PROVING fac
- Page 218 and 219: 206 Chapter 4 PRIMALITY PROVING 196
- Page 220 and 221: 208 Chapter 4 PRIMALITY PROVING The
- Page 222 and 223: 210 Chapter 4 PRIMALITY PROVING Say
- Page 224 and 225: 212 Chapter 4 PRIMALITY PROVING But
- Page 226 and 227: 214 Chapter 4 PRIMALITY PROVING for
- Page 228 and 229: 216 Chapter 4 PRIMALITY PROVING so
- Page 230 and 231: 218 Chapter 4 PRIMALITY PROVING (2)
- Page 232 and 233: 220 Chapter 4 PRIMALITY PROVING hav
- Page 234 and 235: 222 Chapter 4 PRIMALITY PROVING sho
- Page 236 and 237: Chapter 5 EXPONENTIAL FACTORING ALG
- Page 238 and 239: 5.1 Squares 227 5.1.2 Lehman method
4.1 The n − 1 test 179<br />
4.1.3 Succinct certificates<br />
The goal in primality testing is to quickly find a short proof of primality for<br />
prime inputs p. But how do we know that a short proof exists? Any search<br />
will necessarily be in vain if p does not have a short primality proof. We now<br />
show that every prime p has a short proof of primality, or what V. Pratt has<br />
called a “succinct certificate.”<br />
In fact, there is always a short proof that is based on the Lucas Theorem<br />
4.1.1. This might appear obvious, for once you have somehow found the<br />
complete prime factorization of p − 1 and the primitive root a, the conditions<br />
(4.1) may be quickly verified.<br />
However, for the proof to be complete, one needs a demonstration that we<br />
indeed have the complete factorization of p − 1; that is, that the numbers q<br />
appearing in (4.1) really are prime. This suggests an iteration of the method,<br />
but then arises the possibility that there may be a proliferation of cases. The<br />
heart of the proof is to show in the worst case, not too much proliferation can<br />
occur.<br />
It is convenient to make a small, and quite practical, modification in the<br />
Lucas Theorem 4.1.1. The idea is to treat the prime q = 2 differently from<br />
the other primes q dividing p − 1. In fact, we know what a (p−1)/2 should be<br />
congruent to (mod p) ifitisnot1,namely−1. And if a (p−1)/2 ≡−1(modp),<br />
we do not need to check that a p−1 ≡ 1(modp). Further, if q is an odd prime<br />
factor of p − 1, let m = a (p−1)/2q .Ifm q ≡−1(modp) andm 2 ≡ 1(modp),<br />
then m ≡−1(modp) (regardless of whether p is prime or composite). Thus,<br />
to show that a (p−1)/q ≡ 1(modp) it suffices to show a (p−1)/2q ≡−1(modp).<br />
Thus we have the following result.<br />
Theorem 4.1.8. Suppose p>1 is an odd integer and<br />
a (p−1)/2 ≡−1(modp),<br />
a (p−1)/2q ≡−1(modp) for every odd prime q|p − 1.<br />
(4.11)<br />
Then p is prime. Conversely, if p is an odd prime, then every primitive root<br />
a of p satisfies conditions (4.11).<br />
We now describe what might be called a “Lucas tree.” It is a rooted tree<br />
with odd primes at the vertices, p at the root (level 0), and for each positive<br />
level k, aprimer at level k is connected to a prime q at level k − 1ifandonly<br />
if r|q − 1.Forexample,hereistheLucastreeforp = 1279:<br />
1279<br />
✓❙<br />
✓✓ ❙❙71<br />
3<br />
✓❙<br />
✓✓ ❙❙7<br />
5<br />
✓<br />
level 0<br />
level 1<br />
level 2<br />
✓✓ 3 level 3