Skip to main content Accessibility help
×
Home

A unified treatment of syntax with binders

  • NICOLAS POUILLARD (a1) and FRANÇOIS POTTIER (a1)

Abstract

Atoms and de Bruijn indices are two well-known representation techniques for data structures that involve names and binders. However, using either technique, it is all too easy to make a programming error that causes one name to be used where another was intended. We propose an abstract interface to names and binders that rules out many of these errors. This interface is implemented as a library in Agda. It allows defining and manipulating term representations in nominal style and in de Bruijn style. The programmer is not forced to choose between these styles: on the contrary, the library allows using both styles in the same program, if desired. Whereas indexing the types of names and terms with a natural number is a well-known technique to better control the use of de Bruijn indices, we index types with worlds. Worlds are at the same time more precise and more abstract than natural numbers. Via logical relations and parametricity, we are able to demonstrate in what sense our library is safe, and to obtain theorems for free about world-polymorphic functions. For instance, we prove that a world-polymorphic term transformation function must commute with any renaming of the free variables. The proof is entirely carried out in Agda.

Copyright

References

Hide All
Altenkirch, T. (1993) A formalization of the strong normalization proof for System F in LEGO. In Typed Lambda Calculi and Applications, Bezem, M. & Groote, J. F. (eds), Lecture Notes in Computer Science, vol. 664. Springer-Verlag, pp. 1328.
Altenkirch, T. & Reus, B. (1999) Monadic presentations of lambda terms using generalized inductive types. In Computer Science Logic, Lecture Notes in Computer Science, vol. 1683. Springer, pp. 453468.
Atkey, R. (2009) Syntax for free: Representing syntax with binding using parametricity. In International Conference on Typed Lambda Calculi and Applications (TLCA), Lecture Notes in Computer Science, vol. 5608. Springer, pp. 3549.
Atkey, R., Lindley, S. & Yallop, J. (2009 September) Unembedding domain-specific languages. In Haskell Symposium, pp. 37–48.
Aydemir, B. E., Bohannon, A., Fairbairn, M., Foster, J. N., Pierce, B. C., Sewell, P., Vytiniotis, D., Washburn, G., Weirich, S. & Zdancewic, S. (2005) Mechanized metatheory for the masses: The PoplMark challenge. In International Conference on Theorem Proving in Higher-Order Logics (TPHOLs), Lecture Notes in Computer Science, vol. 3603. Springer, pp. 5065.
Aydemir, B., Charguéraud, A., Pierce, B. C., Pollack, R. & Weirich, S. (2008 January) Engineering formal metatheory. In ACM Symposium on Principles of Programming Languages (POPL), pp. 3–15.
Bellegarde, F. & Hook, J. (1994) Substitution: A formal methods case study using monads and transformations. Sci. Comput. Program. 23 (2–3), 287311.
Bernardy, J.-P., Jansson, P. & Paterson, R. (2010) Parametricity and dependent types. In Proceedings of the 15th ACM SIGPLAN International Conference on Functional Programming (ICFP '10). New York: ACM, pp. 345356.
Bird, R. & Paterson, R. (1999) de Bruijn notation as a nested datatype. J. Funct. Program. 9 (1), 7791.
Cave, A. & Pientka, B. (2012 January) Programming with binders and indexed data-types. In ACM Symposium on Principles of Programming Languages (POPL), pp. 413–424.
Charguéraud, A. (2011) The locally nameless representation. J. Autom. Reason. 1–46.
Chen, C. & Xi, H. (2003a, June) Implementing typeful program transformations. In ACM Workshop on Evaluation and Semantics-Based Program Manipulation (PEPM), pp. 20–28.
Chen, C. & Xi, H. (2003b, August) Meta-programming through typeful code representation. In ACM International Conference on Functional Programming (ICFP), pp. 275–286.
Cheney, J. (2005 September) Scrap your nameplate. In ACM International Conference on Functional Programming (ICFP).
Chlipala, A. (2007 June) A certified type-preserving compiler from lambda calculus to assembly language. In ACM Conference on Programming Language Design and Implementation (PLDI), pp. 54–65.
Danielsson, N. A. (2011) Agda standard library [online]. Available at: http://wiki.portal.chalmers.se/agda/agda.php?n=Libraries.StandardLibrary. Accessed July 2012.
de Bruijn, N. G. (1972) Lambda-calculus notation with nameless dummies: A tool for automatic formula manipulation with application to the Church–Rosser theorem. Indag. Math. 34 (5), 381392.
de Bruijn, N. G. (1991) Telescopic mappings in typed lambda calculus. Inf. Comput. 91 (2), 189204.
Donnelly, K. & Xi, H. (2005) Combining higher-order abstract syntax with first-order abstract syntax in ATS. In ACM Workshop on Mechanized Reasoning about Languages with Variable Binding, pp. 58–63.
Fiore, M., Plotkin, G. & Turi, D. (1999) Abstract syntax and variable binding (extended abstract). In IEEE Symposium on Logic in Computer Science (LICS). Computer Society Press, pp. 193202.
Floyd, R. W. (1967) Assigning meanings to programs. In Mathematical Aspects of Computer Science, Proceedings of Symposia in Applied Mathematics, vol. 19, pp. 19–32.
Guillemette, L.-J. & Monnier, S. (2008) A type-preserving compiler in Haskell. In ACM International Conference on Functional Programming (ICFP), pp. 75–86.
Harper, R., Honsell, F. & Plotkin, G. (1993) A framework for defining logics. J. ACM 194–204.
Hoare, C. A. R. (1969) An axiomatic basis for computer programming. Commun. ACM 12 (10), 576580.
Huet, G. (1997) The zipper. J. Funct. Program. 7 (5), 549554.
Licata, D. R. & Harper, R. (2009 September) A universe of binding and computation. In ACM International Conference on Functional Programming (ICFP), pp. 123–134.
McBride, C. (2003). First-order unification by structural recursion. J. Funct. Program. 13 (6), 10611075.
McBride, C. & McKinna, J. (2004) The view from the left. J. Funct. Program. 14 (1), 69111.
McBride, C. & Paterson, R. (2008) Applicative programming with effects. J. Funct. Program. 18 (1), 113.
Mitchell, J. C. (1986) Representation independence and data abstraction. In ACM Symposium on Principles of Programming Languages (POPL), pp. 263–276.
Norell, U. (2007 September) Towards a Practical Programming Language Based on Dependent Type Theory. PhD thesis, Department of Computer Science and Engineering, Chalmers University of Technology, SE-412 96 Göteborg, Sweden.
Pfenning, F. & Lee, P. (1989) LEAP: A language with eval and polymorphism. In International Joint Conference on Theory and Practice of Software Development (TAPSOFT), Lecture Notes in Computer Science, vol. 352. Springer, pp. 345359.
Pientka, B. (2008 January) A type-theoretic foundation for programming with higher-order abstract syntax and first-class substitutions. In ACM Symposium on Principles of Programming Languages (POPL), pp. 371–382.
Pitts, A. M. (2006) Alpha-structural recursion and induction. J. ACM 53, 459506.
Pitts, A. M. (2010 January) Nominal System T. In ACM Symposium on Principles of Programming Languages (POPL), pp. 159–170.
Pollack, R., Sato, M. & Ricciotti, W. (2012) A canonical locally named representation of binding. J. Autom Reasoning 49 (2), 182207.
Poswolsky, A. & Schürmann, C. (2008) Practical programming with higher-order encodings and dependent types. In European Symposium on Programming (ESOP), Lecture Notes in Computer Science, vol. 4960. Springer, pp. 93107.
Poswolsky, A. & Schürmann, C. (2009) System description: Delphin – A functional programming language for deductive systems. Electron. Notes Theor. Comput. Sci. 228, 113120.
Pottier, F. (2006) An overview of Cαml. Electron. Notes Theor. Comput. Sci. 148 (2), 2752.
Pottier, F. (2007 July) Static name control for FreshML. In IEEE Symposium on Logic in Computer Science (LICS), pp. 356–365.
Pouillard, N. (2011a) Nameless, painless. In Proceedings of the 16th ACM SIGPLAN International Conference on Functional Programming (ICFP '11). ACM, pp. 320332.
Pouillard, N. (2011b) Nompa (Agda code) [online]. Available at: http://tiny.nicolaspouillard.fr/NomPa.agda. Accessed November 2011.
Pouillard, N. (2012 January) A Unifying Approach to Safe Programming with First-Order Syntax with Binders. PhD thesis, Université Paris 7.
Pouillard, N. & Pottier, F. (2010) A fresh look at programming with names and binders. In Proceedings of the 15th ACM SIGPLAN International Conference on Functional Programming (ICFP '10). New York: ACM, pp. 217228.
Reynolds, J. C. (1983) Types, abstraction and parametric polymorphism. In Information Processing 83. Elsevier Science, pp. 513523.
Sato, M. & Pollack, R. (2010) External and internal syntax of the lambda-calculus. J. Symb. Comput. 45 (5), 598616.
Schürmann, C., Poswolsky, A. & Sarnat, J. (2005) The ∇-calculus: Functional programming with higher-order encodings. In International Conference on Typed Lambda Calculi and Applications (TLCA), Lecture Notes in Computer Science, vol. 3461. Springer, pp. 339353.
Shinwell, M. R., Pitts, A. M. & Gabbay, M. J. (2003 August) FreshML: Programming with binders made simple. In ACM International Conference on Functional Programming (ICFP), pp. 263–274.
Stark, I. (1994 December). Names and Higher-Order Functions. PhD thesis, University of Cambridge. Also available as Technical Report 363, University of Cambridge Computer Laboratory.
Wadler, P. (1989 September) Theorems for free! In Conference on Functional Programming Languages and Computer Architecture (FPCA), pp. 347–359.
Weirich, S., Yorgey, B. & Sheard, T. (2011) Binders unbound. In Proceedings of the 16th ACM SIGPLAN International Conference on Functional Programming (ICFP '11). ACM, pp. 333345.

Related content

Powered by UNSILO

A unified treatment of syntax with binders

  • NICOLAS POUILLARD (a1) and FRANÇOIS POTTIER (a1)

Metrics

Full text views

Total number of HTML views: 0
Total number of PDF views: 0 *
Loading metrics...

Abstract views

Total abstract views: 0 *
Loading metrics...

* Views captured on Cambridge Core between <date>. This data will be updated every 24 hours.

Usage data cannot currently be displayed.

A unified treatment of syntax with binders

  • NICOLAS POUILLARD (a1) and FRANÇOIS POTTIER (a1)
Submit a response

Discussions

No Discussions have been published for this article.

×

Reply to: Submit a response


Your details


Conflicting interests

Do you have any conflicting interests? *