×

Strongly typed term representations in Coq. (English) Zbl 1269.68041

Summary: There are two approaches to formalizing the syntax of typed object languages in a proof assistant or programming language. The extrinsic approach is to first define a type that encodes untyped object expressions and then make a separate definition of typing judgements over the untyped terms. The intrinsic approach is to make a single definition that captures well-typed object expressions, so ill-typed expressions cannot even be expressed. Intrinsic encodings are attractive and naturally enforce the requirement that metalanguage operations on object expressions, such as substitution, respect object types. The price is that the metalanguage types of intrinsic encodings and operations involve non-trivial dependency, adding significant complexity. This paper describes intrinsic-style formalizations of both simply-typed and polymorphic languages, and basic syntactic operations thereon, in the Coq proof assistant. The Coq types encoding object-level variables (de Bruijn indices) and terms are indexed by both type and typing environment. One key construction is the boot-strapping of definitions and lemmas about the action of substitutions in terms of similar ones for a simpler notion of renamings. In the simply-typed case, this yields definitions that are free of any use of type equality coercions. In the polymorphic case, some substitution operations do still require type coercions, which we at least partially tame by uniform use of heterogeneous equality.

MSC:

68N18 Functional programming and lambda calculus
68T15 Theorem proving (deduction, resolution, etc.) (MSC2010)

Software:

Coq; Heq
Full Text: DOI

References:

[1] Adams, R.: Formalized metatheory with terms represented by an indexed family of types. In: Types for Proofs and Programs. Lecture Notes in Computer Science, vol. 3839, pp. 1–16. Springer (2006) · Zbl 1172.68547
[2] Altenkirch, T., Reus, B.: Monadic presentations of lambda terms using generalized inductive types. In: Computer Science Logic, 13th International Workshop (CSL’99). Lecture Notes in Computer Science, vol. 1683, pp. 453–468. Springer (1999) · Zbl 0944.03011
[3] Benton, N., Hur, C.K.: Biorthogonality, step-indexing and compiler correctness. In: Proceedings of the 14th ACM SIGPLAN International Conference on Functional Programming (ICFP’09), pp. 97–108. ACM (2009) · Zbl 1302.68083
[4] Benton, N., Hur, C.K.: Realizability and compositional compiler correctness for a polymorphic language. Tech. Rep. MSR-TR-2010-62, Microsoft Research (2010)
[5] Benton, N., Kennedy, A.J., Varming, C.: Some domain theory and denotational semantics in Coq. In: Theorem Proving in Higher Order Logics, 22nd International Conference (TPHOLs’09). Lecture Notes in Computer Science, vol. 5674, pp. 115–130. Springer (2009) · Zbl 1252.68248
[6] Bird, R., Meertens, L.: Nested datatypes. In: Proceedings of the 4th International Conference on Mathematics of Program Construction (MPC’98). Lecture Notes in Computer Science, vol. 1422, pp. 52–67. Springer (1998)
[7] Bird, R., Paterson, R.: de Bruijn notation as a nested datatype. J. Funct. Program. 9, 77–91 (1999) · Zbl 0926.68025 · doi:10.1017/S0956796899003366
[8] Brady, E., Hammond, K.: A verified staged interpreter is a verified compiler. In: Proceedings of the 5th International Conference on Generative Programming and Component Engineering (GPCE’06), pp. 111–120. ACM (2006)
[9] Chapman, J.: Type theory should eat itself. In: International Workshop on Logical Frameworks and Meta-Languages: Theory and Practice (LFMTP’08). Electr. Notes Theor. Comput. Sci., vol. 228, pp. 21–36. Elsevier (2009)
[10] Cheney, J., Hinze, R.: First-class phantom types. Tech. Rep. TR2003-1901, Cornell University (2003)
[11] Chlipala, A.: Parametric higher-order abstract syntax for mechanized semantics. In: Proceedings of the 13th ACM SIGPLAN International Conference on Functional Programming (ICFP’08), pp. 143–156. ACM (2008) · Zbl 1323.68184
[12] Coquand, C.: A formalized proof of the soundness and completeness of a simply typed lambda-calculus with explicit substitutions. Higher-Order and Symb. Comp. 15, 57–90 (2002) · Zbl 1041.68016 · doi:10.1023/A:1019964114625
[13] Danielsson, N.A.: A formalization of a dependently typed language as an inductive-recursive family. In: Types for Proofs and Programs. Lecture Notes in Computer Science, vol. 4502, pp. 93–109. Springer (2007) · Zbl 1178.03026
[14] Girard, J.Y., Lafont, Y., Taylor, P.: Proofs and Types. Cambridge Tracts in Theoretical Computer Science, vol. 7. CUP (1989) · Zbl 0671.68002
[15] Goguen, H., McKinna, J.: Candidates for substitution. Tech. Rep. ECS-LFCS-97-358, University of Edinburgh (1997)
[16] Harper, R., Honsell, F., Plotkin, G.: A framework for defining logics. J. ACM 40(1), 143–184 (1993) · Zbl 0778.03004 · doi:10.1145/138027.138060
[17] Hirschowitz, A., Maggesi, M.: Nested abstract syntax in Coq. J. Autom. Reason. (2010). doi: 10.1007/s10817-010-9207-9 · Zbl 1260.68374
[18] Hur, C.-K.: Heq: A Coq library for heterogeneous equality. http://www.mpi-sws.org/\(\sim\)gil/Heq/ (2010). Accessed Feb 2011
[19] Kennedy, A., Russo, C.: Generalized algebraic datatypes and object oriented programming. In: ACM Conference on Object Oriented Programming Systems, Languages and Applications (OOPSLA’05), pp. 21–40. ACM (2005)
[20] McBride, C.: Elimination with a motive. In: Types for Proofs and Programs. Lecture Notes in Computer Science, vol. 2277, pp. 197–216. Springer (2002) · Zbl 1054.03501
[21] McBride, C.: Type preserving renaming and substitution. http://strictlypositive.org/ren-sub.pdf (2005). Accessed Feb 2011
[22] McBride, C.: Outrageous but meaningful coincidences (dependently type-safe syntax and evaluation). In: Proceedings of the 6th ACM SIGPLAN Workshop on Generic Programming (WGP’10). ACM (2010)
[23] McBride, C., McKinna, J.: The view from the left. J. Funct. Program. 14(1), 69–111 (2004) · Zbl 1069.68539 · doi:10.1017/S0956796803004829
[24] Sheard, T.: Languages of the future. In: Companion to the 19th ACM Conference on Object Oriented Programming Systems, Languages and Applications (OOPSLA’04), pp. 116–119. ACM (2004)
[25] Sozeau, M.: PROGRAM-ing finger trees in COQ. In: Proceedings of the 12th ACM SIGPLAN International Conference on Functional Programming (ICFP’07), pp. 13–24. ACM (2007) · Zbl 1291.68157
[26] Sozeau, M.: A dependently-typed formalization of simply-typed lambda-calculus: substitution, denotation, normalization. http://mattam.org/research/publications/drafts/lambda-notes.pdf (2007). Accessed Feb 2011
[27] Xi, H., Chen, C., Chen, G.: Guarded recursive datatype constructors. In: Proceedings of the 30th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL’03), pp. 224–235. ACM (2003) · Zbl 1321.68161
This reference list is based on information provided by the publisher or from digital mathematics libraries. Its items are heuristically matched to zbMATH identifiers and may contain data conversion errors. In some cases that data have been complemented/enhanced by data from zbMATH Open. This attempts to reflect the references listed in the original paper as accurately as possible without claiming completeness or a perfect matching.