Correctness of the AKS primality test #
Theorem Agrawal, Kayal, Saxena, Theorem 4.1: if n ≥ 2 passes the tests of the
AKS algorithm for an r such that the multiplicative order of n modulo r exceeds log₂² n,
then n is prime (Cslib.AKS.prime_of_passes). Together with Cslib.AKS.passes_of_prime, the
tests characterize the primes (Cslib.AKS.prime_iff_passes).
Proof #
If n ≤ r, every a < n is coprime to n by step 3. Otherwise suppose n is composite with
least prime factor p. Step 3 forces p > r. Let ζ be a primitive r-th root of unity in a
field of characteristic p.
- Every
m = (n/p)^i p^jis introspective for every product of the polynomialsX + a,0 ≤ a ≤ ⌊√φ(r) log₂ n⌋(Cslib.AKS.Introspective). - Let
tbe the number of residues of thesemmodulor;log₂² n < ord_r(n) ≤ t ≤ φ(r). PutB = ⌊√t log₂ n⌋, soB < tandB ≤ ⌊√φ(r) log₂ n⌋. - Lower bound. The products of
BfactorsX + awith0 ≤ a ≤ BtakeC(2B, B)distinct values atζ: two products agreeing atζagree at thetdistinct rootsζ^m, and have degreeB < t. - Upper bound. Since
nis not a power ofp, the numbers(n/p)^i p^jwithi, j ≤ ⌊√t⌋are distinct; there are more thantof them, so two,m₁ ≠ m₂, agree modulor. Every value above is then a root ofY^{m₁} - Y^{m₂}, so there are at mostn^{⌊√t⌋}. - Finally
n^{⌊√t⌋} ≤ n^{√t} < 2^{B + 1} ≤ C(2B, B), a contradiction.
This follows Agrawal, Kayal, Saxena, Section 4, with two simplifications: the field is
generated by a primitive root of unity rather than by an irreducible factor of the cyclotomic
polynomial, and the lower bound counts only products of exactly B factors.
Main results #
Cslib.AKS.prime_of_passes: correctness of the AKS tests.Cslib.AKS.prime_iff_passes: the AKS tests characterize the primes.
References #
Elementary facts #
Products of linear polynomials #
The product ∏_{a ∈ s} (X + a) over ℤ / p of a multiset s of B numbers in [0, B].
Instances For
The lower bound. Let S be a set of more than B residues modulo r, each the residue
of a number introspective for every product ∏_{a ∈ s} (X + a). If B < p, these C(2B, B)
products take distinct values at a primitive r-th root of unity ζ: two products agreeing at ζ
agree at the |S| distinct roots ζ^m, and have degree B.
The upper bound. If distinct m₁ ≡ m₂ (mod r) are both introspective for every product
∏_{a ∈ s} (X + a), then every value of these products at a primitive r-th root of unity is a
root of Y^{m₁} - Y^{m₂}, so there are at most max m₁ m₂ such values.
The theorem #
Correctness of the AKS tests Agrawal, Kayal, Saxena, Theorem 4.1: if n ≥ 2
passes the tests of the AKS algorithm for an r such that the multiplicative order of n modulo
r exceeds log₂² n, then n is prime.
The AKS tests characterize the primes: for n ≥ 2 and r such that the multiplicative
order of n modulo r exceeds log₂² n, n passes the tests of the AKS algorithm exactly when
it is prime Agrawal, Kayal, Saxena, Theorem 4.1.