Math 2.0

Number theory Finite fields and computational number theory Theorem

AKS primality test

Builds on Prime numberMultiplicative orderEuler's totient functionPolynomial ringQuotient ringFermat's little theoremFreshman's dreamMiller–Rabin primality test

Statement

Let n≥2n \ge 2 be an integer and let r≥2r \ge 2 be an integer. Assume that nn has no prime factor p≤rp \le r. Then gcd⁡(n,r)=1\gcd(n, r) = 1, so the multiplicative order ord⁡r(n)\ord_r(n) of nn modulo rr is defined. Assume also that ord⁡r(n)>(log⁡2n)2\ord_r(n) > (\log_2 n)^2. Let φ\varphi be Euler's totient function and let ℓ=⌊φ(r)log⁡2n⌋\ell = \floor{\sqrt{\varphi(r)} \log_2 n}. Then the following hold.

  1. The integer nn is prime if and only if nn is not a perfect power and (X+a)n≡Xn+a(modXr−1, n)(X + a)^n \equiv X^n + a \pmod{X^r - 1,\ n} for every integer aa with 1≤a≤ℓ1 \le a \le \ell. Here the congruence is an equality in the quotient ring ℤ[X]/(Xr−1,n)\Z[X]/(X^r - 1, n) of the polynomial ring ℤ[X]\Z[X]. A perfect power is an integer mkm^k with integers m,k≥2m, k \ge 2.
  2. For every n≥2n \ge 2 there is an integer r≤max⁡{3,⌈(log⁡2n)5⌉}r \le \max\set{3, \ceil{(\log_2 n)^5}} with ord⁡r(n)>(log⁡2n)2\ord_r(n) > (\log_2 n)^2 or gcd⁡(n,r)>1\gcd(n, r) > 1.
  3. Hence a deterministic algorithm decides whether nn is prime with a number of bit operations polynomial in log⁡n\log n.

Remarks

The algorithm is due to Manindra Agrawal, Neeraj Kayal and Nitin Saxena, in the paper "PRIMES is in P". It starts from a simple fact: for gcd⁡(a,n)=1\gcd(a, n) = 1, the integer nn is prime if and only if (X+a)n≡Xn+a(modn)(X + a)^n \equiv X^n + a \pmod n in ℤ[X]\Z[X]. The direct check of this identity costs about nn operations, so the test reduces it modulo Xr−1X^r - 1 for a small rr. If nn is composite with a prime factor pp, the congruences for all a≤ℓa \le \ell give a group of polynomials modulo pp. This group is forced to be both small and large at once, unless nn is a power of pp. The algorithm finds the smallest suitable rr, checks gcd⁡(a,n)\gcd(a, n) for a≤ra \le r, tests for perfect powers, and then checks the ℓ\ell congruences.

For nn prime, part 1 holds by Fermat's little theorem and the freshman's dream (X+a)p=Xp+ap(X + a)^p = X^p + a^p in characteristic pp. The test needs no unproved hypothesis and is never wrong, unlike the Miller–Rabin primality test, which is randomised.

Going deeper

For a student

The test turns the binomial identity (X+a)p=Xp+a(X + a)^p = X^p + a modulo pp into a criterion that is cheap to check. The working ring ℤ[X]/(Xr−1,n)\Z[X]/(X^r - 1, n) has elements of size about rlog⁡nr \log n bits, and rr is polynomial in log⁡n\log n by part 2. The proof uses only elementary algebra of finite fields and cyclotomic polynomials, together with a bound on the least common multiple of 1,…,m1, \ldots, m. In practice the test is slower than the Miller–Rabin primality test or elliptic curve methods, so its importance is mainly theoretical. It is a primality test, and it does not find factors; the integer factorization problem is believed to be much harder.

Reading path

To understand this page from the ground up, read these 18 pages in order. The foundations come first.

Show the path as a graph
Each page uses the pages above it. The colour of the bar on a box shows how strong the evidence is, and the box also gives it as text. The list has the same pages.
  • no evidence level
  1. Divisibility definition
  2. Euler's totient function concept
  3. Group concept
  4. Modular exponentiation concept
  5. Multiplicative order concept
  6. Polynomial ring concept
  7. Prime number concept
  8. Quotient ring concept
  9. Congruence modulo n definition
  10. Prime number definition
  11. Ring definition
  12. Fermat's little theorem statement
  13. Primality test concept
  14. Characteristic of a ring definition
  15. Commutative ring definition
  16. Miller–Rabin primality test concept
  17. Freshman's dream statement
  18. AKS primality test statement

Where this leads

1 page builds on this one.

Further reading

  1. Web https://en.wikipedia.org/wiki/AKS_primality_test
About this page
TagXMHQCDWZW1
URIm2://XMHQCDWZW1
Kindstatement, theorem
WritingW0 stub
MSC11Y11, 11A51, 68Q25
StatusThis copy of the site has no build data. Run m2 status XMHQCDWZW1.
AboutPrimality test, Prime number
UsesPrime number, Multiplicative order, Euler's totient function, Polynomial ring, Quotient ring, Fermat's little theorem, Freshman's dream, Miller–Rabin primality test
Same as
Changed2 November 2026

Markdown · JSON · Edit on GitHub

What this page needs for W1

  • a source with a locator (0 of 1)

The writing levels say how complete the text of a page is. They do not measure its truth.

What links here

Used by