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

Cite as @eremondi-2025-coverage (helia, typst) · \cite{eremondi-2025-coverage} (LaTeX)
BibTeX
bibtex · 1 line
@inbook{eremondi-2025-coverage, title={Coverage Semantics for Dependent Pattern Matching}, ISBN={9783031911187}, ISSN={1611-3349}, url={http://dx.doi.org/10.1007/978-3-031-91118-7_11}, DOI={10.1007/978-3-031-91118-7_11}, booktitle={Programming Languages and Systems}, publisher={Springer Nature Switzerland}, author={Eremondi, Joseph and Kammar, Ohad}, year={2025}, pages={264–291} }
hayagriva YAML (typst)
yaml · 17 lines
eremondi-2025-coverage:
  type: chapter
  title: Coverage Semantics for Dependent Pattern Matching
  author:
  - Eremondi, Joseph
  - Kammar, Ohad
  date: 2025
  page-range: 264-291
  url: http://dx.doi.org/10.1007/978-3-031-91118-7_11
  serial-number:
    doi: 10.1007/978-3-031-91118-7_11
    isbn: '9783031911187'
    issn: 1611-3349
  parent:
    type: book
    title: Programming Languages and Systems
    publisher: Springer Nature Switzerland
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.
PDF · DOI · pldb

Homotopy Type Theory: Univalent Foundations of Mathematics hottbook

Web · arXiv

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.
PDF · DOI · pldb

Elimination with a Motive mcbride-2002-elimination

DOI

Syntax and semantics of dependent types Hofmann_1997

DOI
eremondi-2025-coverage reference entries/refs/eremondi-2025-coverage/eremondi-2025-coverage.hel