HOME

TheInfoList



OR:

The AKS primality test (also known as Agrawal–Kayal–Saxena primality test and cyclotomic AKS test) is a
deterministic Determinism is a philosophical view, where all events are determined completely by previously existing causes. Deterministic theories throughout the history of philosophy have developed from diverse and sometimes overlapping motives and cons ...
primality-proving
algorithm In mathematics and computer science, an algorithm () is a finite sequence of rigorous instructions, typically used to solve a class of specific problems or to perform a computation. Algorithms are used as specifications for performing ...
created and published by
Manindra Agrawal Manindra Agrawal (born 20 May 1966) is a professor at the Department of Computer Science and Engineering and the Deputy Director at the Indian Institute of Technology, Kanpur. He was also the recipient of the first Infosys Prize for Mathematics ...
,
Neeraj Kayal Neeraj Kayal ( hi, नीरज कयाल) is an Indian computer scientist and mathematician noted for development of the AKS primality test, along with Manindra Agrawal and Nitin Saxena. Kayal was born and raised in Guwahati, India. Earl ...
, and
Nitin Saxena Nitin Saxena (born 3 May 1981Saxena's CV at University of Bonn
) is ...
, computer scientists at the
Indian Institute of Technology Kanpur The Indian Institute of Technology Kanpur (IIT Kanpur) Hindi: भारतीय प्रौद्योगिकी संस्थान कानपुर) is a public institute of technology located in Kanpur, Uttar Pradesh, India. It was ...
, on August 6, 2002, in an article titled "PRIMES is in P". The algorithm was the first that can provably determine whether any given number is
prime A prime number (or a prime) is a natural number greater than 1 that is not a product of two smaller natural numbers. A natural number greater than 1 that is not prime is called a composite number. For example, 5 is prime because the only ways ...
or
composite Composite or compositing may refer to: Materials * Composite material, a material that is made from several different substances ** Metal matrix composite, composed of metal and other parts ** Cermet, a composite of ceramic and metallic materials ...
in polynomial time, without relying on mathematical conjectures such as the
generalized Riemann hypothesis The Riemann hypothesis is one of the most important conjectures in mathematics. It is a statement about the zeros of the Riemann zeta function. Various geometrical and arithmetical objects can be described by so-called global ''L''-functions, whic ...
. The proof is also notable for not relying on the field of
analysis Analysis ( : analyses) is the process of breaking a complex topic or substance into smaller parts in order to gain a better understanding of it. The technique has been applied in the study of mathematics and logic since before Aristotle (3 ...
. In 2006 the authors received both the
Gödel Prize The Gödel Prize is an annual prize for outstanding papers in the area of theoretical computer science, given jointly by the European Association for Theoretical Computer Science (EATCS) and the Association for Computing Machinery Special Interes ...
and
Fulkerson Prize The Fulkerson Prize for outstanding papers in the area of discrete mathematics is sponsored jointly by the Mathematical Optimization Society (MOS) and the American Mathematical Society (AMS). Up to three awards of $1,500 each are presented at e ...
for their work.


Importance

AKS is the first primality-proving algorithm to be simultaneously ''general'', ''polynomial-time'', ''deterministic'', and ''unconditionally correct''. Previous algorithms had been developed for centuries and achieved three of these properties at most, but not all four. * The AKS algorithm can be used to verify the primality of any general number given. Many fast primality tests are known that work only for numbers with certain properties. For example, the Lucas–Lehmer test works only for
Mersenne number In mathematics, a Mersenne prime is a prime number that is one less than a power of two. That is, it is a prime number of the form for some integer . They are named after Marin Mersenne, a French Minim friar, who studied them in the early 17th ...
s, while
Pépin's test In mathematics, Pépin's test is a primality test, which can be used to determine whether a Fermat number is prime A prime number (or a prime) is a natural number greater than 1 that is not a product of two smaller natural numbers. A natural ...
can be applied to
Fermat number In mathematics, a Fermat number, named after Pierre de Fermat, who first studied them, is a positive integer of the form :F_ = 2^ + 1, where ''n'' is a non-negative integer. The first few Fermat numbers are: : 3, 5, 17, 257, 65537, 42949672 ...
s only. * The maximum running time of the algorithm can be bounded by a
polynomial In mathematics, a polynomial is an expression consisting of indeterminates (also called variables) and coefficients, that involves only the operations of addition, subtraction, multiplication, and positive-integer powers of variables. An example ...
over the number of digits in the target number. ECPP and APR conclusively prove or disprove that a given number is prime, but are not known to have polynomial time bounds for all inputs. * The algorithm is guaranteed to distinguish deterministically whether the target number is prime or composite. Randomized tests, such as Miller–Rabin and Baillie–PSW, can test any given number for primality in polynomial time, but are known to produce only a probabilistic result. * The correctness of AKS is not conditional on any subsidiary unproven
hypothesis A hypothesis (plural hypotheses) is a proposed explanation for a phenomenon. For a hypothesis to be a scientific hypothesis, the scientific method requires that one can test it. Scientists generally base scientific hypotheses on previous obse ...
. In contrast, Miller's version of the Miller–Rabin test is fully deterministic and runs in polynomial time over all inputs, but its correctness depends on the truth of the yet-unproven
generalized Riemann hypothesis The Riemann hypothesis is one of the most important conjectures in mathematics. It is a statement about the zeros of the Riemann zeta function. Various geometrical and arithmetical objects can be described by so-called global ''L''-functions, whic ...
. While the algorithm is of immense theoretical importance, it is not used in practice, rendering it a
galactic algorithm A galactic algorithm is one that outperforms any other algorithm for problems that are sufficiently large, but where "sufficiently large" is so big that the algorithm is never used in practice. Galactic algorithms were so named by Richard Lipton ...
. For 64-bit inputs, the Baillie–PSW test is deterministic and runs many orders of magnitude faster. For larger inputs, the performance of the (also unconditionally correct) ECPP and APR tests is ''far'' superior to AKS. Additionally, ECPP can output a
primality certificate In mathematics and computer science, a primality certificate or primality proof is a succinct, formal proof that a number is prime. Primality certificates allow the primality of a number to be rapidly checked without having to run an expensive or u ...
that allows independent and rapid verification of the results, which is not possible with the AKS algorithm.


Concepts

The AKS primality test is based upon the following theorem: Given an integer n\ge 2 and integer a
coprime In mathematics, two integers and are coprime, relatively prime or mutually prime if the only positive integer that is a divisor of both of them is 1. Consequently, any prime number that divides does not divide , and vice versa. This is equivale ...
to n, n is prime if and only if the
polynomial In mathematics, a polynomial is an expression consisting of indeterminates (also called variables) and coefficients, that involves only the operations of addition, subtraction, multiplication, and positive-integer powers of variables. An example ...
congruence relation holds within the polynomial ring \mathbb_n /math>. Note that X denotes the indeterminate which generates this polynomial ring. This theorem is a generalization to polynomials of Fermat's little theorem. In one direction it can easily be proven using the
binomial theorem In elementary algebra, the binomial theorem (or binomial expansion) describes the algebraic expansion of powers of a binomial. According to the theorem, it is possible to expand the polynomial into a sum involving terms of the form , where the ...
together with the following property of the binomial coefficient: : \equiv 0 \pmod for all 0 if n is prime. While the relation () constitutes a primality test in itself, verifying it takes
exponential time In computer science, the time complexity is the computational complexity that describes the amount of computer time it takes to run an algorithm. Time complexity is commonly estimated by counting the number of elementary operations performed by t ...
: the brute force approach would require the expansion of the (X + a)^n polynomial and a reduction \pmod of the resulting n + 1 coefficients. The congruence is an equality in the
polynomial ring In mathematics, especially in the field of algebra, a polynomial ring or polynomial algebra is a ring (which is also a commutative algebra) formed from the set of polynomials in one or more indeterminates (traditionally also called variables ...
\mathbb_n /math>. Evaluating in a quotient ring of \mathbb_n /math> creates an upper bound for the degree of the polynomials involved. The AKS evaluates the equality in \mathbb_n (X^r- 1), making the computational complexity dependent on the size of r. For clarity, this is expressed as the congruence which is the same as: for some polynomials f and g. Note that all primes satisfy this relation (choosing g=0 in () gives (), which holds for n prime). This congruence can be checked in polynomial time when r is polynomial to the digits of n. The AKS algorithm evaluates this congruence for a large set of a values, whose size is polynomial to the digits of n. The proof of validity of the AKS algorithm shows that one can find an r and a set of a values with the above properties such that if the congruences hold then n is a power of a prime.


History and running time

In the first version of the above-cited paper, the authors proved the asymptotic time complexity of the algorithm to be \tilde(\log(n)^) (using Õ from big O notation)—the twelfth power of the number of digits in ''n'' times a factor that is polylogarithmic in the number of digits. However, this upper bound was rather loose; a widely-held conjecture about the distribution of the
Sophie Germain prime In number theory, a prime number ''p'' is a if 2''p'' + 1 is also prime. The number 2''p'' + 1 associated with a Sophie Germain prime is called a . For example, 11 is a Sophie Germain prime and 2 × 11 +  ...
s would, if true, immediately cut the worst case down to \tilde(\log(n)^6). In the months following the discovery, new variants appeared (Lenstra 2002, Pomerance 2002, Berrizbeitia 2002, Cheng 2003, Bernstein 2003a/b, Lenstra and Pomerance 2003), which improved the speed of computation greatly. Owing to the existence of the many variants, Crandall and Papadopoulos refer to the "AKS-class" of algorithms in their scientific paper "On the implementation of AKS-class primality tests", published in March 2003. In response to some of these variants, and to other feedback, the paper "PRIMES is in P" was updated with a new formulation of the AKS algorithm and of its proof of correctness. (This version was eventually published in ''
Annals of Mathematics The ''Annals of Mathematics'' is a mathematical journal published every two months by Princeton University and the Institute for Advanced Study. History The journal was established as ''The Analyst'' in 1874 and with Joel E. Hendricks as the ...
''.) While the basic idea remained the same, ''r'' was chosen in a new manner, and the proof of correctness was more coherently organized. The new proof relied almost exclusively on the behavior of cyclotomic polynomials over
finite fields In mathematics, a finite field or Galois field (so-named in honor of Évariste Galois) is a field that contains a finite number of elements. As with any field, a finite field is a set on which the operations of multiplication, addition, subt ...
. The new upper bound on time complexity was \tilde(\log(n)^), later reduced using additional results from
sieve theory Sieve theory is a set of general techniques in number theory, designed to count, or more realistically to estimate the size of, sifted sets of integers. The prototypical example of a sifted set is the set of prime numbers up to some prescribed lim ...
to \tilde(\log(n)^). In 2005, Pomerance and Lenstra demonstrated a variant of AKS that runs in \tilde(\log(n)^)operations,H. W. Lenstra Jr. and Carl Pomerance,
Primality testing with Gaussian periods
, preliminary version July 20, 2005.
leading to another updated version of the paper.H. W. Lenstra Jr. and Carl Pomerance,
Primality testing with Gaussian periods
", version of April 12, 2011.
Agrawal, Kayal and Saxena proposed a variant which would run in \tilde(\log(n)^) if
Agrawal's conjecture In number theory, Agrawal's conjecture, due to Manindra Agrawal in 2002, forms the basis for the cyclotomic AKS test. Agrawal's conjecture states formally: Let n and r be two coprime integers, coprime positive integers. If :(X - 1)^n \equiv X^n - ...
were true; however, a heuristic argument by Pomerance and Lenstra suggested that it is probably false.


The algorithm

The algorithm is as follows: : Input: integer . # Check if ''n'' is a
perfect power In mathematics, a perfect power is a natural number that is a product of equal natural factors, or, in other words, an integer that can be expressed as a square or a higher integer power of another integer greater than one. More formally, ''n'' ...
: if for integers and , output ''composite''. # Find the smallest ''r'' such that . (if ''r'' and ''n'' are not coprime, then skip this ''r'') # For all 2 ≤ ''a'' ≤ min (''r'', ''n''−1), check that ''a'' does not divide ''n'': If ''a'', ''n'' for some 2 ≤ ''a'' ≤ min (''r'', ''n''−1), output ''composite''. # If ''n'' ≤ ''r'', output ''prime''. # For to \left\lfloor \sqrt\log_2(n) \right\rfloor do #: if (''X''+''a'')''n''≠ ''X''''n''+''a'' (mod ''X''''r'' − 1,''n''), output ''composite''; # Output ''prime''. Here
ord Ord or ORD may refer to: Places * Ord of Caithness, landform in north-east Scotland * Ord, Nebraska, USA * Ord, Northumberland, England * Muir of Ord, village in Highland, Scotland * Ord, Skye, a place near Tarskavaig * Ord River, Western Austral ...
''r''(''n'') is the
multiplicative order In number theory, given a positive integer ''n'' and an integer ''a'' coprime to ''n'', the multiplicative order of ''a'' modulo ''n'' is the smallest positive integer ''k'' such that a^k\ \equiv\ 1 \pmod n. In other words, the multiplicative order ...
of ''n'' modulo ''r'', log2 is the binary logarithm, and \varphi(r) is Euler's totient function of ''r''. Step 3 is shown in the paper as checking 1 < (''a'',''n'') < ''n'' for all ''a'' ≤ ''r''. It can be seen this is equivalent to trial division up to ''r'', which can be done very efficiently without using gcd. Similarly the comparison in step 4 can be replaced by having the trial division return ''prime'' once it has checked all values up to and including \left\lfloor \sqrt \right\rfloor. Once beyond very small inputs, step 5 dominates the time taken. The essential reduction in complexity (from exponential to polynomial) is achieved by performing all calculations in the finite ring : R := \Bigl(\bigl(\Z/(n)\bigr) Bigr) \Bigl/ (X^r\!\!-\!\!1) \Bigr. consisting of n \cdot r elements. This ring contains only the r
monomial In mathematics, a monomial is, roughly speaking, a polynomial which has only one term. Two definitions of a monomial may be encountered: # A monomial, also called power product, is a product of powers of variables with nonnegative integer expone ...
s \ , and the coefficients are in \Z/(n) =: \Z_n which has n elements all of them codable within \log_2(n) bits. Most later improvements made to the algorithm have concentrated on reducing the size of ''r'' which makes the core operation in step 5 faster, and in reducing the size of ''s'', the number of loops performed in step 5.Daniel J. Bernstein,
Proving Primality After Agrawal-Kayal-Saxena
, version of January 25, 2003.
Typically these changes do not change the computational complexity, but can lead to many orders of magnitude less time taken, e.g. Bernstein's final version has a theoretical speedup by a factor of over 2 million.


Proof of validity outline

For the algorithm to be correct, all steps that identify ''n'' must be correct. Steps 1, 3 and 4 are trivially correct, since they are based on direct tests of the divisibility of ''n''. Step 5 is also correct: since (2) is true for any choice of ''a'' coprime to ''n'' and ''r'' if ''n'' is prime, an inequality means that ''n'' must be composite. The difficult part of the proof is showing that step 6 is true. Its proof of correctness is based on the upper and lower bounds of a
multiplicative group In mathematics and group theory, the term multiplicative group refers to one of the following concepts: *the group under multiplication of the invertible elements of a field, ring, or other structure for which one of its operations is referre ...
in \mathbb_ /math> constructed from the (''X'' + ''a'') binomials that are tested in step 5. Step 4 guarantees that these binomials are \left\lfloor \sqrt\log_2(n) \right\rfloor distinct elements of \mathbb_n /math>. For the particular choice of ''r'', the bounds produce a
contradiction In traditional logic, a contradiction occurs when a proposition conflicts either with itself or established fact. It is often used as a tool to detect disingenuous beliefs and bias. Illustrating a general tendency in applied logic, Aristotle's ...
unless ''n'' is prime or a power of a prime. Together with the test of step 1, this implies that ''n'' is always prime at step 6.


Example 1: ''n'' = 31 is prime

:Input: integer ''n'' = 31 > 1. Where PolynomialMod is a term-wise modulo reduction of the polynomial. e.g. PolynomialMod +2x2+3x3, 3nbsp;= x+2x2+0x3 See AKS Talk page for a discussion on why 'Example 2: n is not Prime past Step 4' is missing.


References


Further reading

*


External links

*
R. Crandall, Apple ACG, and J. Papadopoulos (March 18, 2003): On the implementation of AKS-class primality tests
(PDF)
Article by Borneman, containing photos and information about the three Indian scientists
(PDF)

* ttp://www.scottaaronson.com/writings/prime.pdf The Prime Facts: From Euclid to AKS by
Scott Aaronson Scott Joel Aaronson (born May 21, 1981) is an American theoretical computer scientist and David J. Bruton Jr. Centennial Professor of Computer Science at the University of Texas at Austin. His primary areas of research are quantum computing a ...
(PDF)
The PRIMES is in P little FAQ
by Anton Stiglic


2006 Fulkerson Prize Citation

The AKS "PRIMES in P" Algorithm Resource
{{Authority control Primality tests Finite fields Articles with example pseudocode