Saturday, May 7, 2016

Proof for the Lucas-Lehmer Primality Test

The Lucas-Lehmer primality test states that for the recursive sequence s0 = 4 and sn = sn-12 – 2, and for all p > 2, sp-2 is divisible by 2p – 1 if and only if 2p – 1 is a prime number.  (The following is loosely based on the proof found here with some improvements.)

Definitions

s0 = 4
Let a = ½s0 = ½(4) = 2
Let b = a2 – 1 = 22 – 1 = 3
Let u = a + √b
Let ū = a – √b

Then uū = (a + √b)(a – √b) = a2 – b = a2 – (a2 – 1) = a2 – a2 + 1 = 1

Then sn = u2^n + ū2^n by induction:
s0 = u2^0 + ū2^0 = u1 + ū1 = u + ū = a + √b + a – √b = 2a = 2(½s0) = s0
Assuming sn = u2^n + ū2^n:
sn+1 = sn2 – 2
sn+1 = (u2^n + ū2^n)2 – 2
sn+1 = u2(2^n) + 2u2^nū2^n + ū2(2^n) – 2
sn+1 = u2^(n+1) + 2(uū)2^n + ū2^(n+1) – 2
sn+1 = u2^(n+1) + 2(1)2^n + ū2^(n+1) – 2
sn+1 = u2^(n+1) + 2 + ū2^(n+1) – 2
sn+1 = u2^(n+1) + ū2^(n+1)

Proof of Sufficiency

Prove: If sp-2 is divisible by 2p – 1, then 2p – 1 is a prime number.

Assume sp-2 is divisible by 2p – 1:
Let M = 2p – 1
sp–2 = kM
u2^(p-2) + ū2^(p-2) = kM
u2^(p-2) = kM – ū2^(p-2)
u2^(p-2)u2^(p-2) = kMu2^(p-2) – ū2^(p-2)u2^(p-2)
(u2^(p-2))2 = kMu2^(p-2) – (uū)2^(p-2)
u2^(p-1) = kMu2^(p-2) – 1
Assume that 2p – 1 is not a prime number:
Let q be the smallest factor of M = 2p – 1
M ≡ 0 (mod q)
u2^(p-1) ≡ k(0)u2^(p-2) – 1 (mod q)
u2^(p-1) ≡ -1 (mod q)
(u2^(p-1))2 ≡ (-1)2 (mod q)
u2^p ≡ 1 (mod q)
Since u2^(p-1) ≠ 1, the order does not divide 2p – 1, so the order is 2p
Let X = {n + m√b | n, m ε Zq} and X* = {all elements of X except 0}
|X| = q2 and |X*| = q2 – 1 (as long as b = a2 – 1 is not a perfect square)
u is in X*, and since the order of an element is at most the order of its size,
so 2p ≤ q2 – 1 < q2
Since q is the smallest factor of M, q2 < M = 2p – 1
But then 2p < 2p – 1 which is a contradiction
So 2p – 1 must be a prime number.

Proof of Necessity

Prove: If 2p – 1 is a prime number, then sp-2 is divisible by 2p – 1.

Let M = 2p – 1

Assume p is not a prime number
Then p has two factors m ≥ 2 and n ≥ 2 such that p = mn
But then 2p – 1 = 2mn – 1 which is divisible by 2m – 1 and 2n – 1
This contradicts the assumption that 2p – 1 is a prime number
So p must be a prime number

(-1)(M-1)/2 ≡ -1 (mod M)
the exponent (M – 1)/2 = ½(2p – 1 – 1) = ½(2p – 2) = 2p-1 – 1 must be odd
-1 to an odd exponent is -1
so (-1)(M-1)/2 ≡ -1 (mod M)

2(M-1)/2 ≡ 1 (mod M)
by Fermat’s Little Theorem, 2p ≡ 2 (mod p), so 2p – 2 = np
2p – 2 must be even, and p (as a prime larger than 2) must be odd, so n = 2k and 2p – 2 = 2kp
so the exponent (M – 1)/2 = ½(2p – 1 – 1) = ½(2p – 2) = kp
now 2p ≡ 1 (mod 2p – 1) or 2p ≡ 1 (mod M)
so 2(M-1)/2 = 2kp = (2p)k ≡ 1k (mod M) = 1 (mod M)
so 2(M-1)/2 ≡ 1 (mod M)

3(M-1)/2 ≡ -1 (mod M)
22n+1 – 1 ≡ 7 (mod 12) for all positive integers of n by induction:
22(1)+1 – 1 = 23 – 1 = 7 ≡ 7 (mod 12)
Assuming 22n+1 – 1 ≡ 7 (mod 12):
then 22n+1 ≡ 8 (mod 12)
22(n + 1) +1 – 1 = 22n + 3 – 1 = 22n + 1 + 2 – 1 = 22n + 122 – 1 ≡ 8(4) – 1 (mod 12) ≡ 7 (mod 12)
Since p is a prime larger than 2, p = 2n + 1 for all positive integers,
so M = 2p – 1 = 22n+1 – 1 ≡ 7 (mod 12)
Since M ≡ 7 (mod 12), M = 12n + 7 for some integer n
By the law of quadratic reciprocity, (3 | 12n + 7)(12n + 7 | 3)
= (-1)½(3 – 1)½(12n + 7 – 1) = (-1)6n + 3 = -1
Now, (12n + 7 | 3) = (3·4n + 3·2 + 1 | 3) ≡ (1 | 3) = 1
So (3 | 12n + 7) = -1
Or (3 | M) = -1, which means 3 is a quadratic nonresidue of M
So by Euler’s criterion, 3(M-1)/2 ≡ -1 (mod M)

