Refinements for Free!

  • Cyril Cohen
  • Maxime Dénès
  • Anders Mörtberg
Part of the Lecture Notes in Computer Science book series (LNCS, volume 8307)

Abstract

Formal verification of algorithms often requires a choice between definitions that are easy to reason about and definitions that are computationally efficient. One way to reconcile both consists in adopting a high-level view when proving correctness and then refining stepwise down to an efficient low-level implementation. Some refinement steps are interesting, in the sense that they improve the algorithms involved, while others only express a switch from data representations geared towards proofs to more efficient ones geared towards computations. We relieve the user of these tedious refinements by introducing a framework where correctness is established in a proof-oriented context and automatically transported to computation-oriented data structures. Our design is general enough to encompass a variety of mathematical objects, such as rational numbers, polynomials and matrices over refinable structures. Moreover, the rich formalism of the Coq proof assistant enables us to develop this within Coq, without having to maintain an external tool.

Keywords

Coq Data refinements Formal proofs Efficient algorithms and data structures Parametricity 

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Ahrens, B., Kapulkin, C., Shulman, M.: Univalent categories and the Rezk completion (2013) (Preprint), http://arxiv.org/abs/1303.0584
  2. 2.
    Barthe, G., Capretta, V., Pons, O.: Setoids in type theory. Journal of Functional Programming 13(2), 261–293 (2003)MathSciNetCrossRefMATHGoogle Scholar
  3. 3.
    Bernardy, J.-P., Jansson, P., Paterson, R.: Proofs for free. Journal of Functional Programming 22(2), 107–152 (2012)MathSciNetCrossRefMATHGoogle Scholar
  4. 4.
    Chrząszcz, J.: Implementing Modules in the Coq System. In: Basin, D., Wolff, B. (eds.) TPHOLs 2003. LNCS, vol. 2758, pp. 270–286. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  5. 5.
    Cohen, C.: Pragmatic Quotient Types in Coq. In: Blazy, S., Paulin-Mohring, C., Pichardie, D. (eds.) ITP 2013. LNCS, vol. 7998, pp. 213–228. Springer, Heidelberg (2013)CrossRefGoogle Scholar
  6. 6.
    Coq development team. The Coq Proof Assistant Reference Manual, version 8.4. Technical report, Inria (2012)Google Scholar
  7. 7.
    Danielsson, N.A., Coquand, T.: Isomorphism is Equality (2013) (Preprint), http://www.cse.chalmers.se/~nad/publications/coquand-danielsson-isomorphism-is-equality.html
  8. 8.
    Dénès, M., Mörtberg, A., Siles, V.: A Refinement-Based Approach to Computational Algebra in Coq. In: Beringer, L., Felty, A. (eds.) ITP 2012. LNCS, vol. 7406, pp. 83–98. Springer, Heidelberg (2012)CrossRefGoogle Scholar
  9. 9.
    Gonthier, G., Mahboubi, A.: A Small Scale Reflection Extension for the Coq system. Technical report, Microsoft Research INRIA (2009)Google Scholar
  10. 10.
    Grégoire, B., Mahboubi, A.: Proving Equalities in a Commutative Ring Done Right in Coq. In: Hurd, J., Melham, T. (eds.) TPHOLs 2005. LNCS, vol. 3603, pp. 98–113. Springer, Heidelberg (2005)CrossRefGoogle Scholar
  11. 11.
    Haftmann, F., Krauss, A., Kunčar, O., Nipkow, T.: Data Refinement in Isabelle/HOL. In: Blazy, S., Paulin-Mohring, C., Pichardie, D. (eds.) ITP 2013. LNCS, vol. 7998, pp. 100–115. Springer, Heidelberg (2013)CrossRefGoogle Scholar
  12. 12.
    Karatsuba, A., Ofman, Y.: Multiplication of many-digital numbers by automatic computers. USSR Academy of Sciences 145, 293–294 (1962)Google Scholar
  13. 13.
    Keller, C., Lasson, M.: Parametricity in an Impredicative Sort. In: CSL, vol. 16, pp. 381–395. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik (2012)Google Scholar
  14. 14.
    Lammich, P.: Automatic Data Refinement. In: Blazy, S., Paulin-Mohring, C., Pichardie, D. (eds.) ITP 2013. LNCS, vol. 7998, pp. 84–99. Springer, Heidelberg (2013)CrossRefGoogle Scholar
  15. 15.
    Luo, Z.: Computation and reasoning: a type theory for computer science. Oxford University Press, Inc., New York (1994)MATHGoogle Scholar
  16. 16.
    Magaud, N.: Changing Data Representation within the Coq System. In: Basin, D., Wolff, B. (eds.) TPHOLs 2003. LNCS, vol. 2758, pp. 87–102. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  17. 17.
    McBride, C., McKinna, J.: The view from the left. Journal of Functional Programming 14(1), 69–111 (2004)MathSciNetCrossRefMATHGoogle Scholar
  18. 18.
    T. U. F. Program: Homotopy Type Theory: Univalent Foundations of Mathematics. Institute for Advanced Study (2013), http://homotopytypetheory.org/book/
  19. 19.
    Reynolds, J.C.: Types, abstraction and parametric polymorphism. In: IFIP Congress, pp. 513–523 (1983)Google Scholar
  20. 20.
    Rijke, E., Spitters, B.: Sets in homotopy type theory (2013) (Preprint), http://arxiv.org/abs/1305.3835
  21. 21.
    Sasaki, T., Murao, H.: Efficient Gaussian Elimination Method for Symbolic Determinants and Linear Systems. ACM Trans. Math. Softw. 8(3), 277–289 (1982)MathSciNetCrossRefMATHGoogle Scholar
  22. 22.
    Sozeau, M.: A new look at generalized rewriting in type theory. Journal of Formalized Reasoning 2(1), 41–62 (2009)MathSciNetMATHGoogle Scholar
  23. 23.
    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
  24. 24.
    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’ 21, 1–31 (2011)Google Scholar
  25. 25.
    Strassen, V.: Gaussian elimination is not optimal. Numerische Mathematik 13(4), 354–356 (1969)MathSciNetCrossRefMATHGoogle Scholar
  26. 26.
    Wadler, P.: Views: A way for pattern matching to cohabit with data abstraction. In: POPL, pp. 307–313. ACM Press (1987)Google Scholar
  27. 27.
    Wadler, P.: Theorems for free? In: Functional Programming Languages and Computer Architecture, pp. 347–359. ACM Press (1989)Google Scholar

Copyright information

© Springer International Publishing Switzerland 2013

Authors and Affiliations

  • Cyril Cohen
    • 1
  • Maxime Dénès
    • 2
  • Anders Mörtberg
    • 1
  1. 1.Department of Computer Science and EngineeringChalmers University of Technology and University of GothenburgSweden
  2. 2.INRIA Sophia Antipolis - MéditerranéeFrance

Personalised recommendations