Prime Numbers
Prime Numbers Prime Numbers
212 Chapter 4 PRIMALITY PROVING But if kB and d is an integer with d>(ln n) 1.84 , then there is a squarefree number D in the interval [d, 4d] such that each prime factor q of D satisfies (1) q
4.5 The primality test of Agrawal, Kayal, and Saxena (AKS test) 213 4.5.4 A quartic time primality test Since the most time-consuming step of Algorithm 4.5.1 is the checking of the congruence (x + a) n ≡ x n + a (mod x r − 1,n) for so many values of a, this area would be a good place to look for improvements. In Theorem 4.5.4 we had the improvement of replacing x r − 1 with a polynomial f(x) of possibly smaller degree. Another idea is to get binomial congruences verified “for free.” In the following theorem, we replace x r − 1withx r − b for a suitable integer b, and we need only verify one binomial congruence. Theorem 4.5.7. Let n, r, b be integers with n > 1, r|n − 1, r > lg 2 n, b n−1 ≡ 1(modn), andgcd(b (n−1)/q − 1,n)=1for each prime q|r. If then n is a prime or prime power. (x − 1) n ≡ x n − 1(modx r − b, n), (4.30) Proof. Let p|n be prime and set A = b (n−1)/r mod p. ThenA has order r in Z ∗ p, so that in particular, r|p − 1 (see Pocklington’s Theorem 4.1.3). Note that Thus, by our hypothesis, x n = x · x n−1 = x(x r ) (n−1)/r ≡ Ax (mod x r − b, p). (4.31) (x − 1) n ≡ x n − 1 ≡ Ax − 1(modx r − b, p). Also note that if f(x) ≡ g(x) (modx r − b, p), then f(A i x) ≡ g(A i x) (mod x r − b, p) for any integer i, since(A i x) r − b ≡ x r − b (mod p). Thus, taking f(x) =(x − 1) n and g(x) =Ax − 1, we have (x − 1) n2 ≡ (Ax − 1) n ≡ A 2 x − 1(modx r − b, p), and more generally by induction, we get (x − 1) nj ≡ A j x − 1(modx r − b, p) (4.32) for every nonnegative integer j. Note that if c is an integer and c r ≡ 1(modp), then c ≡ A k (mod p) for some integer k; indeed, all that is used for this observation is that p is prime and A has order r modulo p. So,wehave x p = x · x p−1 = x(x r ) (p−1)/r ≡ b (p−1)/r x ≡ A k x (mod x r − b, p) for some integer k. Thus, since (Ak ) p ≡ Ak (mod p), we have by induction that x pi ≡ A ik x (mod x r − b, p) (4.33) for every nonnegative integer i. Wehavef(x) pi Zp[x], so that by (4.32) and (4.33), we have = f(xpi) for every f(x) ∈ (x − 1) pin j ≡ (A j x − 1) pi ≡ A j x pi − 1 ≡ A j+ik x − 1(modx r − b, p)
- 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 190 and 191: 178 Chapter 4 PRIMALITY PROVING Sin
- 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 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
- Page 240 and 241: 5.2 Monte Carlo methods 229 That is
- Page 242 and 243: 5.2 Monte Carlo methods 231 It is c
- Page 244 and 245: 5.2 Monte Carlo methods 233 computi
- Page 246 and 247: 5.3 Baby-steps, giant-steps 235 cal
- Page 248 and 249: 5.4 Pollard p − 1 method 237 can
- Page 250 and 251: 5.6 Binary quadratic forms 239 f(jB
- Page 252 and 253: 5.6 Binary quadratic forms 241 so o
- Page 254 and 255: 5.6 Binary quadratic forms 243 equi
- Page 256 and 257: 5.6 Binary quadratic forms 245 is a
- Page 258 and 259: 5.6 Binary quadratic forms 247 In t
- Page 260 and 261: 5.6 Binary quadratic forms 249 of D
- Page 262 and 263: 5.7 Exercises 251 is completely rig
- Page 264 and 265: 5.7 Exercises 253 of each of these
- Page 266 and 267: 5.8 Research problems 255 5.17. Sho
- Page 268 and 269: 5.8 Research problems 257 modulo th
- Page 270 and 271: 5.8 Research problems 259 In judgin
- Page 272 and 273: 262 Chapter 6 SUBEXPONENTIAL FACTOR
4.5 The primality test of Agrawal, Kayal, and Saxena (AKS test) 213<br />
4.5.4 A quartic time primality test<br />
Since the most time-consuming step of Algorithm 4.5.1 is the checking of the<br />
congruence (x + a) n ≡ x n + a (mod x r − 1,n) for so many values of a, this<br />
area would be a good place to look for improvements. In Theorem 4.5.4 we<br />
had the improvement of replacing x r − 1 with a polynomial f(x) of possibly<br />
smaller degree. Another idea is to get binomial congruences verified “for free.”<br />
In the following theorem, we replace x r − 1withx r − b for a suitable integer<br />
b, and we need only verify one binomial congruence.<br />
Theorem 4.5.7. Let n, r, b be integers with n > 1, r|n − 1, r > lg 2 n,<br />
b n−1 ≡ 1(modn), andgcd(b (n−1)/q − 1,n)=1for each prime q|r. If<br />
then n is a prime or prime power.<br />
(x − 1) n ≡ x n − 1(modx r − b, n), (4.30)<br />
Proof. Let p|n be prime and set A = b (n−1)/r mod p. ThenA has order r in<br />
Z ∗ p, so that in particular, r|p − 1 (see Pocklington’s Theorem 4.1.3). Note that<br />
Thus, by our hypothesis,<br />
x n = x · x n−1 = x(x r ) (n−1)/r ≡ Ax (mod x r − b, p). (4.31)<br />
(x − 1) n ≡ x n − 1 ≡ Ax − 1(modx r − b, p).<br />
Also note that if f(x) ≡ g(x) (modx r − b, p), then f(A i x) ≡ g(A i x)<br />
(mod x r − b, p) for any integer i, since(A i x) r − b ≡ x r − b (mod p). Thus,<br />
taking f(x) =(x − 1) n and g(x) =Ax − 1, we have<br />
(x − 1) n2<br />
≡ (Ax − 1) n ≡ A 2 x − 1(modx r − b, p),<br />
and more generally by induction, we get<br />
(x − 1) nj<br />
≡ A j x − 1(modx r − b, p) (4.32)<br />
for every nonnegative integer j.<br />
Note that if c is an integer and c r ≡ 1(modp), then c ≡ A k (mod p) for<br />
some integer k; indeed, all that is used for this observation is that p is prime<br />
and A has order r modulo p. So,wehave<br />
x p = x · x p−1 = x(x r ) (p−1)/r ≡ b (p−1)/r x ≡ A k x (mod x r − b, p)<br />
for some integer k. Thus, since (Ak ) p ≡ Ak (mod p), we have by induction<br />
that<br />
x pi<br />
≡ A ik x (mod x r − b, p) (4.33)<br />
for every nonnegative integer i. Wehavef(x) pi<br />
Zp[x], so that by (4.32) and (4.33), we have<br />
= f(xpi) for every f(x) ∈<br />
(x − 1) pin j<br />
≡ (A j x − 1) pi<br />
≡ A j x pi<br />
− 1 ≡ A j+ik x − 1(modx r − b, p)