AKS primality test

The AKS primality test (also known as Agrawal–Kayal–Saxena primality test and cyclotomic AKS test) is a deterministic primality-proving algorithm created and published by Manindra Agrawal, Neeraj Kayal, and Nitin Saxena, computer scientists at the Indian Institute of Technology Kanpur, on August 6, 2002, in an article titled "PRIMES is in P".[1] The algorithm was the first one which is able to determine in polynomial time, whether a given number is prime or composite and this without relying on mathematical conjectures such as the generalized Riemann hypothesis. The proof is also notable for not relying on the field of analysis.[2] In 2006 the authors received both the Gödel Prize and Fulkerson Prize 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 numbers, while Pépin's test can be applied to Fermat numbers only.
  • The maximum running time of the algorithm can be bounded by a polynomial 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. 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.

While the algorithm is of immense theoretical importance, it is not used in practice, rendering it a galactic algorithm. 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 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 and integer coprime to , is prime if and only if the polynomial congruence relation

(1)

holds within the polynomial ring .[1] Note that 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 together with the following property of the binomial coefficient:

for all if is prime.

While the relation (1) constitutes a primality test in itself, verifying it takes exponential time: the brute force approach would require the expansion of the polynomial and a reduction of the resulting coefficients.

The congruence is an equality in the polynomial ring . Evaluating in a quotient ring of creates an upper bound for the degree of the polynomials involved. The AKS evaluates the equality in , making the computational complexity dependent on the size of . For clarity,[1] this is expressed as the congruence

(2)

which is the same as:

(3)

for some polynomials and .

Note that all primes satisfy this relation (choosing in (3) gives (1), which holds for prime). This congruence can be checked in polynomial time when is polynomial to the digits of . The AKS algorithm evaluates this congruence for a large set of values, whose size is polynomial to the digits of . The proof of validity of the AKS algorithm shows that one can find an and a set of values with the above properties such that if the congruences hold then is a power of a prime.[1]

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 (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 primes would, if true, immediately cut the worst case down to .

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.) 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. The new upper bound on time complexity was , later reduced using additional results from sieve theory to .

In 2005, Pomerance and Lenstra demonstrated a variant of AKS that runs in operations,[3] leading to another updated version of the paper.[4] Agrawal, Kayal and Saxena proposed a variant which would run in if Agrawal's conjecture were true; however, a heuristic argument by Pomerance and Lenstra suggested that it is probably false.

The algorithm

The algorithm is as follows:[1]

Input: integer n > 1.
  1. Check if n is a perfect power: if n = ab for integers a > 1 and b > 1, then output composite.
  2. Find the smallest r such that ordr(n) > (log2 n)2. If r and n are not coprime, then output composite.
  3. 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), then output composite.
  4. If nr, then output prime.
  5. For a = 1 to do
    if (X+a)nXn+a (mod Xr − 1,n), then output composite;
  6. Output prime.

Here ordr(n) is the multiplicative order of n modulo r, log2 is the binary logarithm, and is Euler's totient function of r.

Step 3 is shown in the paper as checking 1 < (a,n) < n for all ar. 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

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

consisting of elements. This ring contains only the monomials , and the coefficients are in which has elements, all of them codable within 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.[5] Typically these changes do not change the computational complexity, but can lead to many orders of magnitude less time taken; for example, 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 constructed from the (X + a) binomials that are tested in step 5. Step 4 guarantees that these binomials are distinct elements of . For the particular choice of r, the bounds produce a contradiction 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.[1]

