Reference. Coverage Semantics for Dependent Pattern Matching
Dependent pattern matching is a key feature in dependently typed programming. However, there is a theory-practice disconnect: while many proof assistants implement pattern matching as primitive, theoretical presentations give semantics to pattern matching by elaborating to eliminators. Though theoretically convenient, eliminators can be awkward and verbose, particularly for complex combinations of patterns. This work aims to bridge the theory-practice gap by presenting a direct categorical semantics for pattern matching, which does not elaborate to eliminators. This is achieved using sheaf theory to describe when sets of arrows (terms) can be amalgamated into a single arrow. We present a language with top-level dependent pattern matching, without specifying which sets of patterns are considered covering for a match. Then, we give a sufficient criterion for which pattern-sets admit a sound model: patterns should be in the canonical coverage for the category of contexts. Finally, we use sheaf-theoretic saturation conditions to devise some allowable sets of patterns. We are able to express and exceed the status quo, giving semantics for datatype constructors, nested patterns, absurd patterns, propositional equality, and dot patterns.
Cite
Cites 27 works (5 here)
With notes (5)
Indexed containers altenkirch_indexed_2015
We show that the syntactically rich notion of strictly positive families can be reduced to a core type theory with a fixed number of type constructors exploiting the novel notion of indexed containers. As a result, we show indexed containers provide normal forms for strictly positive families in much the same way that containers provide normal forms for strictly positive types. Interestingly, this step from containers to indexed containers is achieved without having to extend the core type theory. Most of the construction presented here has been formalized using the Agda system.
The view from the left mcbride-2004-the
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 , 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 . 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.
Elimination with a Motive mcbride-2002-elimination
Syntax and semantics of dependent types Hofmann_1997
External (22)
- lean-cwf: Lean proof for ESOP 2025 "Coverage Semantics for Dependent Pattern Matching" (software) (2025)
- Documentation for Agda: Data.Vec.Base (agda-stdlib) (2024)
- Two-level type theory and applications (2023)
- Idris 2: Quantitative Type Theory in Practice (2021)
- Cubical Type Theory: A Constructive Interpretation of the Univalence Axiom (2018)
- Computable decision making on the reals and other spaces: via partiality and nondeterminism (2018)
- Making Discrete Decisions Based on Continuous Values (MS thesis) (2017)
- Pattern matching without K (2014)
- Overlapping and Order-Independent Patterns (2014)
- Dependently typed programming in Agda (2009)
- Higher Topos Theory (2009)
- Eliminating Dependent Pattern Matching (2006)
- Containers: Constructing strictly positive types (2005)
- Epigram: Practical Programming with Dependent Types (2005)
- Interactive Theorem Proving and Program Development (2004)
- Sketches of an Elephant: A Topos Theory Compendium (2003)
- Dependently Typed Functional Programs and Their Proofs (PhD thesis) (2000)
- Pattern matching with dependent types (1992)
- Sheaves in Geometry and Logic: A First Introduction to Topos Theory (1992)
- What Is Unification? (1989)
- Computational Category Theory (1988)
- Views: a way for pattern matching to cohabit with data abstraction (1987)