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.
- Andreas Abel. MiniAgda: Integrating sized and dependent types. In Workshop on Partiality and Recursion in Interactive Theorem Provers (PAR), 2010.Google Scholar
- Andreas Abel. Irrelevance in type theory with a heterogeneous equality judgement. In Foundations of Software Science and Computational Structures. 2011. Google Scholar
Digital Library
- Andreas Abel. Injectivity of type constructors is partially back. Agda refutes excluded middle, 2015a.Google Scholar
- Franz Baader and Wayne Snyder. Unification theory. Handbook of automated reasoning, 2001.Google Scholar
- Thomas Braibant. A new Coq tactic for inversion, 2013.Google Scholar
- Cyril Cohen, Thierry Coquand, Simon Huber, and Anders Mörtberg. Cubical type theory: a constructive interpretation of the univalence axiom, 2015.Google Scholar
- Preprint. Thierry Coquand. Pattern matching with dependent types. In Types for proofs and programs, 1992.Google Scholar
- Cristina Cornes and Delphine Terrasse. Automating inversion of inductive predicates in Coq. In Types for Proofs and Programs. 1995. Google Scholar
Digital Library
- Nils Anders Danielsson. Heterogenous equality is crippled by the Bool /= Fin 2 fix, 2010.Google Scholar
- Gabe Dijkstra. Disunifying non-fully applied constructors is inconsistent with function extensionality, 2015.Google Scholar
- Healfdene Goguen, Conor McBride, and James McKinna. Eliminating dependent pattern matching. In Algebra, Meaning, and Computation. 2006.Google Scholar
- 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 Scholar
- Chung-Kil Hur. Agda with the excluded middle is inconsistent?, 2010.Google Scholar
- 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 Scholar
Digital Library
- Zhaohui 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
- Per Martin-Löf. Intuitionistic type theory. Number 1 in Studies in Proof Theory. 1984.Google Scholar
- 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 Scholar
- Conor McBride. Elimination with a motive. In Types for proofs and programs, 2002. Google Scholar
Digital Library
- Conor McBride. Epigram: Practical programming with dependent types. In Advanced Functional Programming, 2005. Google Scholar
Digital Library
- Conor McBride, Healfdene Goguen, and James McKinna. A few constructions on constructors. In Types for Proofs and Programs, 2006. Google Scholar
Digital Library
- James McKinna and Fredrik Nordvall Forsberg. The encode-decode method, relationally. In Types for proofs and programs, 2015.Google Scholar
- Alexandre Miquel. Re: Agda with the excluded middle is inconsistent?, 2010.Google Scholar
- Ulf Norell. Towards a practical programming language based on dependent type theory. PhD thesis, Chalmers University of Technology, 2007.Google Scholar
- Daniel Peebles. Case splitting emits hidden record patterns that should remain implicit, 2012.Google Scholar
- Andrea Vezzosi. Heterogeneous equality incompatible with univalence even –without-K, 2015.Google Scholar
Index Terms
Unifiers as equivalences: proof-relevant unification of dependently typed data
Recommendations
Unifiers as equivalences: proof-relevant unification of dependently typed data
ICFP 2016: Proceedings of the 21st ACM SIGPLAN International Conference on Functional ProgrammingDependently 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, ...
Lifting proof-relevant unification to higher dimensions
CPP 2017: Proceedings of the 6th ACM SIGPLAN Conference on Certified Programs and ProofsIn a dependently typed language such as Coq or Agda, unification can be used to discharge equality constraints and detect impossible cases automatically. By nature of dependent types, it is necessary to use a proof-relevant unification algorithm where ...
Decidability of conversion for type theory in type theory
Type theory should be able to handle its own meta-theory, both to justify its foundational claims and to obtain a verified implementation. At the core of a type checker for intensional type theory lies an algorithm to check equality of types, or in ...







Comments