Skip to main content

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

Abstract

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.

This is a preview of subscription content, access via your institution.

Notes

  1. 1.

    The name can be decomposed in is R for Riemann, Int for Integral, and gen for generalized.

  2. 2.

    It turns out that the theorem derivable_pt_lim_CVU was already introduced by a previous study on the implementation of \(\pi \) in the Coq standard library of real numbers [6].

  3. 3.

    In retrospect, it might have been useful to add hypotheses that returned values by all functions were positive, as long as the inputs were.

References

  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)

  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)

  4. 4.

    Bailey, D.: Borwein, Peter, Plouffe, Simon: on the rapid computation of various polylogarithmic constants. Math. Comput. 66(218), 903–913 (1997)

    Article  Google 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)

  6. 6.

    Bertot, Y., Allais, G.: Views of Pi: definition and computation. J. Formaliz. Reason. 7(1), 105–129 (2014)

    MathSciNet  Google Scholar 

  7. 7.

    Bertot, Y., Magaud, N., Zimmermann, P.: A proof of GMP square root. J. Autom. Reason. 29(3–4), 225–252 (2002)

    MathSciNet  Article  MATH  Google Scholar 

  8. 8.

    Bertot, Y., Rideau, L., Théry, L.: Distant decimals of pi. https://www-sop.inria.fr/marelle/distant-decimals-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)

  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)

  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)

    MathSciNet  Article  MATH  Google 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)

  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)

    MATH  Google Scholar 

  14. 14.

    Brent, R.P.: Fast multiple-precision evaluation of elementary functions. J. ACM 23(2), 242–251 (1976)

    MathSciNet  Article  MATH  Google Scholar 

  15. 15.

    Cartan, H.: Théorie des filtres. Comptes Rendus de l’Académie des Sciences 205, 595–598 (1937)

    MATH  Google 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)

  17. 17.

    Cruz-Filipe, L.: Constructive Real Analysis: A Type-Theoretical Formalization and Applications. PhD Thesis, University of Nijmegen, April (2004)

  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)

  19. 19.

    Coq Development Team. The Coq proof assistant. http://coq.inria.fr (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)

  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)

    MathSciNet  Article  MATH  Google Scholar 

  22. 22.

    Gonthier, G., et al: Mathematical components. http://math-comp.github.io/math-comp/. Accessed 18 Dec 2017

  23. 23.

    Gourevitch, B.: The world of Pi, 1999. http://www.pi314.net (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)

  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. http://mizar.org/trybulec65/ (2007)

  27. 27.

    Harrison, J.: Pi series in Bailey/Borwein/Plouffe polylogarithmic constants paper, the HOL Light library. https://github.com/jrh13/hol-light/blob/master/Examples/polylog.ml (2010). Accessed 18 Dec 2017

  28. 28.

    Harrison, J.: Theorem Proving with the Real Numbers, 1st edn. Springer, Berlin (2011)

    MATH  Google 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)

  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)

  31. 31.

    King, L.V.: On the Direct Numerical Calculation of Elliptic Functions and Integrals. Cambridge University Press, Cambridge (1924)

    MATH  Google 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)

    MathSciNet  Article  MATH  Google Scholar 

  33. 33.

    Leroy, X.: Formal verification of a realistic compiler. Commun. ACM 52(7), 107–115 (2009)

    Article  Google 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)

    MathSciNet  Article  MATH  Google Scholar 

  35. 35.

    Nipkow, T., Wenzel, M., Paulson, L.C.: Isabelle/HOL: A Proof Assistant for Higher-Order Logic. Springer, Berlin (2002)

    Book  MATH  Google 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)

  37. 37.

    Salamin, E.: Computation of \(\pi \) using arithmetic-geometric mean. Math. Comput. 33(135), 565–570 (1976)

    MathSciNet  MATH  Google Scholar 

  38. 38.

    Schönhage, A., Strassen, V.: Schnelle Multiplikation großer Zahlen. Computing 7(3–4), 281–292 (1971)

    MathSciNet  Article  MATH  Google 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)

Download references

Author information

Affiliations

Authors

Corresponding author

Correspondence to Yves Bertot.

Additional information

This work was partially funded by the ANR project FastRelax (ANR-14-CE25-0018-01) of the French National Agency for Research.

Rights and permissions

Reprints and Permissions

About this article

Verify currency and authenticity via CrossMark

Cite this article

Bertot, Y., Rideau, L. & Théry, L. Distant Decimals of \(\pi \): Formal Proofs of Some Algorithms Computing Them and Guarantees of Exact Computation. J Autom Reasoning 61, 33–71 (2018). https://doi.org/10.1007/s10817-017-9444-2

Download citation

Keywords

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