Abstract
Dependent pattern matching is an intuitive way to write programs and proofs in dependently typed languages. It is reminiscent of both pattern matching in functional languages and case analysis in on-paper mathematics. However, in general it is incompatible with new type theories such as homotopy type theory (HoTT). As a consequence, proofs in such theories are typically harder to write and to understand. The source of this incompatibility is the reliance of dependent pattern matching on the so-called K axiom - also known as the uniqueness of identity proofs - which is inadmissible in HoTT. The Agda language supports an experimental criterion to detect definitions by pattern matching that make use of the K axiom, but so far it lacked a formal correctness proof.
In this paper, we propose a new criterion for dependent pattern matching without K, and prove it correct by a translation to eliminators in the style of Goguen et al. (2006). Our criterion both allows more good definitions than existing proposals, and solves a previously undetected problem in the criterion offered by Agda. It has been implemented in Agda and is the first to be supported by a formal proof. Thus it brings the benefits of dependent pattern matching to contexts where we cannot assume K, such as HoTT. It also points the way to new forms of dependent pattern matching, for example on higher inductive types.
- T. Altenkirch. Without-K problem, 2012. URL https://lists.chalmers.se/pipermail/agda/2012/004104.html. On the Agda mailing list.Google Scholar
- E. Brady. Idris, a general purpose dependently typed programming language: Design and implementation. Journal of Functional Programming, 23 (5), 2013.Google Scholar
Cross Ref
- J. Cockx. Yet another way Agda-without-K is incompatible with univalence, 2014. URL https://lists.chalmers.se/pipermail/agda/2014/006367.html. On the Agda mailing list.Google Scholar
- T. Coquand. Pattern matching with dependent types. In Types for proofs and programs, 1992.Google Scholar
- P.-E. Dagand. A cosmology of datatypes: reusability and dependent types. PhD thesis, University of Strathclyde, 2013.Google Scholar
- N. A. Danielsson. Experiments related to equality, 2013. URL http://www.cse.chalmers.se/~nad/repos/equality/. Agda code.Google Scholar
- D. Devriese and F. Piessens. On the bright side of type classes: instance arguments in Agda. ACM SIGPLAN International Conference on Functional Programming (ICFP), pages 143--155, 2011. Google Scholar
Digital Library
- P. Dybjer. Inductive sets and families in Martin-Löf's type theory and their set-theoretic semantics. In Proceedings of the first workshop on Logical frameworks, 1991. Google Scholar
Digital Library
- H. Goguen, C. McBride, and J. McKinna. Eliminating dependent pattern matching. In Algebra, Meaning, and Computation. 2006.Google Scholar
Cross Ref
- M. Hofmann and T. Streicher. The groupoid model refutes uniqueness of identity proofs. In Logic in Computer Science, pages 208--212, 1994.Google Scholar
- J.-P. Jouannaud and C. Kirchner. Solving equations in abstract algebras: A rule-based survey of unification. 1990.Google Scholar
- N. Kraus and C. Sattler. On the hierarchy of univalent universes: U(n) is not n-truncated. arXiv preprint arXiv:1311.4002, 2013.Google Scholar
- N. Kraus, M. Escardó, T. Coquand, and T. Altenkirch. Generalizations of Hedberg's theorem. In Typed Lambda Calculi and Applications, pages 173--188. Springer, 2013.Google Scholar
Cross Ref
- Z. Luo. Computation and reasoning: a type theory for computer science, volume 11 of International Series of Monographs on Computer Science. 1994. Google Scholar
Digital Library
- P. Martin-Löf. Intuitionistic type theory. Number 1 in Studies in Proof Theory. 1984.Google Scholar
- C. McBride. Towards dependent pattern matching in lego. TYPES meeting, 1998.Google Scholar
- C. McBride. Dependently typed functional programs and their proofs. PhD thesis, University of Edinburgh, 2000.Google Scholar
- C. McBride. Elimination with a motive. In Types for proofs and programs, 2002. Google Scholar
Digital Library
- C. McBride, H. Goguen, and J. McKinna. A few constructions on constructors. In Types for Proofs and Programs, 2006. Google Scholar
Digital Library
- U. Norell. Towards a practical programming language based on dependent type theory. PhD thesis, Chalmers University of Technology, 2007.Google Scholar
- U. Norell, A. Abel, and N. A. Danielsson. Release notes for Agda 2 version 2.3.2, 2012. URL http://wiki.portal.chalmers.se/agda/pmwiki.php?n=Main.Version-2-3-2.Google Scholar
- J. Reed. Another possible without-K problem, 2013. URL https://lists.chalmers.se/pipermail/agda/2013/005578.html. On the Agda mailing list.Google Scholar
- Sicard-Ramírez. -without-K option too restrictive?, 2013. URL https://lists.chalmers.se/pipermail/agda/2013/005407.html. On the Agda mailing list.Google Scholar
- M. Sozeau. Equations: A dependent pattern-matching compiler. In Interactive theorem proving, 2010. Google Scholar
Digital Library
- The Coq development team. The Coq proof assistant reference manual. LogiCal Project, 2012. URL http://coq.inria.fr. Version 8.4.Google Scholar
- The Univalent Foundations Program. Homotopy Type Theory: Univalent Foundations of Mathematics. http://homotopytypetheory.org/book, Institute for Advanced Study, 2013.Google Scholar
Index Terms
Pattern matching without K
Recommendations
Elaborating dependent (co)pattern matching
In a dependently typed language, we can guarantee correctness of our programs 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 ...
Cubical agda: a dependently typed programming language with univalence and higher inductive types
Proof assistants based on dependent type theory provide expressive languages for both programming and proving within the same system. However, all of the major implementations lack powerful extensionality principles for reasoning about equality, such as ...
Pattern matching without K
ICFP '14: Proceedings of the 19th ACM SIGPLAN international conference on Functional programmingDependent pattern matching is an intuitive way to write programs and proofs in dependently typed languages. It is reminiscent of both pattern matching in functional languages and case analysis in on-paper mathematics. However, in general it is ...







Comments