Author:
MCBRIDE CONOR,MCKINNA JAMES
Abstract
Pattern matching has proved an extremely powerful and durable notion in functional programming. This paper contributes a new programming notation for type theory which elaborates the notion in various ways. First, as is by now quite well-known in the type theory community, definition by pattern matching becomes a more discriminating tool in the presence of dependent types, since it refines the explanation of types as well as values. This becomes all the more true in the presence of the rich class of datatypes known as inductive families (Dybjer, 1991). Secondly, as proposed by Peyton Jones (1997) for Haskell, and independently rediscovered by us, subsidiary case analyses on the results of intermediate computations, which commonly take place on the right-hand side of definitions by pattern matching, should rather be handled on the left. In simply-typed languages, this subsumes the trivial case of Boolean guards; in our setting it becomes yet more powerful. Thirdly, elementary pattern matching decompositions have a well-defined interface given by a dependent type; they correspond to the statement of an induction principle for the datatype. More general, user-definable decompositions may be defined which also have types of the same general form. Elementary pattern matching may therefore be recast in abstract form, with a semantics given by translation. Such abstract decompositions of data generalize Wadler's (1987) notion of ‘view’. The programmer wishing to introduce a new view of a type $\mathit{T}$, and exploit it directly in pattern matching, may do so via a standard programming idiom. The type theorist, looking through the Curry–Howard lens, may see this as proving a theorem, one which establishes the validity of a new induction principle for $\mathit{T}$. We develop enough syntax and semantics to account for this high-level style of programming in dependent type theory. We close with the development of a typechecker for the simply-typed lambda calculus, which furnishes a view of raw terms as either being well-typed, or containing an error. The implementation of this view is ipso facto a proof that typechecking is decidable.
Publisher
Cambridge University Press (CUP)
Cited by
168 articles.
订阅此论文施引文献
订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献
1. Strictly Monotone Brouwer Trees for Well Founded Recursion over Multiple Arguments;Proceedings of the 13th ACM SIGPLAN International Conference on Certified Programs and Proofs;2024-01-09
2. Focusing on Refinement Typing;ACM Transactions on Programming Languages and Systems;2023-12-20
3. Propositional Forms of Judgemental Interpretations;Journal of Logic, Language and Information;2023-05-03
4. A Proof Tree Builder for Sequent Calculus and Hoare Logic;Electronic Proceedings in Theoretical Computer Science;2023-03-10
5. Aesop: White-Box Best-First Proof Search for Lean;Proceedings of the 12th ACM SIGPLAN International Conference on Certified Programs and Proofs;2023-01-11