Compiling contextual objects: bringing higher-order abstract syntax to programmers

Binders in data-structures representing code or proofs can be represented in a variety of ways, from low-level first-order representations such as de Bruijn indices to higher-order abstract syntax (HOAS), with nominal logic somewhere in-between. HOAS is arguably the cleanest and highest-level representation but comes with significant problems in expressiveness and efficiency. The Beluga language addresses this expressiveness problem by providing a powerful pattern matching facility as well as explicit control over contexts. This work aims to solve one important efficiency concern by showing how to compile Beluga down to lower-level primitives. It does so by compiling Beluga's binders into an intermediate first-order representation that abstracts over the eventual low-level representation, and by adapting ML-style pattern compilation to the more general case of Beluga's patterns. As an important side benefit, our work clarifies the connection between programming with HOAS in Beluga and programming with first-order approaches based on names.

[1]  Pierre Letouzey,et al.  A New Extraction for Coq , 2002, TYPES.

[2]  Zhong Shao,et al.  Implementing typed intermediate languages , 1998, ICFP '98.

[3]  Luc Maranget Compiling pattern matching to good decision trees , 2008, ML '08.

[4]  Frank Pfenning,et al.  On equivalence and canonical forms in the LF type theory , 2001, TOCL.

[5]  Frank Pfenning,et al.  Optimizing Higher-Order Pattern Unification , 2003, CADE.

[6]  Brigitte Pientka,et al.  Beluga: A Framework for Programming and Reasoning with Deductive Systems (System Description) , 2010, IJCAR.

[7]  Martín Abadi,et al.  Explicit substitutions , 1989, POPL '90.

[8]  Patrick J. Hayes,et al.  Computation and Deduction , 1973, MFCS.

[9]  Adam Chlipala Parametric higher-order abstract syntax for mechanized semantics , 2008, ICFP 2008.

[10]  Frank Pfenning,et al.  System Description: Twelf - A Meta-Logical Framework for Deductive Systems , 1999, CADE.

[11]  Robert Harper,et al.  A universe of binding and computation , 2009, ICFP.

[12]  Martín Abadi,et al.  Explicit substitutions , 1989, POPL '90.

[13]  Andrew M. Pitts,et al.  A First Order Theory of Names and Binding , 2001 .

[14]  Brigitte Pientka,et al.  Case Analysis of Higher-Order Data , 2009, Electron. Notes Theor. Comput. Sci..

[15]  Brigitte Pientka,et al.  Programming with binders and indexed data-types , 2012, POPL '12.

[16]  Xavier Leroy,et al.  Formal verification of a realistic compiler , 2009, CACM.

[17]  Andrew M. Pitts,et al.  FreshML: programming with binders made simple , 2003, ICFP '03.

[18]  Carsten Schürmann,et al.  System Description: Delphin - A Functional Programming Language for Deductive Systems , 2008, LFMTP@LICS.

[19]  M. Maher Unification via Explicit Substitutions: The Case of Higher-Order Patterns , 1996 .

[20]  Brigitte Pientka,et al.  Higher-Order Dynamic Pattern Unification for Dependent Types and Records , 2011, TLCA.

[21]  Frank Pfenning,et al.  Contextual modal type theory , 2008, TOCL.

[22]  Amy P. Felty,et al.  Hybrid - A Definitional Two-Level Approach to Reasoning with Higher-Order Abstract Syntax , 2012, J. Autom. Reason..

[23]  ScienceYale UniversityNew Haven An Overview of the Flint/ml Compiler , 1997 .

[24]  Brigitte Pientka A type-theoretic foundation for programming with higher-order abstract syntax and first-class substitutions , 2008, POPL '08.

[25]  Stefan Monnier,et al.  Singleton types here, singleton types there, singleton types everywhere , 2010, PLPV '10.

[26]  Stephanie Weirich,et al.  Boxes go bananas: encoding higher-order abstract syntax with parametric polymorphism , 2003, ICFP '03.

[27]  Luc Maranget,et al.  Optimizing pattern matching , 2001, ICFP '01.

[28]  François Pottier,et al.  A fresh look at programming with names and binders , 2010, ICFP '10.

[29]  Furio Honsell,et al.  A framework for defining logics , 1993, JACM.

[30]  Pierre Letouzey Extraction in Coq: An Overview , 2008, CiE.

[31]  Frank Pfenning,et al.  A Coverage Checking Algorithm for LF , 2003, TPHOLs.

[32]  Frank Pfenning,et al.  Higher-order abstract syntax , 1988, PLDI '88.

[33]  Stefan Monnier,et al.  A type-preserving compiler in Haskell , 2008, ICFP.

[34]  Gopalan Nadathur,et al.  Explicit substitutions in the reduction of lambda terms , 2003, PPDP '03.

[35]  Christian Urban,et al.  Nominal Techniques in Isabelle/HOL , 2005, Journal of Automated Reasoning.

[36]  Nicolas Frisby,et al.  Hobbits for Haskell: a library for higher-order encodings in functional programming languages , 2012 .