Hostname: page-component-89b8bd64d-7zcd7 Total loading time: 0 Render date: 2026-05-12T13:00:07.520Z Has data issue: false hasContentIssue false

Elaborating dependent (co)pattern matching: No pattern left behind

Part of: ICFP2018

Published online by Cambridge University Press:  21 January 2020

JESPER COCKX
Affiliation:
Chalmers and Gothenburg University, Sweden (until October 2019) and TU Delft, Netherlands (from December 2019) (e-mail: jesper@sikanda.be)
ANDREAS ABEL
Affiliation:
Chalmers and Gothenburg University, Sweden (e-mail: andreas.abel@gu.se)
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.

In a dependently typed language, we can guarantee correctness of our programmes by providing formal proofs. To check them, the typechecker elaborates these programs and proofs into a low-level core language. However, this core language is by nature hard to understand by mere humans, so how can we know we proved the right thing? This question occurs in particular for dependent copattern matching, a powerful language construct for writing programmes and proofs by dependent case analysis and mixed induction/coinduction. A definition by copattern matching consists of a list of clauses that are elaborated to a case tree, which can be further translated to primitive eliminators. In previous work this second step has received a lot of attention, but the first step has been mostly ignored so far. We present an algorithm elaborating definitions by dependent copattern matching to a core language with inductive data types, coinductive record types, an identity type, and constants defined by well-typed case trees. To ensure correctness, we prove that elaboration preserves the first-match semantics of the user clauses. Based on this theoretical work, we reimplement the algorithm used by Agda to check left-hand sides of definitions by pattern matching. The new implementation is at the same time more general and less complex, and fixes a number of bugs and usability issues with the old version. Thus, we take another step towards the formally verified implementation of a practical dependently typed language.

Information

Type
Research Article
Creative Commons
Creative Common License - CCCreative Common License - BY
This is an Open Access article, distributed under the terms of the Creative Commons Attribution licence (http://creativecommons.org/licenses/by/4.0/), which permits unrestricted re-use, distribution, and reproduction in any medium, provided the original work is properly cited.
Copyright
© Cambridge University Press 2020
Submit a response

Discussions

No Discussions have been published for this article.