Functors for Proofs and Programs

  • Jean-Christophe Filliâtre
  • Pierre Letouzey
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 2986)


This paper presents the formal verification with the Coq proof assistant of several applicative data structures implementing finite sets. These implementations are parameterized by an ordered type for the elements, using functors from the ML module system. The verification follows closely this scheme, using the newly Coq module system. One of the verified implementation is the actual code for sets and maps from the Objective Caml standard library. The formalization refines the informal specifications of these libraries into formal ones. The process of verification exhibited two small errors in the balancing scheme, which have been fixed and then verified. Beyond these verification results, this article illustrates the use and benefits of modules and functors in a logical framework.


Module System Balance Tree Binary Search Tree Inductive Predicate Balance Binary Search Tree 
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.


  1. 1.
    The Coq Proof Assistant,
  2. 2.
    The Objective Caml language,
  3. 3.
    Adams, S.: Functional pearls: Efficient sets – a balancing act. Journal of Functional Programming 3(4), 553–561 (1993); Expanded version available as Technical Report CSTR 92-10, University of SouthamptonCrossRefGoogle Scholar
  4. 4.
    Adel’son-Vel’skiĭ, G.M., Landis, E.M.: An algorithm for the organization of information. Soviet Mathematics–Doklady 3(5), 1259–1263 (1962)Google Scholar
  5. 5.
    Chrząszcz, J.: Implementing modules in the system Coq. In: 16th International Conference on Theorem Proving in Higher Order Logics, University of Rome III (September 2003)Google Scholar
  6. 6.
    Chrząszcz, J.: Modules in Type Theory with generative definitions. PhD thesis, Warsaw University and Université Paris-Sud (2003); To be defendedGoogle Scholar
  7. 7.
    Courant, J.: A Module Calculus for Pure Type Systems. In: Typed Lambda Calculi and Applications 1997. LNCS, pp. 112–128. Springer, Heidelberg (1997)Google Scholar
  8. 8.
    Guibas, L.J., Sedgewick, R.: A dichromatic framework for balanced trees. In: 19th Annual Symposium on Foundations of Computer Science, Ann Arbor, Michigan, October 16-18, pp. 8–21. IEEE, Los Alamitos (1978)CrossRefGoogle Scholar
  9. 9.
    Harper, R., Lillibridge, M.: A type-theoretic approach to higher-order modules with sharing. In: Conference record of POPL 1994: 21st ACM SIGPLANSIGACT Symposium on Principles of Programming Languages, Portland, OR, January 1994, pp. 123–137 (1994)Google Scholar
  10. 10.
    Hinze, R.: Constructing red-black trees. In: Okasaki, C. (ed.) Proceedings of the Workshop on Algorithmic Aspects of Advanced Programming Languages, WAAAPL 1999, Paris, France, September 1999, pp. 89–99 (1999); Also technical report of Columbia University, CUCS-023-99Google Scholar
  11. 11.
    Leroy, X.: A modular module system. Journal of Functional Programming 10(3), 269–303 (2000)zbMATHCrossRefGoogle Scholar
  12. 12.
    Letouzey, P.: A New Extraction for Coq. In: Geuvers, H., Wiedijk, F. (eds.) TYPES 2002. LNCS, vol. 2646, pp. 200–219. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  13. 13.
    Letouzey, P.: Programmation fonctionnelle certifiée en Coq. PhD thesis, Universit é Paris Sud (2003); To be defendedGoogle Scholar
  14. 14.
    Okasaki, C.: Purely Functional Data Structures. Cambridge University Press, Cambridge (1998)CrossRefGoogle Scholar
  15. 15.
    Wadler, P.: Deforestation: transforming programs to eliminate trees. Theoretical Computer Science 73, 231–248 (1990)zbMATHCrossRefMathSciNetGoogle Scholar
  16. 16.
    Xi, H.: Dependently Typed Data Structures. In: Proceedings of Workshop of Algorithmic Aspects of Advanced Programming Languages (WAAAPL 1999), Paris, September 1999, pp. 17–32 (1999)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2004

Authors and Affiliations

  • Jean-Christophe Filliâtre
    • 1
  • Pierre Letouzey
    • 1
  1. 1.LRI – CNRS UMR 8623 Université Paris-SudFrance

Personalised recommendations