Bidirectional Elaboration of Dependently Typed Programs

Dependently typed programming languages allow programmers to express a rich set of invariants and verify them statically via type checking. To make programming with dependent types practical, dependently typed systems provide a compact language for programmers where one can omit some arguments, called implicit, which can be inferred. This source language is then usually elaborated into a core language where type checking and fundamental properties such as normalization are well understood. Unfortunately, this elaboration is rarely specified and in general is ill-understood. This makes it not only difficult for programmers to understand why a given program fails to type check, but also is one of the reasons that implementing dependently typed programming systems remains a black art known only to a few. In this paper, we specify the design of a source language for a dependently typed programming language where we separate the language of programs from the language of types and terms occurring in types. Total functions in our language correspond directly to first-order inductive proofs over a specific index domain. We then give a bi-directional elaboration algorithm to translate source terms where implicit arguments can be omitted to a fully explicit core language and prove soundness of our elaboration. Our framework provides post-hoc explanation for elaboration found in the programming and proof environment, Beluga.

[1]  Marko Luther,et al.  More On Implicit Syntax , 2001, IJCAR.

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

[3]  Brigitte Pientka,et al.  Higher-order term indexing using substitution trees , 2009, TOCL.

[4]  Hongwei Xi,et al.  Dependent ML An approach to practical programming with dependent types , 2007, Journal of Functional Programming.

[5]  Steve Zdancewic,et al.  AURA: a programming language for authorization and audit , 2008, ICFP 2008.

[6]  Benjamin C. Pierce,et al.  Local type inference , 1998, POPL '98.

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

[8]  Brigitte Pientka,et al.  Structural Recursion over Contextual Objects , 2014 .

[9]  Brigitte Pientka,et al.  Programming Type-Safe Transformations Using Higher-Order Abstract Syntax , 2013, CPP.

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

[11]  Christoph Zenger,et al.  Indexed Types , 1997, Theoretical Computer Science.

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

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

[14]  U. Norell,et al.  Towards a practical programming language based on dependent type theory , 2007 .

[15]  Frank Pfenning,et al.  Dependent types in practical programming , 1999, POPL '99.

[16]  Simon L. Peyton Jones,et al.  Complete and decidable type inference for GADTs , 2009, ICFP.

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

[18]  D. Walker,et al.  A concurrent logical framework I: Judgments and properties , 2003 .

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

[20]  Conor McBride,et al.  The view from the left , 2004, Journal of Functional Programming.

[21]  Brigitte Pientka,et al.  An insider's look at LF type reconstruction: everything you (n)ever wanted to know , 2013, J. Funct. Program..

[22]  Chiyan Chen,et al.  Combining programming with theorem proving , 2005, ICFP '05.

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

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

[25]  Frank Pfenning,et al.  Elf: a language for logic definition and verified metaprogramming , 1989, [1989] Proceedings. Fourth Annual Symposium on Logic in Computer Science.

[26]  Dale Miller,et al.  Unification of Simply Typed Lamda-Terms as Logic Programming , 1991, ICLP.

[27]  Claude Kirchner,et al.  Unification via Explicit Substitutions: The Case of Higher-Order Patterns , 1996, JICSLP.

[28]  Andrea Asperti,et al.  A Bi-Directional Refinement Algorithm for the Calculus of (Co)Inductive Constructions , 2012, Log. Methods Comput. Sci..

[29]  Edwin Brady,et al.  Idris, a general-purpose dependently typed programming language: Design and implementation , 2013, Journal of Functional Programming.