Abstract
Most interactive theorem provers provide support for some form of user-customizable proof automation. In a number of popular systems, such as Coq and Isabelle, this automation is achieved primarily through tactics, which are programmed in a separate language from that of the prover's base logic. While tactics are clearly useful in practice, they can be difficult to maintain and compose because, unlike lemmas, their behavior cannot be specified within the expressive type system of the prover itself.
We propose a novel approach to proof automation in Coq that allows the user to specify the behavior of custom automated routines in terms of Coq's own type system. Our approach involves a sophisticated application of Coq's canonical structures, which generalize Haskell type classes and facilitate a flexible style of dependently-typed logic programming. Specifically, just as Haskell type classes are used to infer the canonical implementation of an overloaded term at a given type, canonical structures can be used to infer the canonical proof of an overloaded lemma for a given instantiation of its parameters. We present a series of design patterns for canonical structure programming that enable one to carefully and predictably coax Coq's type inference engine into triggering the execution of user-supplied algorithms during unification, and we illustrate these patterns through several realistic examples drawn from Hoare Type Theory. We assume no prior knowledge of Coq and describe the relevant aspects of Coq type inference from first principles.
Supplemental Material
- Andrea Asperti, Wilmer Ricciotti, Claudio Sacerdoti Coen, and Enrico Tassi. Hints in unification. In TPHOLs, volume 5674 of LNCS, pages 84--98, 2009. Google Scholar
Digital Library
- Bruno Barras, Jean-Pierre Jouannaud, Pierre-Yves Strub, and Qian Wang. CoqMTU: a higher-order type theory with a predicative hierarchy of universes parametrized by a decidable first-order theory. In LICS, pages 143--151, 2011. Google Scholar
Digital Library
- Yves Bertot, Georges Gonthier, Sidi Ould Biha, and Ioana Pasca. Canonical big operators. In TPHOLs, volume 5170 of LNCS, pages 86--101, 2008. Google Scholar
Digital Library
- Thomas Braibant and Damien Pous. Rewriting modulo associativity and commutativity in Coq. In Second Coq workshop, 2010.Google Scholar
- Manuel M. T. Chakravarty, Gabriele Keller, and Simon Peyton Jones. Associated type synonyms. In ICFP, pages 241--253, 2005. Google Scholar
Digital Library
- Adam Chlipala. Certified programming with dependent types. URL: http://adam.chlipala.net/cpdt, 2008.Google Scholar
- Adam Chlipala. Mostly-automated verification of low-level programs in computational separation logic. In PLDI, 2011. Google Scholar
Digital Library
- Georges Gonthier. Formal proof - the four-color theorem. Notices of the AMS, 55(11):1382--93, 2008.Google Scholar
- Georges Gonthier. Point-free, set-free concrete linear algebra. In ITP, 2011. Google Scholar
Digital Library
- Georges Gonthier and Assia Mahboubi. An introduction to small scale reflection in Coq. Journal of Formalized Reasoning, 3(2):95--152, 2010.Google Scholar
- Georges Gonthier, Beta Ziliani, Aleksandar Nanevski, and Derek Dreyer. How to make ad hoc proof automation less ad hoc, 2011. Code + appendix: http://www.mpi-sws.org/~beta/lessadhoc. Google Scholar
Digital Library
- Benjamin Grégoire and Assia Mahboubi. Proving equalities in a commutative ring done right in Coq. In TPHOLs, pages 98--113, 2005. Google Scholar
Digital Library
- Cordelia Hall, Kevin Hammond, Simon Peyton Jones, and Philip Wadler. Type classes in Haskell. TOPLAS, 18:241--256, 1996. Google Scholar
Digital Library
- Limin Jia, Jianzhou Zhao, Vilhelm Sjöberg, and Stephanie Weirich. Dependent types and program equivalence. In POPL, pages 275--286, 2010. Google Scholar
Digital Library
- Mark P. Jones. Type classes with functional dependencies. In ESOP, pages 230--244, 2000. Google Scholar
Digital Library
- Gerwin Klein, June Andronick, Kevin Elphinstone, Gernot Heiser, David Cock, Philip Derrin, Dhammika Elkaduwe, Kai Engelhardt, Rafal Kolanski, Michael Norrish, Thomas Sewell, Harvey Tuch, and Simon Winwood. seL4: formal verification of an operating-system kernel. CACM, 53(6):107--115, 2010. Google Scholar
Digital Library
- Xavier Leroy. Formal verification of a realistic compiler. CACM, 52:107--115, July 2009. Google Scholar
Digital Library
- J. Garrett Morris and Mark P. Jones. Instance chains: Type class programming without overlapping instances. In ICFP, pages 375--386, 2010. Google Scholar
Digital Library
- Aleksandar Nanevski, Viktor Vafeiadis, and Josh Berdine. Structuring the verification of heap-manipulating programs. In POPL, pages 261--274, 2010. Google Scholar
Digital Library
- Brigitte Pientka and Joshua Dunfield. Programming with proofs and explicit contexts. In PPDP, pages 163--173, 2008. Google Scholar
Digital Library
- Adam Poswolsky and Carsten Schürmann. System description: Delphin - a functional programming language for deductive systems. ENTCS, 228:113--120, 2009. Google Scholar
Digital Library
- John C. Reynolds. Separation logic: a logic for shared mutable data structures. In LICS, 2002. Google Scholar
Digital Library
- Amokrane Saïbi. Typing algorithm in type theory with inheritance. In POPL, pages 292--301, 1997. Google Scholar
Digital Library
- Matthieu Sozeau and Nicolas Oury. First-class type classes. In TPHOLs, volume 5170 of LNCS, pages 278--293, 2008. Google Scholar
Digital Library
- Bas Spitters and Eelis van der Weegen. 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
- Antonis Stampoulis and Zhong Shao. VeriML: Typed computation of logical terms inside a language with effects. In ICFP, pages 333--344, 2010. Google Scholar
Digital Library
- Pierre-Yves Strub. Coq modulo theory. In CSL, pages 529--543, 2010. Google Scholar
Digital Library
- Philip Wadler and Stephen Blott. How to make ad-hoc polymorphism less ad hoc. In POPL, pages 60--76, 1989. Google Scholar
Digital Library
Index Terms
How to make ad hoc proof automation less ad hoc
Recommendations
How to make ad hoc proof automation less ad hoc
ICFP '11: Proceedings of the 16th ACM SIGPLAN international conference on Functional programmingMost interactive theorem provers provide support for some form of user-customizable proof automation. In a number of popular systems, such as Coq and Isabelle, this automation is achieved primarily through tactics, which are programmed in a separate ...
Mtac: a monad for typed tactic programming in Coq
ICFP '13Effective support for custom proof automation is essential for large scale interactive proof development. However, existing languages for automation via *tactics* either (a) provide no way to specify the behavior of tactics within the base logic of the ...
Mtac: a monad for typed tactic programming in Coq
ICFP '13: Proceedings of the 18th ACM SIGPLAN international conference on Functional programmingEffective support for custom proof automation is essential for large scale interactive proof development. However, existing languages for automation via *tactics* either (a) provide no way to specify the behavior of tactics within the base logic of the ...







Comments