Computer Certified Efficient Exact Reals in Coq

  • Robbert Krebbers
  • Bas Spitters
Part of the Lecture Notes in Computer Science book series (LNCS, volume 6824)


Floating point operations are fast, but require continuous effort on the part of the user in order to ensure that the results are correct. This burden can be shifted away from the user by providing a library of exact analysis in which the computer handles the error estimates. We provide an implementation of the exact real numbers in the Coq proof assistant. This improves on the earlier Coq-implementation by O’Connor in two ways: we use dyadic rationals built from the machine integers and we optimize computation of power series by using approximate division. Moreover, we use type classes for clean mathematical interfaces. This appears to be the first time that type classes are used in heavy computation. We obtain over a 100 times speed up of the basic operations and indications for improving the Coq system.


Virtual Machine Type Class Canonical Structure Proof Search Dyadic Rational 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Bishop, E.A.: Foundations of constructive analysis. McGraw-Hill, New York (1967)zbMATHGoogle Scholar
  2. 2.
    O’Connor, R.: A Monadic, Functional Implementation of Real Numbers. MSCS 17(1), 129–159 (2007)MathSciNetzbMATHGoogle Scholar
  3. 3.
    O’Connor, R.: Certified Exact Transcendental Real Number Computation in Coq. In: Mohamed, O.A., Muñoz, C., Tahar, S. (eds.) TPHOLs 2008. LNCS, vol. 5170, pp. 246–261. Springer, Heidelberg (2008)CrossRefGoogle Scholar
  4. 4.
    O’Connor, R., Spitters, B.: A computer verified, monadic, functional implementation of the integral. TCS 411(37), 3386–3402 (2010)MathSciNetCrossRefzbMATHGoogle Scholar
  5. 5.
    Coquand, T., Huet, G.: The Calculus of Constructions. Information and Computation 76(2-3), 95–120 (1988)MathSciNetCrossRefzbMATHGoogle Scholar
  6. 6.
    Coquand, T., Paulin, C.: Inductively defined types. In: Martin-Löf, P., Mints, G. (eds.) COLOG 1988. LNCS, vol. 417, pp. 50–66. Springer, Heidelberg (1990)CrossRefGoogle Scholar
  7. 7.
    Coq Development Team: The Coq Proof Assistant Reference Manual. INRIA-Rocquencourt (2008)Google Scholar
  8. 8.
    Bertot, Y., Castéran, P.: Interactive Theorem Proving and Program Development. Coq’Art: The Calculus of Inductive Constructions. Texts in TCS. Springer, Heidelberg (2004)CrossRefzbMATHGoogle Scholar
  9. 9.
    Martin-Löf, P.: An intuitionistic theory of types. In: Twenty-five years of constructive type theory. Oxford Logic Guides, vol. 36, pp. 127–172. OUP (1998)Google Scholar
  10. 10.
    Martin-Löf, P.: Constructive Mathematics and Computer Science. In: Logic, Methodology and the Philosophy of Science VI. Studies in Logic and the Foundations of Mathematics, vol. 104, pp. 153–175 (1982)Google Scholar
  11. 11.
    Letouzey, P.: Extraction in Coq: An Overview. In: Beckmann, A., Dimitracopoulos, C., Löwe, B. (eds.) CiE 2008. LNCS, vol. 5028, pp. 359–369. Springer, Heidelberg (2008)CrossRefGoogle Scholar
  12. 12.
    Cruz-Filipe, L., Spitters, B.: Program Extraction from Large Proof Developments. In: Basin, D., Wolff, B. (eds.) TPHOLs 2003. LNCS, vol. 2758, pp. 205–220. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  13. 13.
    Cruz-Filipe, L., Letouzey, P.: A Large-Scale Experiment in Executing Extracted Programs. Electronic Notes in Theoretical Computer Science 151(1), 75–91 (2006)CrossRefzbMATHGoogle Scholar
  14. 14.
    Hofmann, M.: Extensional constructs in intensional type theory. CPHC/BCS Distinguished Dissertations. Springer, Heidelberg (1997)CrossRefGoogle Scholar
  15. 15.
    Palmgren, E.: Constructivist and Structuralist Foundations: Bishops and Lawveres Theories of Sets. Technical Report 4, Mittag-Leffler (2009)Google Scholar
  16. 16.
    Sozeau, M.: A New Look at Generalized Rewriting in Type Theory. Journal of Formalized Reasoning 2(1), 41–62 (2009)MathSciNetzbMATHGoogle Scholar
  17. 17.
    Sozeau, M., Oury, N.: First-class type classes. In: Mohamed, O.A., Muñoz, C., Tahar, S. (eds.) TPHOLs 2008. LNCS, vol. 5170, pp. 278–293. Springer, Heidelberg (2008)CrossRefGoogle Scholar
  18. 18.
    Spitters, B., van der Weegen, E.: Type classes for mathematics in type theory. MSCS, special issue on Interactive theorem proving and the formalization of mathematics (2011)Google Scholar
  19. 19.
    Grégoire, B., Leroy, X.: A compiled implementation of strong reduction. In: ICFP, pp. 235–246 (2002)Google Scholar
  20. 20.
    Armand, M., Grégoire, B., Spiwack, A., Théry, L.: Extending Coq with imperative features and its application to SAT verification. In: Kaufmann, M., Paulson, L.C. (eds.) ITP 2010. LNCS, vol. 6172, pp. 83–98. Springer, Heidelberg (2010)CrossRefGoogle Scholar
  21. 21.
    Spiwack, A.: Verified Computing in Homological Algebra, A Journey Exploring the Power and Limits of Dependent Type Theory. PhD thesis, INRIA (2011)Google Scholar
  22. 22.
    Richman, F.: Real numbers and other completions. Mathematical Logic Quarterly 54(1), 98–108 (2008)MathSciNetCrossRefzbMATHGoogle Scholar
  23. 23.
    Moggi, E.: Computational lambda-calculus and monads. In: LICS, pp. 14–23 (1989)Google Scholar
  24. 24.
    Wadler, P.: Monads for functional programming. In: Proceedings of the Marktoberdorf Summer School on Program Design Calculi (August 1992)Google Scholar
  25. 25.
    Garillot, F., Gonthier, G., Mahboubi, A., Rideau, L.: Packaging mathematical structures. In: Berghofer, S., Nipkow, T., Urban, C., Wenzel, M. (eds.) TPHOLs 2009. LNCS, vol. 5674, pp. 327–342. Springer, Heidelberg (2009)CrossRefGoogle Scholar
  26. 26.
    Gonthier, G., Mahboubi, A., Tassi, E.: A Small Scale Reflection Extension for the Coq system. Technical Report RR-6455, INRIA (2008)Google Scholar
  27. 27.
    Bauer, A., Kavkler, I.: A constructive theory of continuous domains suitable for implementation. Annals of Pure and Applied Logic 159(3), 251–267 (2009)MathSciNetCrossRefzbMATHGoogle Scholar
  28. 28.
    O’Connor, R.: Incompleteness and Completeness: Formalizing Logic and Analysis in Type Theory. PhD thesis, Radboud University Nijmegen (2009)Google Scholar
  29. 29.
    Wolfram, S.: A new kind of science. Wolfram Media (2002)Google Scholar
  30. 30.
    Gonthier, G., Ziliani, B., Nanevski, A., Dreyer, D.: Making ad hoc proof automation less ad hoc (2011)Google Scholar
  31. 31.
    Asperti, A., Ricciotti, W., Coen, C., Tassi, E.: Hints in Unification. In: Berghofer, S., Nipkow, T., Urban, C., Wenzel, M. (eds.) TPHOLs 2009. LNCS, vol. 5674, pp. 84–98. Springer, Heidelberg (2009)CrossRefGoogle Scholar
  32. 32.
    Boldo, S., Melquiond, G.: Flocq: A unified library for proving floating-point algorithms in Coq. In: Proc 20th IEEE Symposium on Computer Arithmetic (2011)Google Scholar
  33. 33.
    Julien, N., Pasca, I.: Formal Verification of Exact Computations Using Newton’s Method. In: Berghofer, S., Nipkow, T., Urban, C., Wenzel, M. (eds.) TPHOLs 2009. LNCS, vol. 5674, pp. 408–423. Springer, Heidelberg (2009)CrossRefGoogle Scholar
  34. 34.
    Bertot, Y.: Affine functions and series with co-inductive real numbers. MSCS 17(1), 37–63 (2007)MathSciNetzbMATHGoogle Scholar
  35. 35.
    Julien, N.: Certified Exact Real Arithmetic Using Co-induction in Arbitrary Integer Base. In: Garrigue, J., Hermenegildo, M.V. (eds.) FLOPS 2008. LNCS, vol. 4989, pp. 48–63. Springer, Heidelberg (2008)CrossRefGoogle Scholar
  36. 36.
    Berger, U.: From coinductive proofs to exact real arithmetic. In: Grädel, E., Kahle, R. (eds.) CSL 2009. LNCS, vol. 5771, pp. 132–146. Springer, Heidelberg (2009)CrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2011

Authors and Affiliations

  • Robbert Krebbers
    • 1
  • Bas Spitters
    • 1
  1. 1.Radboud University NijmegenThe Netherlands

Personalised recommendations