skip to main content
article

Unifiers as equivalences: proof-relevant unification of dependently typed data

Published:04 September 2016Publication History
Skip Abstract Section

Abstract

Dependently typed languages such as Agda, Coq and Idris use a syntactic first-order unification algorithm to check definitions by dependent pattern matching. However, these algorithms don’t adequately consider the types of the terms being unified, leading to various unintended results. As a consequence, they require ad hoc restrictions to preserve soundness, but this makes them very hard to prove correct, modify, or extend.

This paper proposes a framework for reasoning formally about unification in a dependently typed setting. In this framework, unification rules compute not just a unifier but also a corresponding correctness proof in the form of an equivalence between two sets of equations. By rephrasing the standard unification rules in a proof-relevant manner, they are guaranteed to preserve soundness of the theory. In addition, it enables us to safely add new rules that can exploit the dependencies between the types of equations.

Using our framework, we reimplemented the unification algorithm used by Agda. As a result, we were able to replace previous ad hoc restrictions with formally verified unification rules, fixing a number of bugs in the process. We are convinced this will also enable the addition of new and interesting unification rules in the future, without compromising soundness along the way.

References

  1. Andreas Abel. MiniAgda: Integrating sized and dependent types. In Workshop on Partiality and Recursion in Interactive Theorem Provers (PAR), 2010.Google ScholarGoogle Scholar
  2. Andreas Abel. Irrelevance in type theory with a heterogeneous equality judgement. In Foundations of Software Science and Computational Structures. 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Andreas Abel. Injectivity of type constructors is partially back. Agda refutes excluded middle, 2015a.Google ScholarGoogle Scholar
  4. Franz Baader and Wayne Snyder. Unification theory. Handbook of automated reasoning, 2001.Google ScholarGoogle Scholar
  5. Thomas Braibant. A new Coq tactic for inversion, 2013.Google ScholarGoogle Scholar
  6. Cyril Cohen, Thierry Coquand, Simon Huber, and Anders Mörtberg. Cubical type theory: a constructive interpretation of the univalence axiom, 2015.Google ScholarGoogle Scholar
  7. Preprint. Thierry Coquand. Pattern matching with dependent types. In Types for proofs and programs, 1992.Google ScholarGoogle Scholar
  8. Cristina Cornes and Delphine Terrasse. Automating inversion of inductive predicates in Coq. In Types for Proofs and Programs. 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Nils Anders Danielsson. Heterogenous equality is crippled by the Bool /= Fin 2 fix, 2010.Google ScholarGoogle Scholar
  10. Gabe Dijkstra. Disunifying non-fully applied constructors is inconsistent with function extensionality, 2015.Google ScholarGoogle Scholar
  11. Healfdene Goguen, Conor McBride, and James McKinna. Eliminating dependent pattern matching. In Algebra, Meaning, and Computation. 2006.Google ScholarGoogle Scholar
  12. Joseph A. Goguen. What is unification? – A categorical view of substitution, equation and solution. In Resolution of Equations in Algebraic Structures, Volume 1: Algebraic Techniques, 1989.Google ScholarGoogle Scholar
  13. Chung-Kil Hur. Agda with the excluded middle is inconsistent?, 2010.Google ScholarGoogle Scholar
  14. Daniel R. Licata and Michael Shulman. Calculating the fundamental group of the circle in homotopy type theory. In 28th Annual IEEE/ACM Symposium on Logic in Computer Science, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Zhaohui 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
  16. Per Martin-Löf. Intuitionistic type theory. Number 1 in Studies in Proof Theory. 1984.Google ScholarGoogle Scholar
  17. Conor McBride. Towards dependent pattern matching in LEGO. TYPES meeting, 1998a. Conor McBride. Inverting inductively defined relations in LEGO. In Types for Proofs and Programs, 1998b. Conor McBride. Dependently typed functional programs and their proofs. PhD thesis, University of Edinburgh, 2000.Google ScholarGoogle Scholar
  18. Conor McBride. Elimination with a motive. In Types for proofs and programs, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Conor McBride. Epigram: Practical programming with dependent types. In Advanced Functional Programming, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Conor McBride, Healfdene Goguen, and James McKinna. A few constructions on constructors. In Types for Proofs and Programs, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. James McKinna and Fredrik Nordvall Forsberg. The encode-decode method, relationally. In Types for proofs and programs, 2015.Google ScholarGoogle Scholar
  22. Alexandre Miquel. Re: Agda with the excluded middle is inconsistent?, 2010.Google ScholarGoogle Scholar
  23. Ulf Norell. Towards a practical programming language based on dependent type theory. PhD thesis, Chalmers University of Technology, 2007.Google ScholarGoogle Scholar
  24. Daniel Peebles. Case splitting emits hidden record patterns that should remain implicit, 2012.Google ScholarGoogle Scholar
  25. Andrea Vezzosi. Heterogeneous equality incompatible with univalence even –without-K, 2015.Google ScholarGoogle Scholar

Index Terms

  1. Unifiers as equivalences: proof-relevant unification of dependently typed data

      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

      • Published in

        cover image ACM SIGPLAN Notices
        ACM SIGPLAN Notices  Volume 51, Issue 9
        ICFP '16
        September 2016
        501 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/3022670
        Issue’s Table of Contents
        • cover image ACM Conferences
          ICFP 2016: Proceedings of the 21st ACM SIGPLAN International Conference on Functional Programming
          September 2016
          501 pages
          ISBN:9781450342193
          DOI:10.1145/2951913

        Copyright © 2016 ACM

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 4 September 2016

        Check for updates

        Qualifiers

        • article

      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!