Initial Semantics for higher-order typed syntax in Coq

Initial Semantics aims at characterizing the syntax associated to a signature as the initial object of some category. We present an initial semantics result for typed higher-order syntax together with its formalization in the Coq proof assistant. The main theorem was first proved on paper in the second author's PhD thesis in 2010, and verified formally shortly afterwards. To a simply-typed binding signature S over a fixed set T of object types we associate a category called the category of representations of S. We show that this category has an initial object Sigma(S). From its construction it will be clear that the object Sigma(S) merits the name abstract syntax associated to S. Our theorem is implemented and proved correct in the proof assistant Coq through heavy use of dependent types. The approach through monads gives rise to an implementation of syntax where both terms and variables are intrinsically typed, i.e. where the object types are reflected in the meta-level types. This article is to be seen as a research article rather than about the formalization of a classical mathematical result. The nature of our theorem - involving lengthy, technical proofs and complicated algebraic structures - makes it particularly interesting for formal verification. Our goal is to promote the use of computer theorem provers as research tools, and, accordingly, a new way of publishing mathematical results: a parallel description of a theorem and its formalization should allow the verification of correct transcription of definitions and statements into the proof assistant, and straightforward but technical proofs should be well-hidden in a digital library. We argue that Coq's rich type theory, combined with its various features such as implicit arguments, allows a particularly readable formalization and is hence well-suited for communicating mathematics.

[1]  Bas Spitters,et al.  Type classes for mathematics in type theory† , 2011, Mathematical Structures in Computer Science.

[2]  Benedikt Ahrens,et al.  Extended Initiality for Typed Abstract Syntax , 2011, Log. Methods Comput. Sci..

[3]  Assia Mahboubi,et al.  Packaging Mathematical Structures , 2009, TPHOLs.

[4]  Amy P. Felty,et al.  Logic Colloquium 2006: Higher-order abstract syntax in type theory , 2009 .

[5]  Chung-Kil Hur,et al.  Equational Systems and Free Constructions (Extended Abstract) , 2007, ICALP.

[6]  Adam Chlipala An Introduction to Programming and Proving with Dependent Types in Coq , 2010, J. Formaliz. Reason..

[7]  Martin Hofmann Semantical analysis of higher-order abstract syntax , 1999, Proceedings. 14th Symposium on Logic in Computer Science (Cat. No. PR00158).

[8]  Joseph A. Goguen,et al.  Initial Algebra Semantics and Continuous Algebras , 1977, J. ACM.

[9]  Marino Miculan,et al.  A framework for typed HOAS and semantics , 2003, PPDP '03.

[10]  Richard S. Bird,et al.  Nested Datatypes , 1998, MPC.

[11]  Gérard P. Huet,et al.  Constructive category theory , 2000, Proof, Language, and Interaction.

[12]  Greg O'Keefe Towards a Readable Formalisation of Category Theory , 2004, Electron. Notes Theor. Comput. Sci..

[13]  Yves Bertot,et al.  Interactive Theorem Proving and Program Development: Coq'Art The Calculus of Inductive Constructions , 2010 .

[14]  Andrew M. Pitts,et al.  A new approach to abstract syntax involving binders , 1999, Proceedings. 14th Symposium on Logic in Computer Science (Cat. No. PR00158).

[15]  Varmo Vene,et al.  CATEGORICAL PROGRAMMING WITH INDUCTIVE AND COINDUCTIVE TYPES , 2000 .

[16]  André Hirschowitz,et al.  Modules over Monads and Linearity , 2006, WoLLIC.

[17]  Carlos Simpson Explaining Gabriel–Zisman Localization to the Computer , 2006, Journal of Automated Reasoning.

[18]  Chung-Kil Hur,et al.  Strongly Typed Term Representations in Coq , 2011, Journal of Automated Reasoning.

[19]  Freek Wiedijk,et al.  Formal proof -- getting started , 2008 .

[20]  André Hirschowitz,et al.  Nested Abstract Syntax in Coq , 2010, Journal of Automated Reasoning.

[21]  Chung-Kil Hur Categorical equational systems : algebraic models and equational reasoning , 2010 .

[22]  André Hirschowitz,et al.  Modules over monads and initial semantics , 2010, Inf. Comput..

[23]  Rance Cleaveland,et al.  Implementing mathematics with the Nuprl proof development system , 1986 .

[24]  Benjamin C. Pierce,et al.  Mechanized Metatheory for the Masses: The PoplMark Challenge , 2005, TPHOLs.

[25]  Julianna Zsido Typed Abstract Syntax , 2010 .

[26]  Marcelo P. Fiore,et al.  Semantic analysis of normalisation by evaluation for typed lambda calculus , 2002, PPDP '02.

[27]  Daniele Turi,et al.  Abstract Syntax and Variable Binding (Extended Abstract) , 2003 .

[28]  Thorsten Altenkirch,et al.  Monadic Presentations of Lambda Terms Using Generalized Inductive Types , 1999, CSL.

[29]  Matthieu Sozeau,et al.  First-Class Type Classes , 2008, TPHOLs.

[30]  Philip Wadler,et al.  Monads for functional programming , 1995, NATO ASI PDC.