Abstract
De Bruijn indices are a well known technique for programming with names and binders. They provide a representation that is both simple and canonical.
However, programming errors tend to be really easy to make. We propose a safer programming interface implemented as a library. Whereas indexing the types of names and terms by a numerical bound is a famous technique, we index them by worlds, a different notion of index that is both finer and more abstract. While being more finely typed, our approach incurs no loss of expressiveness or efficiency.
Via parametricity we obtain properties about functions polymorphic on worlds. For instance, well-typed world-polymorphic functions over open λ-terms commute with any renaming of the free variables.
Our whole development is conducted within Agda, from the code of the library, to its soundness proof and the properties of external functions. The soundness of our library is demonstrated via the construction of a logical relations argument.
Supplemental Material
- Thorsten Altenkirch. A formalization of the strong normalization proof for System F in LEGO. In J. F. Groote M. Bezem, editor, Typed Lambda Calculi and Applications, LNCS 664, pages 13--28, 1993. Google Scholar
Digital Library
- Thorsten Altenkirch and Bernhard Reus. Monadic presentations of lambda terms using generalized inductive types. In Computer Science Logic, volume 1683 of Lecture Notes in Computer Science, pages 453--468. Springer, 1999. Google Scholar
Cross Ref
- Françoise Bellegarde and James Hook. Substitution: A formal methods case study using monads and transformations. Sci. Comput. Program., 23(2-3):287--311, 1994. Google Scholar
Digital Library
- Jean-Philippe Bernardy, Patrik Jansson, and Ross Paterson. Parametricity and dependent types. In Proceedings of the 15th ACM SIGPLAN international conference on Functional programming, ICFP '10, pages 345--356, New York, NY, USA, 2010. ACM. Google Scholar
Digital Library
- Richard Bird and Ross Paterson. de Bruijn notation as a nested datatype. Journal of Functional Programming, 9(1):77--91, January 1999. Google Scholar
Digital Library
- Nicolaas G. de Bruijn. Lambda-calculus notation with nameless dummies: a tool for automatic formula manipulation with application to the Church-Rosser theorem. Indag. Math., 34(5):381--392, 1972.Google Scholar
Cross Ref
- Conor McBride and James McKinna. The view from the left. J. Funct. Program., 14:69--111, January 2004. Google Scholar
Digital Library
- Conor McBride and Ross Paterson. Applicative programming with effects. Journal of Functional Programming, 18(1):1--13, 2008. Google Scholar
Digital Library
- Nicolas Pouillard. Nameless, painless (Agda code), 2011. http://tiny.nicolaspouillard.fr/NaPa.agda.Google Scholar
- Nicolas Pouillard and François Pottier. A fresh look at programming with names and binders. In Proceedings of the 15th ACM SIGPLAN international conference on Functional programming, ICFP '10, pages 217--228, New York, NY, USA, September 2010. ACM. Google Scholar
Digital Library
- John C. Reynolds. Types, abstraction and parametric polymorphism. In Information Processing 83, pages 513--523. Elsevier Science, 1983.Google Scholar
- Philip Wadler. Theorems for free! In Conference on Functional Programming Languages and Computer Architecture (FPCA), pages 347--359, September 1989. Google Scholar
Digital Library
Index Terms
Nameless, painless
Recommendations
Nameless, painless
ICFP '11: Proceedings of the 16th ACM SIGPLAN international conference on Functional programmingDe Bruijn indices are a well known technique for programming with names and binders. They provide a representation that is both simple and canonical.
However, programming errors tend to be really easy to make. We propose a safer programming interface ...
A fresh look at programming with names and binders
ICFP '10A wide range of computer programs, including compilers and theorem provers, manipulate data structures that involve names and binding. However, the design of programming idioms which allow performing these manipulations in a safe and natural style has, ...
A fresh look at programming with names and binders
ICFP '10: Proceedings of the 15th ACM SIGPLAN international conference on Functional programmingA wide range of computer programs, including compilers and theorem provers, manipulate data structures that involve names and binding. However, the design of programming idioms which allow performing these manipulations in a safe and natural style has, ...







Comments