u(M+1)/2 ≡ -1 (mod M)
u = a + √b = (a + √b)2(a + 1)/2(a + 1) = (a + 1 + √b)^2/2(a + 1)
because the numerator (a + √b)2(a + 1) = 2(a + 1)a + 2(a + 1)√b
= 2a2 + 2a + 2(a + 1)√b = a2 + a2 + 2a + 1 – 1 + 2(a + 1)√b
= a2 + 2a + 1 + 2(a + 1)√b + a2 – 1 = (a + 1)2 + 2(a + 1)√b + b = (a + 1 + √b)2
(recall that b = a2 – 1)
so u(M+1)/2 = [(a + 1 + √b)^2/2(a + 1)](M+1)/22(a + 1)/-2(a + 1) (mod M) = -1 (mod M)
the numerator (a + 1 + √b)2(M+1)/2 = (a + 1 + √b)(M+1)
= (a + 1 + √b)(a + 1 + √b)M ≡ -2(a + 1) (mod M)
using the binomial theorem in a finite field and prime exponent M,
(a + 1 + √b)M ≡ (a + 1)M + √bM (mod M)
and using Fermat’s Little Theorem, (a + 1)M ≡ a + 1 (mod M)
and √bM = bM/2 = bM/2 – ½ + ½ = b(M – 1)/2 + ½ = b(M – 1)/2b½ = (a2 – 1)(M – 1)/2b½
= ((a – 1)(a + 1))(M – 1)/2b½ = (a – 1)(M – 1)/2(a + 1)(M – 1)/2b½
since a = 2, (a – 1)(M – 1)/2 = (2 – 1)(M – 1)/2 = 1(M – 1)/2 ≡ 1 (mod M), and (a + 1)(M – 1)/2 = (2 + 1)(M – 1)/2 = 3(M – 1)/2 ≡ -1 (mod M)
so √bM = (a – 1)(M – 1)/2(a + 1)(M – 1)/2b½ ≡ (1)(-1)b½ (mod M) = -√b (mod M)
therefore, (a + 1 + √b)M ≡ (a + 1 – √b) (mod M)
so (a + 1 + √b)2(M+1)/2 = (a + 1 + √b)(a + 1 + √b)M ≡ (a + 1 + √b)(a + 1 – √b) (mod M)
= (a + 1)2 – b (mod M) = (a + 1)2 – (a2 – 1) (mod M) = a2 + 2a + 1 – a2 + 1 (mod M)
= 2a + 2 (mod M) = 2(a + 1) (mod M)
the denominator (2(a + 1))(M+1)/2 = (2(a + 1))(M–1)/2 + 1 = (2(a + 1))(M–1)/2(2(a + 1))
= 2(M–1)/2(a + 1)(M–1)/2(2(a + 1)) ≡ (1)(-1)(2(a + 1)) (mod M) = -2(a + 1) (mod M)
so u(M+1)/2 ≡ -1 (mod M)

Therefore,
u(M+1)/2 ≡ -1 (mod M)
u(M+1)/4+(M+1)/4 ≡ -1 (mod M)
u(M+1)/4u(M+1)/4 ≡ -1 (mod M)
u(M+1)/4u(M+1)/4ū(M+1)/4 ≡ -ū(M+1)/4 (mod M)
u(M+1)/4(uū)(M+1)/4 ≡ -ū(M+1)/4 (mod M)
u(M+1)/4(1)(M+1)/4 ≡ -ū(M+1)/4 (mod M)
u(M+1)/4 ≡ -ū(M+1)/4 (mod M)
u(M+1)/4 + ū(M+1)/4 ≡ 0 (mod M)
u(2^p–1+1)/4 + ū(2^p–1+1)/4 ≡ 0 (mod M)
u(2^p)/4 + ū(2^p)/4 ≡ 0 (mod M)
u2^(p–2) + ū2^(p–2) ≡ 0 (mod M)
sp-2 ≡ 0 (mod M)
which means sp-2 is divisible by 2p – 1

Conclusion

We have proved the conditional (if sp-2 is divisible by 2p – 1, then 2p – 1 is a prime number) and its converse (if 2p – 1 is a prime number, then sp-2 is divisible by 2p – 1), which means the biconditional (sp-2 is divisible by 2p – 1 if and only if 2p – 1 is a prime number) is also true.

Interesting Notes

Other s0 values can be chosen, as long as the following criteria are met:
● b = a2 – 1 is not a perfect square
● (a – 1)(M – 1)/2 ≡ 1 (mod M)
● (a + 1)(M – 1)/2 ≡ -1 (mod M)

The traditional value for s0 is s0 = 4 (a = 2, a – 1 = 1, a + 1 = 3, and b = 3), but other values that fit the above criteria are s0 = 10 (a = 5, a – 1 = 4, a + 1 = 6, and b = 24) and s0 = 2/3 (a = 1/3, a – 1 = -2/3, a + 1 = 4/3, and b = -8/9).


No comments:

Post a Comment