Hostname: page-component-586b7cd67f-t8hqh Total loading time: 0 Render date: 2024-11-25T06:41:00.635Z Has data issue: false hasContentIssue false

A unified treatment of syntax with binders

Published online by Cambridge University Press:  15 August 2012

NICOLAS POUILLARD
Affiliation:
INRIA, Domaine de Voluceau, Rocquencourt, BP 105, 78153 Le Chesnay, Cedex, France (e-mail: [email protected], [email protected])
FRANÇOIS POTTIER
Affiliation:
INRIA, Domaine de Voluceau, Rocquencourt, BP 105, 78153 Le Chesnay, Cedex, France (e-mail: [email protected], [email protected])
Rights & Permissions [Opens in a new window]

Abstract

Core share and HTML view are not available for this content. However, as you have access to this content, a full PDF is available via the ‘Save PDF’ action button.

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.

Type
Articles
Copyright
Copyright © Cambridge University Press 2012

References

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.CrossRefGoogle Scholar
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.CrossRefGoogle Scholar
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.CrossRefGoogle Scholar
Atkey, R., Lindley, S. & Yallop, J. (2009 September) Unembedding domain-specific languages. In Haskell Symposium, pp. 37–48.CrossRefGoogle Scholar
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.CrossRefGoogle Scholar
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.CrossRefGoogle Scholar
Bellegarde, F. & Hook, J. (1994) Substitution: A formal methods case study using monads and transformations. Sci. Comput. Program. 23 (2–3), 287311.CrossRefGoogle Scholar
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.CrossRefGoogle Scholar
Bird, R. & Paterson, R. (1999) de Bruijn notation as a nested datatype. J. Funct. Program. 9 (1), 7791.CrossRefGoogle Scholar
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.CrossRefGoogle Scholar
Charguéraud, A. (2011) The locally nameless representation. J. Autom. Reason. 1–46.Google Scholar
Chen, C. & Xi, H. (2003a, June) Implementing typeful program transformations. In ACM Workshop on Evaluation and Semantics-Based Program Manipulation (PEPM), pp. 20–28.CrossRefGoogle Scholar
Chen, C. & Xi, H. (2003b, August) Meta-programming through typeful code representation. In ACM International Conference on Functional Programming (ICFP), pp. 275–286.CrossRefGoogle Scholar
Cheney, J. (2005 September) Scrap your nameplate. In ACM International Conference on Functional Programming (ICFP).CrossRefGoogle Scholar
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.CrossRefGoogle Scholar
Danielsson, N. A. (2011) Agda standard library [online]. Available at: http://wiki.portal.chalmers.se/agda/agda.php?n=Libraries.StandardLibrary. Accessed July 2012.Google Scholar
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.CrossRefGoogle Scholar
de Bruijn, N. G. (1991) Telescopic mappings in typed lambda calculus. Inf. Comput. 91 (2), 189204.CrossRefGoogle Scholar
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.CrossRefGoogle Scholar
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.Google Scholar
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.CrossRefGoogle Scholar
Guillemette, L.-J. & Monnier, S. (2008) A type-preserving compiler in Haskell. In ACM International Conference on Functional Programming (ICFP), pp. 75–86.CrossRefGoogle Scholar
Harper, R., Honsell, F. & Plotkin, G. (1993) A framework for defining logics. J. ACM 194–204.CrossRefGoogle Scholar
Hoare, C. A. R. (1969) An axiomatic basis for computer programming. Commun. ACM 12 (10), 576580.CrossRefGoogle Scholar
Huet, G. (1997) The zipper. J. Funct. Program. 7 (5), 549554.CrossRefGoogle Scholar
Licata, D. R. & Harper, R. (2009 September) A universe of binding and computation. In ACM International Conference on Functional Programming (ICFP), pp. 123–134.CrossRefGoogle Scholar
McBride, C. (2003). First-order unification by structural recursion. J. Funct. Program. 13 (6), 10611075.CrossRefGoogle Scholar
McBride, C. & McKinna, J. (2004) The view from the left. J. Funct. Program. 14 (1), 69111.CrossRefGoogle Scholar
McBride, C. & Paterson, R. (2008) Applicative programming with effects. J. Funct. Program. 18 (1), 113.CrossRefGoogle Scholar
Mitchell, J. C. (1986) Representation independence and data abstraction. In ACM Symposium on Principles of Programming Languages (POPL), pp. 263–276.CrossRefGoogle Scholar
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.Google Scholar
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.Google Scholar
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.CrossRefGoogle Scholar
Pitts, A. M. (2006) Alpha-structural recursion and induction. J. ACM 53, 459506.CrossRefGoogle Scholar
Pitts, A. M. (2010 January) Nominal System T. In ACM Symposium on Principles of Programming Languages (POPL), pp. 159–170.CrossRefGoogle Scholar
Pollack, R., Sato, M. & Ricciotti, W. (2012) A canonical locally named representation of binding. J. Autom Reasoning 49 (2), 182207.CrossRefGoogle Scholar
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.Google Scholar
Poswolsky, A. & Schürmann, C. (2009) System description: Delphin – A functional programming language for deductive systems. Electron. Notes Theor. Comput. Sci. 228, 113120.CrossRefGoogle Scholar
Pottier, F. (2006) An overview of Cαml. Electron. Notes Theor. Comput. Sci. 148 (2), 2752.CrossRefGoogle Scholar
Pottier, F. (2007 July) Static name control for FreshML. In IEEE Symposium on Logic in Computer Science (LICS), pp. 356–365.CrossRefGoogle Scholar
Pouillard, N. (2011a) Nameless, painless. In Proceedings of the 16th ACM SIGPLAN International Conference on Functional Programming (ICFP '11). ACM, pp. 320332.CrossRefGoogle Scholar
Pouillard, N. (2011b) Nompa (Agda code) [online]. Available at: http://tiny.nicolaspouillard.fr/NomPa.agda. Accessed November 2011.Google Scholar
Pouillard, N. (2012 January) A Unifying Approach to Safe Programming with First-Order Syntax with Binders. PhD thesis, Université Paris 7.Google Scholar
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.CrossRefGoogle Scholar
Reynolds, J. C. (1983) Types, abstraction and parametric polymorphism. In Information Processing 83. Elsevier Science, pp. 513523.Google Scholar
Sato, M. & Pollack, R. (2010) External and internal syntax of the lambda-calculus. J. Symb. Comput. 45 (5), 598616.CrossRefGoogle Scholar
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.CrossRefGoogle Scholar
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.CrossRefGoogle Scholar
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.Google Scholar
Wadler, P. (1989 September) Theorems for free! In Conference on Functional Programming Languages and Computer Architecture (FPCA), pp. 347–359.CrossRefGoogle Scholar
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.CrossRefGoogle Scholar
Submit a response

Discussions

No Discussions have been published for this article.