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

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.

[1]  James McKinna,et al.  The encode-decode method, relationally , 2015 .

[2]  Paliath Narendran,et al.  Unification Theory , 2001, Handbook of Automated Reasoning.

[3]  Claude Kirchner,et al.  Solving Equations in Abstract Algebras: A Rule-Based Survey of Unification , 1991, Computational Logic - Essays in Honor of Alan Robinson.

[4]  Andreas Abel Irrelevance in Type Theory with a Heterogeneous Equality Judgement , 2011, FoSSaCS.

[5]  P. Dybjer Inductive sets and families in Martin-Lo¨f's type theory and their set-theoretic semantics , 1991 .

[6]  Conor McBride,et al.  Eliminating Dependent Pattern Matching , 2006, Essays Dedicated to Joseph A. Goguen.

[7]  Joseph A. Goguen,et al.  What Is Unification?: A Categorical View of Substitution, Equation and Solution , 1989 .

[8]  Conor McBride,et al.  Epigram: Practical Programming with Dependent Types , 2004, Advanced Functional Programming.

[9]  Jaap van Oosten,et al.  The Univalent Foundations Program. Homotopy Type Theory: Univalent Foundations of Mathematics. http: //homotopytypetheory.org/book, Institute for Advanced Study, 2013, vii + 583 pp , 2014, Bulletin of Symbolic Logic.

[10]  Conor McBride,et al.  Elimination with a Motive , 2000, TYPES.

[11]  Daniel R. Licata,et al.  Calculating the Fundamental Group of the Circle in Homotopy Type Theory , 2013, 2013 28th Annual ACM/IEEE Symposium on Logic in Computer Science.

[12]  Per Martin-Löf,et al.  Intuitionistic type theory , 1984, Studies in proof theory.

[13]  Zhaohui Luo,et al.  Computation and reasoning - a type theory for computer science , 1994, International series of monographs on computer science.

[14]  U. Norell,et al.  Towards a practical programming language based on dependent type theory , 2007 .

[15]  Conor McBride,et al.  A Few Constructions on Constructors , 2004, TYPES.

[16]  Andreas Abel,et al.  MiniAgda: Integrating Sized and Dependent Types , 2010, PAR@ITP.

[17]  Franz Baader,et al.  Unification theory , 1986, Decis. Support Syst..

[18]  J. Monin Proof Trick: Small Inversions , 2010 .

[19]  Dominique Devriese,et al.  Pattern matching without K , 2014, ICFP.

[20]  Conor McBride,et al.  Dependently typed functional programs and their proofs , 2000 .

[21]  Thierry Coquand,et al.  Cubical Type Theory: A Constructive Interpretation of the Univalence Axiom , 2015, TYPES.

[22]  Matthieu Sozeau,et al.  A unification algorithm for Coq featuring universe polymorphism and overloading , 2015, ICFP.

[23]  Cristina Cornes,et al.  Automating Inversion of Inductive Predicates in Coq , 1995, TYPES.

[24]  Jeremy Avigad,et al.  The Lean Theorem Prover (System Description) , 2015, CADE.

[25]  Thierry Coquand,et al.  Pattern Matching with Dependent Types , 1992 .

[26]  Conor McBride,et al.  Inverting Inductively Defined Relations in LEGO , 1996, TYPES.

[27]  Andrea Asperti,et al.  Hints in Unification , 2009, TPHOLs.