Journal of Automated Reasoning

, Volume 61, Issue 1–4, pp 33–71 | Cite as

Distant Decimals of \(\pi \): Formal Proofs of Some Algorithms Computing Them and Guarantees of Exact Computation

  • Yves BertotEmail author
  • Laurence Rideau
  • Laurent Théry


We describe how to compute very far decimals of \(\pi \) and how to provide formal guarantees that the decimals we compute are correct. In particular, we report on an experiment where 1 million decimals of \(\pi \) and the billionth hexadecimal (without the preceding ones) have been computed in a formally verified way. Three methods have been studied, the first one relying on a spigot formula to obtain at a reasonable cost only one distant digit (more precisely a hexadecimal digit, because the numeration basis is 16) and the other two relying on arithmetic–geometric means. All proofs and computations can be made inside the Coq system. We detail the new formalized material that was necessary for this achievement and the techniques employed to guarantee the accuracy of the computed digits, in spite of the necessity to work with fixed precision numerical computation.


Formal proofs in real analysis Coq proof assistant Arithmetic geometric means Bailey, Borwein, and Plouffe formula BBP PI 


  1. 1.
    Almkvist, G., Berndt, B.: Gauss, Landen, Ramanujan, the Arithmetic–Geometric Mean, Ellipses, \(\pi \), and the Ladies Diary (1988), pp. 125–150. Springer, Berlin (2016)Google Scholar
  2. 2.
    Anonymous: Première composition de mathématiques”, concours externe de recrutement de professeurs certifiés, section mathématiques (1995)Google Scholar
  3. 3.
    Armand, M., Grégoire, B., Spiwack, A., Théry, L.: Extending Coq with imperative features and its application to SAT verification. In: Interactive Theorem Proving, First International Conference, ITP 2010, volume 6172 of LNCS. Springer, pp. 83–98 (2010)Google Scholar
  4. 4.
    Bailey, D.: Borwein, Peter, Plouffe, Simon: on the rapid computation of various polylogarithmic constants. Math. Comput. 66(218), 903–913 (1997)CrossRefGoogle Scholar
  5. 5.
    Bertot, Y.: Fixed precision patterns for the formal verification of mathematical constant approximations. In: Proceedings of the 2015 Conference on Certified Programs and Proofs. ACM, pp. 147–155 (2015)Google Scholar
  6. 6.
    Bertot, Y., Allais, G.: Views of Pi: definition and computation. J. Formaliz. Reason. 7(1), 105–129 (2014)MathSciNetGoogle Scholar
  7. 7.
    Bertot, Y., Magaud, N., Zimmermann, P.: A proof of GMP square root. J. Autom. Reason. 29(3–4), 225–252 (2002)MathSciNetCrossRefzbMATHGoogle Scholar
  8. 8.
    Bertot, Y., Rideau, L., Théry, L.: Distant decimals of pi. (2017). Accessed 18 Dec 2017
  9. 9.
    Besson, F.: Fast reflexive arithmetic tactics the linear case and beyond. In: Proceedings of the 2006 International Conference on Types for Proofs and Programs, volume 4502 of LNCS. Springer, pp. 48–62 (2007)Google Scholar
  10. 10.
    Boespflug, M., Dénès, M., Grégoire, B.: Full reduction at full throttle. In Certified Programs and Proofs: First International Conference, volume 7086 of LNCS. Springer, pp. 362–377 (2011)Google Scholar
  11. 11.
    Boldo, S., Lelay, C., Melquiond, G.: Coquelicot: a user-friendly library of real analysis for Coq. Math. Comput. Sci. 9(1), 41–62 (2015)MathSciNetCrossRefzbMATHGoogle Scholar
  12. 12.
    Boldo, S., Melquiond, G.: Flocq: a unified library for proving floating-point algorithms in Coq. In: IEEE Symposium on Computer Arithmetic. IEEE Computer Society, pp. 243–252 (2011)Google Scholar
  13. 13.
    Borwein, J.M., Borwein, P.B.: Pi and the AGM: A Study in the Analytic Number Theory and Computational Complexity. Wiley, New York (1987)zbMATHGoogle Scholar
  14. 14.
    Brent, R.P.: Fast multiple-precision evaluation of elementary functions. J. ACM 23(2), 242–251 (1976)MathSciNetCrossRefzbMATHGoogle Scholar
  15. 15.
    Cartan, H.: Théorie des filtres. Comptes Rendus de l’Académie des Sciences 205, 595–598 (1937)zbMATHGoogle Scholar
  16. 16.
    Cohen, C., Dénès, M., Mörtberg, A.: Refinements for free! In: Certified Programs and Proofs: Third International Conference, volume 8307 of LNCS. Springer, pp. 147–162 (2013)Google Scholar
  17. 17.
    Cruz-Filipe, L.: Constructive Real Analysis: A Type-Theoretical Formalization and Applications. PhD Thesis, University of Nijmegen, April (2004)Google Scholar
  18. 18.
    Dénès, M., Mörtberg, A., Siles, V.: A refinement-based approach to computational algebra in Coq. In: Interactive Theorem Proving—Third International Conference, ITP 2012, volume 7406 of LNCS. Springer, pp. 83–98 (2012)Google Scholar
  19. 19.
    Coq Development Team. The Coq proof assistant. (2016). Accessed 18 Dec 2017
  20. 20.
    Filliâtre, J.-C., Paskevich, A.: Why3—where programs meet provers. In: Programming Languages and Systems: 22nd European Symposium on Programming, ESOP 2013, volume 7792 of LNCS. Springer, pp. 125–128 (2013)Google Scholar
  21. 21.
    Fousse, L., Hanrot, G., Lefèvre, V., Pélissier, P., Zimmermann, P.: MPFR: a multiple-precision binary floating-point library with correct rounding. ACM Trans. Math. Softw. 33(2), 13 (2007)MathSciNetCrossRefzbMATHGoogle Scholar
  22. 22.
    Gonthier, G., et al: Mathematical components. Accessed 18 Dec 2017
  23. 23.
    Gourevitch, B.: The world of Pi, 1999. (2017). Accessed 18 Dec 2017
  24. 24.
    Grégoire, B., Théry, L.: A purely functional library for modular arithmetic and its application to certifying large prime numbers. In: Automated Reasoning: Third International Joint Conference, IJCAR 2006, volume 4130 of LNCS. Springer, pp. 423–437 (2006)Google Scholar
  25. 25.
    Hales, T.C., et al.: A formal proof of the Kepler conjecture. arXiv:1501.02155 (2015)
  26. 26.
    Harrison, J.: Formalizing basic complex analysis. In: From Insight to Proof: Festschrift in Honour of Andrzej Trybulec, volume 10(23) of Studies in Logic, Grammar and Rhetoric. University of Białystok, pp. 151–165. (2007)
  27. 27.
    Harrison, J.: Pi series in Bailey/Borwein/Plouffe polylogarithmic constants paper, the HOL Light library. (2010). Accessed 18 Dec 2017
  28. 28.
    Harrison, J.: Theorem Proving with the Real Numbers, 1st edn. Springer, Berlin (2011)zbMATHGoogle Scholar
  29. 29.
    Hölzl, J.: Proving inequalities over reals with computation in Isabelle/HOL. In: Proceedings of the ACM SIGSAM 2009 International Workshop on Programming Languages for Mechanized Mathematics Systems (PLMMS’09), Munich, pp. 38–45 (2009)Google Scholar
  30. 30.
    Hölzl, J., Immler, F., Huffman, B.: Type classes and filters for mathematical analysis in Isabelle/HOL. In: Interactive Theorem Proving (ITP 2013), volume 7998 of LNCS. Springer, pp. 279–294 (2013)Google Scholar
  31. 31.
    King, L.V.: On the Direct Numerical Calculation of Elliptic Functions and Integrals. Cambridge University Press, Cambridge (1924)zbMATHGoogle Scholar
  32. 32.
    Krebbers, R., Spitters, B.: Type classes for efficient exact real arithmetic in Coq. Log. Methods Comput. Sci. 9(1), 1–27 (2013)MathSciNetCrossRefzbMATHGoogle Scholar
  33. 33.
    Leroy, X.: Formal verification of a realistic compiler. Commun. ACM 52(7), 107–115 (2009)CrossRefGoogle Scholar
  34. 34.
    Martin-Dorel, É., Melquiond, G.: Proving tight bounds on univariate expressions with elementary functions in Coq. J. Autom. Reason. 57(3), 187–217 (2016)MathSciNetCrossRefzbMATHGoogle Scholar
  35. 35.
    Nipkow, T., Wenzel, M., Paulson, L.C.: Isabelle/HOL: A Proof Assistant for Higher-Order Logic. Springer, Berlin (2002)CrossRefzbMATHGoogle Scholar
  36. 36.
    O’Connor, R.: Certified exact transcendental real number computation in Coq. In: Theorem Proving in Higher Order Logics: 21st International Conference, TPHOLs 2008, volume 5170 of LNCS. Springer, pp. 246–261 (2008)Google Scholar
  37. 37.
    Salamin, E.: Computation of \(\pi \) using arithmetic-geometric mean. Math. Comput. 33(135), 565–570 (1976)MathSciNetzbMATHGoogle Scholar
  38. 38.
    Schönhage, A., Strassen, V.: Schnelle Multiplikation großer Zahlen. Computing 7(3–4), 281–292 (1971)MathSciNetCrossRefzbMATHGoogle Scholar
  39. 39.
    Solovyev, A., Hales, T.C.: Formal verification of nonlinear inequalities with Taylor interval approximations. In: NASA Formal Methods: 5th International Symposium, NFM 2013, volume 7871 of LNCS. Springer, pp. 383–397 (2013)Google Scholar

Copyright information

© Springer Science+Business Media B.V., part of Springer Nature 2017

Authors and Affiliations

  1. 1.Inria Sophia AntipolisUniversité Côte d’AzurSophia AntipolisFrance

Personalised recommendations