Example 1: n = 31 is prime

   Input: integer n = 31 > 1.

   (* Step 1 *)
   If (n = ab for integers a > 1 and b > 1), 
     output composite.
     For ( b = 2; b <= log2(n); b++) {
       a = n1/b;
       If (a is integer), 
         Return[Composite]
     }
     a = n1/2...n1/4 = {5.568, 3.141, 2.360}

   (* Step 2 *)
   Find the smallest r such that Or(n) > (log2 n)2.
     maxk = ⌊(log2 n)2⌋;
     maxr = Max[3, ⌈(Log2 n)5⌉]; (* maxr really isn't needed *)
     nextR = True;
     For (r = 2; nextR && r < maxr; r++) {
       nextR = False;
       For (k = 1; (!nextR) && k ≤ maxk; k++) {
         nextR = (Mod[nk, r] == 1 || Mod[nk, r]==0)
       }
     }
     r--; (*the loop over increments by one*)
      
     r = 29

   (* Step 3 *)
   If (1 < gcd(a,n) < n for some ar), 
     output composite.
     For (a = r; a > 1; a--) {
       If ((gcd = GCD[a,n]) > 1 && gcd < n), 
         Return[Composite]
     }
      
     gcd = {GCD(29,31)=1, GCD(28,31)=1, ..., GCD(2,31)=1} ≯ 1

   (* Step 4 *)
   If (nr), 
     output prime.
     If (n ≤ r), 
       Return[Prime] (* this step may be omitted if n > 5690034 *)
      
     31 > 29
   
   (* Step 5 *)
   For a = 1 to  do
     If ((X+a)nXn + a (mod Xr − 1,n)), 
       output composite;
      
     φ[x_] := EulerPhi[x];
     PolyModulo[f_] := PolynomialMod[PolynomialRemainder[f, xr-1, x], n];
     max = Floor[Log[2, n]φ[r]];
     For (a = 1; a ≤ max; a++) {
       If (PolyModulo[(x+a)n - PolynomialRemainder[xn+a, xr-1], x] ≠ 0) {
         Return[Composite]
       {
     }
      
     (x+a)31 =
       a31 +31a30x +465a29x2 +4495a28x3 +31465a27x4 +169911a26x5 +736281a25x6 +2629575a24x7 +7888725a23x8 +20160075a22x9 +44352165a21x10 +84672315a20x11 +141120525a19x12 +206253075a18x13 +265182525a17x14 +300540195a16x15 +300540195a15x16 +265182525a14x17 +206253075a13x18 +141120525a12x19 +84672315a11x20 +44352165a10x21 +20160075a9x22 +7888725a8x23 +2629575a7x24 +736281a6x25 +169911a5x26 +31465a4x27 +4495a3x28 +465a2x29 +31ax30 +x31
      
     PolynomialRemainder [(x+a)31, x29-1] =
       465a2 +a31 +(31a+31a30)x +(1+465a29)x2 +4495a28x3 +31465a27x4 +169911a26x5 +736281a25x6 +2629575a24x7 +7888725a23x8 +20160075a22x9 +44352165a21x10 +84672315a20x11 +141120525a19x12 +206253075a18x13 +265182525a17x14 +300540195a16x15 +300540195a15x16 +265182525a14x17 +206253075a13x18 +141120525a12x19 +84672315a11x20 +44352165a10x21 +20160075a9x22 +7888725a8x23 +2629575a7x24 +736281a6x25 +169911a5x26 +31465a4x27 +4495a3x28
      
     (A) PolynomialMod [PolynomialRemainder [(x+a)31, x29-1], 31] = a31+x2
      
     (B) PolynomialRemainder [x31+a, x29-1] = a+x2
      
     (A) - (B) = a31+x2 - (a+x2) = a31-a
      
     
      
     {131-1 = 0 (mod 31), 231-2 = 0 (mod 31), 331-3 = 0 (mod 31), ..., 2631-26 = 0 (mod 31)}
   
   (* Step 6 *)
   Output prime.
     31 Must be Prime

Where PolynomialMod is a term-wise modulo reduction of the polynomial. e.g. PolynomialMod[x+2x2+3x3, 3] = x+2x2+0x3

[6]

References

  1. ^ a b c d e f Agrawal, Manindra; Kayal, Neeraj; Saxena, Nitin (2004). "PRIMES is in P" (PDF). Annals of Mathematics. 160 (2): 781–793. doi:10.4007/annals.2004.160.781. JSTOR 3597229.
  2. ^ Granville, Andrew (2005). "It is easy to determine whether a given integer is prime". Bull. Amer. Math. Soc. 42: 3–38. doi:10.1090/S0273-0979-04-01037-7.
  3. ^ H. W. Lenstra Jr. and Carl Pomerance, "Primality testing with Gaussian periods", preliminary version July 20, 2005.
  4. ^ H. W. Lenstra Jr. and Carl Pomerance, "Primality testing with Gaussian periods Archived 2012-02-25 at the Wayback Machine", version of April 12, 2011.
  5. ^ Daniel J. Bernstein, "Proving Primality After Agrawal-Kayal-Saxena", version of January 25, 2003.
  6. ^ See AKS Talk page for a discussion on why 'Example 2: n is not Prime past Step 4' is missing.

Further reading

Read other articles:

Lokasi Hortobágy sebagai salah satu kawasan mikro dalam geografi fisik Hungaria Hortobágy (pengucapan bahasa Hungaria: [ˈhortobaːɟ]) adalah taman nasional seluas 800 km2 di Hungaria bagian timur, yang kaya dengan cerita rakyat dan sejarah budaya. Taman ini, yang merupakan bagian dari Dataran Luas Alföld, ditetapkan sebagai taman nasional pada tahun 1973 (yang pertama di Hungaria) dan terpilih sebagai salah satu Situs Warisan Dunia pada tahun 1999.[1] Hortobágy adalah kawas...

Ця стаття є частиною Проєкту:Тернопільщина (рівень: 4, важливість: низька) Портал «Тернопільщина»Мета проєкту — створення якісних та інформативних статей на теми, пов'язані з Тернопільщиною. Ви можете покращити цю статтю, відредагувавши її, а на сторінці проєкту вказано, ч

Leonid UtyosovUtyosov dalam Jolly Fellows (1934)LahirLeyzer (Lazar) Vaysbeyn(1895-03-22)22 Maret 1895Odessa, Kekaisaran RusiaMeninggal9 Maret 1982(1982-03-09) (umur 86)Moskwa, SFSR Rusia, Uni SovietMakamPemakaman Novodevichy, MoskwaPekerjaanPenyanyi, pemeran, konduktorGelarArtis Rakyat USSR (1965)Karier musikGenre Estrada Folk Romansa Rusia Pop Instrumen Vokal Leonid Osipovich Utyosov atau Utesov (bahasa Rusia: Леонид Осипович Утёсов; nama sebenarnya Lazar (Leyzer...

Utomo JosodirdjoUtomo Josodirdjo adalah pendiri kantor akuntan terkemuka, SGV Utomo & Co. (sekarang Purwanto, Sungkoro & Surja)Informasi pribadiLahir(1930-01-01)1 Januari 1930Malang, Jawa Timur, Masa Hindia BelandaMeninggal28 November 2022(2022-11-28) (umur 92)Jakarta, IndonesiaKewarganegaraanIndonesiaSuami/istriUtami Rahardja ​(m. 1957)​AnakTiara JosodirdjoDewi JosodirdjoOrang tuaLiem Hwai Tjioe (ayah)Anna Bong (ibu)KerabatDaniel Budiman (menantu)Tho...

Усть-Чорна (заказник) Річка Тересва біля смт Усть-ЧорнаРічка Тересва біля смт Усть-Чорна 48°18′07″ пн. ш. 23°57′24″ сх. д. / 48.302000000027774718° пн. ш. 23.95672222002777829° сх. д. / 48.302000000027774718; 23.95672222002777829Координати: 48°18′07″ пн. ш. 23°57′24″ сх. д. / þ...

Arquieparquia de LvivArchieparchia Leopolitanus Ucrainorum Arquieparquia de Lviv dos Ucranianos Localização País Ucrânia Território Eparquias Sufragâneas Sambir-Drohobyč, Sokal'-Žovkva, Stryj Estatísticas População 1 064 811794 636 católicos[1] Área 3 767 km² Arciprestados 17 Paróquias 307 Sacerdotes 476 Informação Denominação Igreja Greco-Católica Ucraniana Rito bizantino Criação da Eparquia 1677 Elevação a Arquieparquia 22 de fevereiro de 1807 Cat...

Ростовский педагогический колледж  (РПК) Прежние названия Московский центральный опытный педагогический техникум им. Н. К. Крупской Ростовский педагогический техникум им. Н. К. Крупской Ростовское педагогическое училище Ростовский педагогический лицей Год основания...

2022 film directed by Venkat Prabhu Manmadha LeelaiTheatrical release posterDirected byVenkat PrabhuWritten byManivannan BalasubramaniamProduced byT. MurugananthamStarringAshok SelvanSamyuktha HegdeRiya SumanSmruthi VenkatChandranJayaprakashCinematographyThamizh A. AzhaganEdited byVenkat RaajenMusic byPremgi AmarenProductioncompanyRockfort EntertainmentRelease date April 1, 2022 (2022-04-01) (India) CountryIndiaLanguageTamil Manmadha Leelai (transl. Cupid Tales) is a ...

Historic house in New Jersey, United States United States historic placeRockinghamU.S. National Register of Historic PlacesNew Jersey Register of Historic Places Back of house in 2007Show map of Somerset County, New JerseyShow map of New JerseyShow map of the United StatesLocation84 Laurel AvenueFranklin Township, New JerseyCoordinates40°23′3″N 74°37′8″W / 40.38417°N 74.61889°W / 40.38417; -74.61889 (Rockinghamdisplay=inline,title)Area5.5 acres (2.2...

المرشد الأعلى للثورة الإسلامية رهبر معظم انقلاب اسلامی   علي خامنئي  منذ 4 يونيو 1989 البلد إيران  عن المنصب مقر الإقامة الرسمي طهران،  إيران المعين مجلس خبراء القيادة  تأسيس المنصب 3 ديسمبر 1979  أول حامل للمنصب روح الله الخميني آخر حامل للمنصب علي خامنئي الموقع ...

1

0 ← 1 → 2二進法 1三進法 1四進法 1五進法 1六進法 1七進法 1八進法 1十二進法 1十六進法 1二十進法 1二十四進法 1三十六進法 1ローマ数字 I漢数字 一大字 壱算木 位取り記数法 一進法 「一」の筆順 1(一、壱、壹、弌、いち、ひと、ひとつ)は、最小の正の整数である。0 を自然数に含めない流儀では、最小の自然数とも言える。整数の通常の順序において、0 の次で ...

This article's lead section may be too short to adequately summarize the key points. Please consider expanding the lead to provide an accessible overview of all important aspects of the article. (November 2023) Tate McRae discographyMcRae performing at The Fonda Theatre, Los Angeles in 2022Studio albums2EPs2Singles35 Canadian singer Tate McRae has released two studio albums, one mixtape, two extended plays and 35 singles (including three as a featured artist). McRae released her debut single ...

Artikel ini sebatang kara, artinya tidak ada artikel lain yang memiliki pranala balik ke halaman ini.Bantulah menambah pranala ke artikel ini dari artikel yang berhubungan atau coba peralatan pencari pranala.Tag ini diberikan pada Oktober 2022. Gereja Santo NikolausNiguliste MuseumNiguliste kirikLokasiTallinnNegaraEstoniaDenominasiNoneDenominasi sebelumnyaGereja LutheranSitus webMuseum websiteSejarahDidirikanAbad ke-13DedikasiSanto NikolausArsitekturStatusDekonsentrasiStatus fungsionalMuseumT...

A former station on the Chicago Transit Authority's Evanston Line Isabella 2800N1200WFormer Chicago 'L' rapid transit stationIsabella in 1968General informationLocation1215 Isabella StreetEvanston/Wilmette, Illinois, Illinois 60201Coordinates42°04′08″N 87°41′19″W / 42.0690°N 87.6885°W / 42.0690; -87.6885Owned byChicago Transit AuthorityLine(s)Evanston BranchPlatforms2 side platformsTracks2 tracksConstructionStructure typeAt-gradePlatform levels1Parking...

 История ИндииДревняя Индия Доисторическая Индия Индская цивилизация Ведийская цивилизация Религия, Варны, Махаджанапады Империя Маурьев Экономика, Распространение буддизма, Чанакья, Сатавахана Золотой век Ариабхата, Рамаяна, Махабхарата Средневековая Индия Гурдж...

1942 film by Mark Sandrich Holiday InnTheatrical release posterDirected byMark SandrichScreenplay byClaude BinyonElmer Rice (adaptation)Story byIrving BerlinProduced byMark SandrichStarring Bing Crosby Fred Astaire Marjorie Reynolds Virginia Dale Walter Abel CinematographyDavid AbelEdited byEllsworth HoaglandMusic byIrving BerlinProductioncompanyParamount PicturesDistributed byParamount PicturesRelease date August 4, 1942 (1942-08-04) Running time100 minutesCountryUnited States...

GFriend discographyGFriend in April 2019Studio albums4Compilation albums1Music videos20EPs10Singles19Reissues1 The following is the discography of the six-member South Korean girl group GFriend. The group has released four studio albums, one compilation album, ten extended plays, one repackaged album and nineteen singles. Albums Studio albums List of studio albums, with selected details and chart positions Title Details Peak chart positions Sales KOR[1] JPN[2] JPN Hot.[3&#...

Ron ClementsClements di Festival Film Animasi Internasional Annecy tahun 2016LahirRonald Francis Clements[1]25 April 1953 (umur 70)Kota Sioux, Iowa, Amerika SerikatPekerjaanAnimator, sutradara, produser, penulis naskahTempat kerjaWalt Disney Animation StudiosSuami/istriTamara Lee Glumace (1989–sekarang)[1] Ronald Francis Ron Clements (lahir tanggal 25 April 1953) merupakan seorang sutradara, produser dan penulis naskah film animasi Amerika Serikat di Walt Disney Animati...

National beauty pageant competition in Poland Miss Polonia OrganizationFormation1927TypeBeauty pageantHeadquartersWarsawLocationPolandMembership Miss WorldMiss EarthMiss Grand InternationalMiss IntercontinentalMiss CharmOfficial language PolishWebsitewww.misspolonia.com.pl Miss Polonia is a national beauty pageant in Poland to select the official ambassador of Poland at the Miss World, Miss Earth, Miss Grand International, Miss Intercontinental and Miss Charm pageants.[1][2] T...

El aprendizaje basado en problemas (ABP o, del inglés, PBL, problem-based learning) puede definirse como un proceso de indagación que resuelve preguntas, curiosidades, dudas e incertidumbres sobre fenómenos complejos de la vida.[1]​ Es un método docente basado en el estudiante como protagonista de su propio aprendizaje,[2]​ donde la indagación por el alumno es una parte importante del ABP y que guiará el proceso del aprendizaje.[3]​ Aprendizaje por problemas En esta me...