Defining and Reasoning About Recursive Functions: A Practical Tool for the Coq Proof Assistant

  • Gilles Barthe
  • Julien Forest
  • David Pichardie
  • Vlad Rusu
Part of the Lecture Notes in Computer Science book series (LNCS, volume 3945)


We present a practical tool for defining and proving properties of recursive functions in the Coq proof assistant. The tool generates from pseudo-code the graph of the intended function as an inductive relation. Then it proves that the relation actually represents a function, which is by construction the function that we are trying to define. Then, we generate induction and inversion principles, and a fixpoint equation for proving other properties of the function. Our tool builds upon state-of-the-art techniques for defining recursive functions, and can also be used to generate executable functions from inductive descriptions of their graph. We illustrate the benefits of our tool on two case studies.


Type Theory Recursive Function Recursive Call Proof Obligation Proof Assistant 
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.
    Balaa, A., Bertot, Y.: Fix-point equations for well-founded recursion in type theory. In: Aagaard, M.D., Harrison, J. (eds.) TPHOLs 2000. LNCS, vol. 1869, pp. 1–16. Springer, Heidelberg (2000)CrossRefGoogle Scholar
  2. 2.
    Barthe, G., Courtieu, P.: Efficient Reasoning about Executable Specifications in Coq. In: Carreño, V.A., Muñoz, C.A., Tahar, S. (eds.) TPHOLs 2002. LNCS, vol. 2410, pp. 31–46. Springer, Heidelberg (2002)CrossRefGoogle Scholar
  3. 3.
    Barthe, G., Dufay, G., Jakubiec, L., Serpette, B., de Sousa, S.M.: A Formal Executable Semantics of the JavaCard Platform. In: Sands, D. (ed.) ESOP 2001. LNCS, vol. 2028, pp. 302–319. Springer, Heidelberg (2001)CrossRefGoogle Scholar
  4. 4.
    Barthe, G., Frade, M.J., Giménez, E., Pinto, L., Uustalu, T.: Type-based termination of recursive definitions. Mathematical Structures in Computer Science 14, 97–141 (2004)MathSciNetCrossRefzbMATHGoogle Scholar
  5. 5.
    Berghofer, S., Nipkow, T.: Executing higher order logic. In: Callaghan, P., Luo, Z., McKinna, J., Pollack, R. (eds.) TYPES 2000. LNCS, vol. 2277, pp. 24–40. Springer, Heidelberg (2002)CrossRefGoogle Scholar
  6. 6.
    Bertot, Y., Capretta, V., Das Barman, K.: Type-theoretic functional semantics. In: Carreño, V.A., Muñoz, C.A., Tahar, S. (eds.) TPHOLs 2002. LNCS, vol. 2410, pp. 83–98. Springer, Heidelberg (2002)CrossRefGoogle Scholar
  7. 7.
    Bertot, Y., Castéran, P.: Interactive Theorem Proving and Program Development— Coq’Art: The Calculus of Inductive Constructions. Texts in Theoretical Computer Science. Springer, Heidelberg (2004)CrossRefzbMATHGoogle Scholar
  8. 8.
    Blanqui, F.: Definitions by rewriting in the calculus of constructions. Mathematical Structures in Computer Science 15(1), 37–92 (2005)MathSciNetCrossRefzbMATHGoogle Scholar
  9. 9.
    Bove, A., Capretta, V.: Modelling general recursion in type theory. Mathematical Structures in Computer Science 15, 671–708 (2005)MathSciNetCrossRefzbMATHGoogle Scholar
  10. 10.
    Cachera, D., Jensen, T., Pichardie, D., Rusu, V.: Extracting a data flow analyzer in constructive logic. Theoretical Computer Science 342 (2005) (to appear)Google Scholar
  11. 11.
    Cachera, D., Pichardie, D.: Embedding of Systems of Affine Recurrence Equations in Coq. In: Basin, D., Wolff, B. (eds.) TPHOLs 2003. LNCS, vol. 2758, pp. 155–170. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  12. 12.
    Capretta, V.: General recursion via coinductive types. Logical Methods in Computer Science 1(2), 1–18 (2005)MathSciNetCrossRefzbMATHGoogle Scholar
  13. 13.
    Coq Development Team. The Coq Proof Assistant User’s Guide. Version 8.0 (January 2004)Google Scholar
  14. 14.
    Dybjer, P.: A general formulation of simultaneous inductive-recursive definitions in type theory. Journal of Symbolic Logic 65(2), 525–549 (2000)MathSciNetCrossRefzbMATHGoogle Scholar
  15. 15.
    Gordon, M.J.C., Melham, T.F. (eds.): Introduction to HOL: A theorem proving environment for higher-order logic. Cambridge University Press, Cambridge (1993)zbMATHGoogle Scholar
  16. 16.
    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
  17. 17.
    Katsushige, M., Kiyoshi, N., Hitoshi, K.: Pipelined LMS Adaptative Filter Using a New Look-Ahead Transformation. IEEE Transactions on Circuits and Systems 46, 51–55 (1999)CrossRefGoogle Scholar
  18. 18.
    Leroy, X.: Formal certification of a compiler back-end, or: programming a compiler with a proof assistant. In: Proceedings of POPL 2006. ACM Press, New York (2006)Google Scholar
  19. 19.
    McBride, C., McKinna, J.: The view from the left. Journal of Functional Programming 14, 69–111 (2004)MathSciNetCrossRefzbMATHGoogle Scholar
  20. 20.
    Nipkow, T., Paulson, L.C., Wenzel, M.T.: Isabelle/HOL: A Proof Assistant for Higher-Order Logic. LNCS, vol. 2283. Springer, Heidelberg (2002)zbMATHGoogle Scholar
  21. 21.
    Nordström, B.: Terminating general recursion. BIT 28(3), 605–619 (1988)MathSciNetCrossRefzbMATHGoogle Scholar
  22. 22.
    Color Project,
  23. 23.
    Shankar, N., Owre, S., Rushby, J.M.: The PVS Proof Checker: A Reference Manual. Computer Science Laboratory, SRI International (February 1993); Supplemented with the PVS2 Quick Reference Manual (1997)Google Scholar
  24. 24.
    Slind, K.: Reasoning about Terminating Functional Programs. PhD thesis, TU Münich (1999)Google Scholar
  25. 25.
    Xi, H.: Dependent types for program termination verification. Higher-Order and Symbolic Computation 15(1), 91–131 (2002)CrossRefzbMATHGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2006

Authors and Affiliations

  • Gilles Barthe
    • 1
  • Julien Forest
    • 1
  • David Pichardie
    • 1
  • Vlad Rusu
    • 2
  1. 1.EVEREST TeamINRIA Sophia-AntipolisFrance
  2. 2.VERTECS TeamIRISA/INRIA RennesFrance

Personalised recommendations