skip to main content
10.1145/2628136.2628139acmconferencesArticle/Chapter ViewAbstractPublication PagesicfpConference Proceedingsconference-collections
research-article

Pattern matching without K

Published: 19 August 2014 Publication History

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.

References

[1]
T. Altenkirch. Without-K problem, 2012. URL https://lists.chalmers.se/pipermail/agda/2012/004104.html. On the Agda mailing list.
[2]
E. Brady. Idris, a general purpose dependently typed programming language: Design and implementation. Journal of Functional Programming, 23 (5), 2013.
[3]
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.
[4]
T. Coquand. Pattern matching with dependent types. In Types for proofs and programs, 1992.
[5]
P.-E. Dagand. A cosmology of datatypes: reusability and dependent types. PhD thesis, University of Strathclyde, 2013.
[6]
N. A. Danielsson. Experiments related to equality, 2013. URL http://www.cse.chalmers.se/~nad/repos/equality/. Agda code.
[7]
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.
[8]
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.
[9]
H. Goguen, C. McBride, and J. McKinna. Eliminating dependent pattern matching. In Algebra, Meaning, and Computation. 2006.
[10]
M. Hofmann and T. Streicher. The groupoid model refutes uniqueness of identity proofs. In Logic in Computer Science, pages 208--212, 1994.
[11]
J.-P. Jouannaud and C. Kirchner. Solving equations in abstract algebras: A rule-based survey of unification. 1990.
[12]
N. Kraus and C. Sattler. On the hierarchy of univalent universes: U(n) is not n-truncated. arXiv preprint arXiv:1311.4002, 2013.
[13]
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.
[14]
Z. Luo. Computation and reasoning: a type theory for computer science, volume 11 of International Series of Monographs on Computer Science. 1994.
[15]
P. Martin-Löf. Intuitionistic type theory. Number 1 in Studies in Proof Theory. 1984.
[16]
C. McBride. Towards dependent pattern matching in lego. TYPES meeting, 1998.
[17]
C. McBride. Dependently typed functional programs and their proofs. PhD thesis, University of Edinburgh, 2000.
[18]
C. McBride. Elimination with a motive. In Types for proofs and programs, 2002.
[19]
C. McBride, H. Goguen, and J. McKinna. A few constructions on constructors. In Types for Proofs and Programs, 2006.
[20]
U. Norell. Towards a practical programming language based on dependent type theory. PhD thesis, Chalmers University of Technology, 2007.
[21]
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.
[22]
J. Reed. Another possible without-K problem, 2013. URL https://lists.chalmers.se/pipermail/agda/2013/005578.html. On the Agda mailing list.
[23]
Sicard-Ramírez. -without-K option too restrictive?, 2013. URL https://lists.chalmers.se/pipermail/agda/2013/005407.html. On the Agda mailing list.
[24]
M. Sozeau. Equations: A dependent pattern-matching compiler. In Interactive theorem proving, 2010.
[25]
The Coq development team. The Coq proof assistant reference manual. LogiCal Project, 2012. URL http://coq.inria.fr. Version 8.4.
[26]
The Univalent Foundations Program. Homotopy Type Theory: Univalent Foundations of Mathematics. http://homotopytypetheory.org/book, Institute for Advanced Study, 2013.

Cited By

View all

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Conferences
ICFP '14: Proceedings of the 19th ACM SIGPLAN international conference on Functional programming
August 2014
390 pages
ISBN:9781450328739
DOI:10.1145/2628136
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

Sponsors

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 19 August 2014

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. agda
  2. dependent pattern matching
  3. homotopy type theory
  4. k axiom

Qualifiers

  • Research-article

Funding Sources

Conference

ICFP'14
Sponsor:

Acceptance Rates

ICFP '14 Paper Acceptance Rate 28 of 85 submissions, 33%;
Overall Acceptance Rate 333 of 1,064 submissions, 31%

Upcoming Conference

ICFP '25
ACM SIGPLAN International Conference on Functional Programming
October 12 - 18, 2025
Singapore , Singapore

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)36
  • Downloads (Last 6 weeks)0
Reflects downloads up to 13 Dec 2024

Other Metrics

Citations

Cited By

View all
  • (2024)Deriving Dependently-Typed OOP from First PrinciplesProceedings of the ACM on Programming Languages10.1145/36498468:OOPSLA1(983-1009)Online publication date: 29-Apr-2024
  • (2023)Some Remarks About Dependent Type TheoryThe French School of Programming10.1007/978-3-031-34518-0_8(175-202)Online publication date: 11-Oct-2023
  • (2022)Subtyping Without ReductionMathematics of Program Construction10.1007/978-3-031-16912-0_2(34-61)Online publication date: 22-Sep-2022
  • (2021)A simpler encoding of indexed typesProceedings of the 6th ACM SIGPLAN International Workshop on Type-Driven Development10.1145/3471875.3472991(14-22)Online publication date: 18-Aug-2021
  • (2021)A novice-friendly induction tactic for leanProceedings of the 10th ACM SIGPLAN International Conference on Certified Programs and Proofs10.1145/3437992.3439928(199-211)Online publication date: 17-Jan-2021
  • (2021)Formalizing category theory in AgdaProceedings of the 10th ACM SIGPLAN International Conference on Certified Programs and Proofs10.1145/3437992.3439922(327-342)Online publication date: 17-Jan-2021
  • (2021)Big Data Processing on Volunteer ComputingACM Transactions on Internet Technology10.1145/340980121:4(1-20)Online publication date: 22-Jul-2021
  • (2020)Monster mashACM Transactions on Graphics10.1145/3414685.341780539:6(1-12)Online publication date: 27-Nov-2020
  • (2020)SymmetryNetACM Transactions on Graphics10.1145/3414685.341777539:6(1-14)Online publication date: 27-Nov-2020
  • (2020)An analysis and simulation tool of real-time communications in on-chip networksACM SIGBED Review10.1145/3412821.341282217:1(5-11)Online publication date: 27-Jul-2020
  • Show More Cited By

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media