Module 8 : Primality Testing

Lecture 3 : AKS PRIMALITY TEST

 

Algorithm:

INPUT: n ≥ 1

STEP 1: If ∃ a, b > 1 N such that n= ab, then output COMPOSITE.

STEP2: Find the minimal r  N such that or(n) > log2 (n)

STEP3 : For a=1to r do

           If 1< (a,n) < n, then output COMPOSITE

STEP4: if r ≥ n, then output PRIME

STEP5:  For a=1 to  do
If (x+a)n – (xn +a) ≠ 0 mod (n, xr -1), then output COMPOSITE.

STEP 6: output PRIME.

Proof:  If n is prime, STEP 1 cannot return COMPOSITE. Similarly, STEP 3 cannot return COMPOSITE. Hence, the AKS algorithm will always return PRIME if n is prime.

Conversely, if the AKS algorithm returns PRIME, we will prove that n is indeed prime. If the algorithm returns PRIME in STEP 4, n must be prime because otherwise a non trivial factor a would have been found in STEP 3. The only case which remains is that if the algorithm returns PRIME in STEP 6.

Lemma: There exists an integer r  N with the following properties:

Proof:

For n=2, r=3 satisfies all the conditions.

For
 We know that for n ≥ 7, lcm(n) ≥ 2n where lcm(m) denote the LCM of first m numbers.