Abstract
The AKS algorithm (by Agrawal, Kayal and Saxena) is a significant theoretical result, establishing “PRIMES in P” by a brilliant application of ideas from finite fields. This paper describes an implementation of the AKS algorithm in our theorem prover HOL4, together with a proof of its correctness and its computational complexity. The complexity analysis is based on a conservative computation model using a writer monad. The method is elementary, but enough to show that our implementation of the AKS algorithm takes a number of execution steps bounded by a polynomial function of the input size. This establishes formally that the AKS algorithm indeed shows “PRIMES is in P”.
Similar content being viewed by others
Explore related subjects
Discover the latest articles, news and stories from top researchers in related subjects.References
Aaronson, S.: The prime facts: From Euclid to AKS (2003). http://www.scottaaronson.com/writings/prime.pdf. Accessed 13 June 2020
Agrawal, M.: A short history of “PRIMES is in P”. In: 33rd International Colloquium on Automata, Languages and Programming, ICALP 2006, Venice, Italy (2006)
Agrawal, M.: Primality tests based on Fermat’s Little theorem. In: Chaudhuri, S., Das, S.R., Paul, H.S., Tirthapura, S. (eds.) Distributed Computing and Networking. Number 4308 in Theoretical Computer Science and General Issues, pp. 288–293. Springer, Berlin (2006)
Agrawal, M., Kayal, N., Saxena, N.: PRIMES is in P (2002). Original paper by the AKS team. http://www.cse.iitk.ac.in/users/manindra/algebra/primality_original.pdf. Accessed 13 June 2020
Agrawal, M., Kayal, N., Saxena, N.: PRIMES is in P. Ann. Math. 160(2), 781–793 (2004)
Avanzini, M., Dal Lago, U., Moser, G.: Analysing the complexity of functional programs: higher-order meets first-order. In: Proceedings of the 20th ACM SIGPLAN International Conference on Functional Programming, ICFP 2015, pp. 152–164, New York, NY, USA. Association for Computing Machinery (2015)
Avigad, J., Donnelly, K., Formalizing, O.: Notation in Isabelle, HOL. In: Basin, D., Rusinowitch, M. (eds.) Automated Reasoning. Lecture Notes in Computer Science, vol. 3097, pp. 357–371. Springer, Berlin. IJCAR (2004)
Bagnara, R., Pescetti, A., Zaccagnini, A., Zaffanella, E.: PURRS: towards computer algebra support for fully automatic worst-case complexity analysis. CoRR (2005). arXiv:cs/0512056
Benzinger, R.: Automated higher-order complexity analysis. Theor. Comput. Sci. 318, 79–103 (2004)
Bernstein, D.J.: An Exposition of the Agrawal–Kayal–Saxena Primality Proving Theorem (2002). https://wstein.org/edu/Fall2002/124/refs/aks.pdf. Accessed 13 June 2020
Bornemann, F.: PRIMES Is in P: a breakthrough for everyman. Not. AMS 50(5), 545–552 (2003)
Brent, R.P.: Primality testing. Technical report, Mathematical Sciences Institute, ANU (2010). https://maths-people.anu.edu.au/~brent/pd/comp4600_primality.pdf. Accessed 13 June 2020
Campos, C., Modave, F., Roach, S.: Towards the verification of the AKS primality test in ACL2. In: 5th International Conference on Intelligent Technologies (2004)
Chan, H.L.: Primality testing is polynomial-time: a mechanised verification of the AKS algorithm. Ph.D., Australian National University, Canberra, Australia (2019). https://openresearch-repository.anu.edu.au/handle/1885/177195. Accessed 13 June 2020
Chan, H.L., Norrish, M.: A string of pearls: proofs of Fermat’s Little theorem. J. Formaliz. Reason. 6(1), 63–87 (2013)
Chan, H.L., Norrish, M.: Mechanisation of AKS algorithm: part 1—the main theorem. In: Urban, C., Zhang, X. (eds.) Interactive Theorem Proving, ITP 2015, Number 9236 in LNCS, pp. 117–136. Springer, Berlin (2015)
Chan, H.L., Norrish, M.: Classification of finite fields with applications. J. Autom. Reason. 63(3), 667–693 (2019)
Chan, H.L., Norrish, M.: Proof pearl: bounding least common multiples with triangles. J. Autom. Reason. 62(2), 171–192 (2019)
Crandall, R., Pomerance, C.: Prime Numbers: A Computational Perspective. Springer, Berlin (2005)
Daleson, G.: Deterministic primality testing in polynomial time. Master’s thesis, Portland State University (2006)
de Moura, F.L.C., Tadeu, R.: The Correctness of the AKS Primality Test in Coq (2008). http://www.cic.unb.br/~flavio/AKS.pdf. Accessed 13 June 2020
Dietzfelbinger, M.: Primality Testing in Polynomial Time: From Randomized Algorithms to ‘PRIMES is in P’. Lecture Notes in Computer Science. Springer (2004)
EATCS: Gödel Prize by European Association for Theoretical Computer Science. In: 33rd International Colloquium on Automata, Languages and Programming, ICALP (2006)
Eberl, M.: Proving divide and conquer complexities in Isabelle/HOL. J. Autom. Reason. 58(4), 483–508 (2017)
Haslbeck, M.P.L., Nipkow, T.: Hoare logics for time bounds: a study in meta theory. In: Beyer, D., Huisman, M. (eds.) Tools and Algorithms for the Construction and Analysis of Systems, pp. 155–171. Springer International Publishing, Cham (2018)
Hurd, J.: Verification of the Miller–Rabin Probabilistic Primality Test. Elsevier Science Inc., Amsterdam (2003). https://doi.org/10.1016/S1567-8326(02)00065-6
Jouannaud, J.-P., Weiwen, X.: Automatic complexity analysis for programs extracted from Coq proof. Electron. Not. Theor. Comput. Sci. 153(1), 35–53 (2006)
Knuth, D.E.: The Art of Computer Programming: Seminumerical Algorithms, vol. 2, 3rd edn. Addison-Wesley Longman Publishing Co. Inc, Boston (1998)
Le Métayer, D.: ACE: an automatic complexity evaluator. ACM Trans. Program. Lang. Syst. 10(2), 248–266 (1988)
Lenstra, H.W.: Primality testing with Gaussian periods. In: Agrawal, M., Seth, A. (eds.) FST TCS 2002: Foundations of Software Technology and Theoretical Computer Science. Lecture Notes in Computer Science, vol. 2556, pages 1–1. Springer, Berlin (2002)
Nair, M.: On Chebyshev-type inequalities for primes. Am. Math. Mon. 89(2), 126–129 (1982)
Rempe-Gillen, L., Waldecker, R.: Primality testing for beginners, Student Mathematical Library, vol. 70. American Mathematical Society (2014)
Robinson, S.: New method said to solve key problem in math (2002). https://www.nytimes.com/2002/08/08/us/new-method-said-to-solve-key-problem-in-math.html. Accessed 13 June 2020
Rosendahl, M.: Automatic complexity analysis. In: Proceedings of the 4th International Conference on Functional Programming Languages and Computer Architecture, FPCA’89, pp. 144–156, New York, NY, USA. Association for Computing Machinery (1989)
Schoof, R.: Four primality testing algorithms. Algorithmic Number Theory, MSRI Publications, vol. 44, pp. 101–126 (2008). http://www.mat.uniroma2.it/~schoof/05rene.pdf. Accessed 13 June 2020
Shoup, V.: A Computational Introduction to Number Theory and Algebra, 1st edn. Cambridge University Press, Cambridge (2008)
Tao, T.: The AKS primality test. In his blog (2009). http://terrytao.wordpress.com/2009/08/11/the-aks-primality-test/. Accessed 13 June 2020
Théry, L.: Proving pearl: Knuth’s algorithm for prime numbers. In: Basin, D., Wolff, B. (eds.) Theorem Proving in Higher Order Logics, pp. 304–318. Springer, Berlin (2003)
Laurent Théry: The Correctness of the AKS algorithm, a direct transcription. In: Coq (2019). https://github.com/thery/mathcomp-extra/blob/master/aks.v
von zur Gathen, J., Gerhard, J.: Modern Computer Algebra, 3rd edn. Cambridge University Press, Cambridge (2013)
Wiedijk, F., Harrison’s, J.: Formalization of the Agrawal–Kayal–Saxena primality test. Intercity Number Theory Seminar, Nijmegen (2003). http://www.cs.ru.nl/~freek/talks/intercity.dvi. Accessed 13 June 2020
Author information
Authors and Affiliations
Corresponding author
Additional information
Publisher's Note
Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Rights and permissions
About this article
Cite this article
Chan, H.L., Norrish, M. Mechanisation of the AKS Algorithm. J Autom Reasoning 65, 205–256 (2021). https://doi.org/10.1007/s10817-020-09563-y
Received:
Accepted:
Published:
Issue Date:
DOI: https://doi.org/10.1007/s10817-020-09563-y