skip to main content
research-article

Pattern matching without K

Published:19 August 2014Publication History
Skip Abstract Section

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

Index Terms

  1. Pattern matching without K

            Recommendations

            Comments

            Login options

            Check if you have access through your login credentials or your institution to get full access on this article.

            Sign in

            Full Access

            PDF Format

            View or Download as a PDF file.

            PDF

            eReader

            View online with eReader.

            eReader
            About Cookies On This Site

            We use cookies to ensure that we give you the best experience on our website.

            Learn more

            Got it!