Abstract
Unification is the core of type inference algorithms for modern functional programming languages, like Haskell. As a first step towards a formalization of a type inference algorithm for such programming languages, we present a formalization in Coq of a type unification algorithm that follows classic algorithms presented in programming language textbooks.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Similar content being viewed by others
Notes
- 1.
Abbreviation of Brouwer, Heyting, Kolmogorov, de Bruijn and Martin-Löf Correspondence. This is also known as the Curry-Howard “isomorphism”.
- 2.
In Coq, we can use sections to delimit the scope of local variables.
- 3.
Kinds classify type expressions in the same way as types classify terms. More details about the use of kinds and high-order operators can be found in [13].
- 4.
According to the BHK-interpretation, a type is inhabited only if it represents a logic proposition that is provable.
- 5.
In type theory terminology, the unit type is a type that has a unique inhabitant and the empty type is a type that does not have inhabitants. Under BHK-interpretation, they correspond to a true and false propositions, respectively [20].
- 6.
A hole in a function definition is a subterm that is left unspecified. In Coq, holes are represented by underscores and such unspecified parts of a definition are usually filled by tactic generated terms.
- 7.
This tactic is defined on a tactic library developed by Arthur Charguraud [25].
- 8.
The default depth limit used by auto is 5.
References
Peyton Jones, S.: Haskell 98 Language and Libraries: The Revised Report. Cambridge University Press, Cambridge (2003)
Milner, R., Tofte, M., Harper, R.: Definition of Standard ML. MIT Press, Cambridge (1990)
Milner, R.: A theory of type polymorphism in programming. J. Comput. Syst. Sci. 17(3), 348–375 (1978)
Pottier, F., Rémy, D.: The essence of ML type inference. In: Pierce, B.C. (ed.) Advanced Topics in Types and Programming Languages, pp. 389–489. MIT Press, Cambridge (2005)
Robinson, J.A.: A machine-oriented logic based on the resolution principle. J. ACM 12(1), 23–41 (1965)
Bertot, Y., Castéran, P.: Interactive Theorem Proving and Program Development. Coq’Art: The Calculus of Inductive Constructions. Texts in Theoretical Computer Science. Springer, New York (2004)
Bove, A., Dybjer, P., Norell, U.: A brief overview of agda – a functional language with dependent types. In: Berghofer, S., Nipkow, T., Urban, C., Wenzel, M. (eds.) TPHOLs 2009. LNCS, vol. 5674, pp. 73–78. Springer, Heidelberg (2009)
Paulson, L.C.: Verifying the unification algorithm in lcf. CoRR cs.LO/9301101 (1993)
Bove, A.: Programming in Martin-Löf type theory: Unification - A non-trivial example. Licentiate Thesis of the Department of Computer Science, Chalmers University of Technology, November 1999
McBride, C.: First-order unification by structural recursion. J. Funct. Program. 13(6), 1061–1075 (2003)
Kothari, S., Caldwell, J.: A machine checked model of idempotent mgu axioms for lists of equational constraints. In: Fernandez, M. (ed.): Proceedings 24th International Workshop on Unification. EPTCS, vol. 42, pp. 24–38 (2010)
Mitchell, J.C.: Foundations of Programming Languages. MIT Press, Cambridge (1996)
Pierce, B.C.: Types and Programming Languages. MIT Press, Cambridge (2002)
McBride, C., McKinna, J.: The view from the left. J. Funct. Program. 14(1), 69–111 (2004)
Leroy, X.: Formal verification of a realistic compiler. Commun. ACM 52(7), 107–115 (2009)
Barthe, G., Dufay, G., Jakubiec, L., de Sousa, S.M.: A formal correspondence between offensive and defensive JavaCard virtual machines. In: Cortesi, A. (ed.) VMCAI 2002. LNCS, vol. 2294, p. 32. Springer, Heidelberg (2002)
Gonthier, G.: The four colour theorem: engineering of a formal proof. In: Kapur, D. (ed.) ASCM 2007. LNCS (LNAI), vol. 5081, pp. 333–333. Springer, Heidelberg (2008)
Gonthier, G.: Engineering mathematics: the odd order theorem proof. In: Giacobazzi, R., Cousot, R. (eds.) POPL, pp. 1–2. ACM (2013)
Ribeiro, R., et al.: A mechanized textbook proof of a type unification algorithm – on-line repository (2015). https://github.com/rodrigogribeiro/unification
Sørensen, M., Urzyczyn, P.: Lectures on the Curry-Howard Isomorphism. Studies in Logic and the Foundations of Mathematics, vol. 10. Elsevier (2006)
Chlipala, A.: Certified Programming with Dependent Types - A Pragmatic Introduction to the Coq Proof Assistant. MIT Press, Cambridge (2013)
de Bruijn, N.: Lambda calculus notation with nameless dummies, a tool for automatic formula manipulation, with application to the church-rosser theorem. Indagationes Mathematicae (Proceedings) 75(5), 381–392 (1972)
Charguéraud, A.: The locally nameless representation. J. Autom. Reason. 49(3), 363–408 (2012)
Coq Developement Team: Coq Proof Assistant – Reference Manual (2014). http://coq.inria.fr/distrib/current/refman//
Pierce, B.C., Casinghino, C., Gaboardi, M., Greenberg, M., Hriţcu, C., Sjoberg, V., Yorgey, B.: Software Foundations. Electronic textbook (2015)
Nordström, B.: Terminating general recursion. BIT Numer. Math. 28(3), 605–619 (1988)
McBride, C.: First-order unification by structural recursion – correctness proof
Naraschewski, W., Nipkow, T.: Type inference verified: algorithm w in isabelle/hol. J. Autom. Reason. 23(3), 299–318 (1999)
Avelar, A.B., de Moura, F.L.C., Galdino, A.L., Ayala-Rincón, M.: Verification of the completeness of unification algorithms à la Robinson. In: Queiroz, R., Dawar, A. (eds.) WoLLIC 2010. LNCS, vol. 6188, pp. 110–124. Springer, Heidelberg (2010)
Avelar, A.B., Galdino, A.L., de Moura, F.L.C., Ayala-Rincón, M.: First-order unification in the PVS proof assistant. Logic J. IGPL 22(5), 758–789 (2014)
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2016 Springer International Publishing Switzerland
About this paper
Cite this paper
Ribeiro, R., Camarão, C. (2016). A Mechanized Textbook Proof of a Type Unification Algorithm. In: Cornélio, M., Roscoe, B. (eds) Formal Methods: Foundations and Applications. SBMF 2015. Lecture Notes in Computer Science(), vol 9526. Springer, Cham. https://doi.org/10.1007/978-3-319-29473-5_8
Download citation
DOI: https://doi.org/10.1007/978-3-319-29473-5_8
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-319-29472-8
Online ISBN: 978-3-319-29473-5
eBook Packages: Computer ScienceComputer Science (R0)