Skip to main content

A Mechanized Textbook Proof of a Type Unification Algorithm

  • Conference paper
  • First Online:
Formal Methods: Foundations and Applications (SBMF 2015)

Part of the book series: Lecture Notes in Computer Science ((LNPSE,volume 9526))

Included in the following conference series:

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 34.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 44.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    Abbreviation of Brouwer, Heyting, Kolmogorov, de Bruijn and Martin-Löf Correspondence. This is also known as the Curry-Howard “isomorphism”.

  2. 2.

    In Coq, we can use sections to delimit the scope of local variables.

  3. 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. 4.

    According to the BHK-interpretation, a type is inhabited only if it represents a logic proposition that is provable.

  5. 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. 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. 7.

    This tactic is defined on a tactic library developed by Arthur Charguraud [25].

  8. 8.

    The default depth limit used by auto is 5.

References

  1. Peyton Jones, S.: Haskell 98 Language and Libraries: The Revised Report. Cambridge University Press, Cambridge (2003)

    Google Scholar 

  2. Milner, R., Tofte, M., Harper, R.: Definition of Standard ML. MIT Press, Cambridge (1990)

    Google Scholar 

  3. Milner, R.: A theory of type polymorphism in programming. J. Comput. Syst. Sci. 17(3), 348–375 (1978)

    Article  MathSciNet  MATH  Google Scholar 

  4. 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)

    Google Scholar 

  5. Robinson, J.A.: A machine-oriented logic based on the resolution principle. J. ACM 12(1), 23–41 (1965)

    Article  MATH  Google Scholar 

  6. 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)

    Google Scholar 

  7. 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)

    Chapter  Google Scholar 

  8. Paulson, L.C.: Verifying the unification algorithm in lcf. CoRR cs.LO/9301101 (1993)

    Google Scholar 

  9. 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

    Google Scholar 

  10. McBride, C.: First-order unification by structural recursion. J. Funct. Program. 13(6), 1061–1075 (2003)

    Article  MathSciNet  MATH  Google Scholar 

  11. 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)

    Google Scholar 

  12. Mitchell, J.C.: Foundations of Programming Languages. MIT Press, Cambridge (1996)

    Google Scholar 

  13. Pierce, B.C.: Types and Programming Languages. MIT Press, Cambridge (2002)

    Google Scholar 

  14. McBride, C., McKinna, J.: The view from the left. J. Funct. Program. 14(1), 69–111 (2004)

    Article  MathSciNet  MATH  Google Scholar 

  15. Leroy, X.: Formal verification of a realistic compiler. Commun. ACM 52(7), 107–115 (2009)

    Article  Google Scholar 

  16. 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)

    Chapter  Google Scholar 

  17. 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)

    Chapter  Google Scholar 

  18. Gonthier, G.: Engineering mathematics: the odd order theorem proof. In: Giacobazzi, R., Cousot, R. (eds.) POPL, pp. 1–2. ACM (2013)

    Google Scholar 

  19. Ribeiro, R., et al.: A mechanized textbook proof of a type unification algorithm – on-line repository (2015). https://github.com/rodrigogribeiro/unification

  20. Sørensen, M., Urzyczyn, P.: Lectures on the Curry-Howard Isomorphism. Studies in Logic and the Foundations of Mathematics, vol. 10. Elsevier (2006)

    Google Scholar 

  21. Chlipala, A.: Certified Programming with Dependent Types - A Pragmatic Introduction to the Coq Proof Assistant. MIT Press, Cambridge (2013)

    Google Scholar 

  22. 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)

    Article  MATH  Google Scholar 

  23. Charguéraud, A.: The locally nameless representation. J. Autom. Reason. 49(3), 363–408 (2012)

    Article  MATH  Google Scholar 

  24. Coq Developement Team: Coq Proof Assistant – Reference Manual (2014). http://coq.inria.fr/distrib/current/refman//

  25. Pierce, B.C., Casinghino, C., Gaboardi, M., Greenberg, M., Hriţcu, C., Sjoberg, V., Yorgey, B.: Software Foundations. Electronic textbook (2015)

    Google Scholar 

  26. Nordström, B.: Terminating general recursion. BIT Numer. Math. 28(3), 605–619 (1988)

    Article  MATH  Google Scholar 

  27. McBride, C.: First-order unification by structural recursion – correctness proof

    Google Scholar 

  28. Naraschewski, W., Nipkow, T.: Type inference verified: algorithm w in isabelle/hol. J. Autom. Reason. 23(3), 299–318 (1999)

    Article  MathSciNet  MATH  Google Scholar 

  29. 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)

    Chapter  Google Scholar 

  30. 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)

    Article  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Rodrigo Ribeiro .

Editor information

Editors and Affiliations

Rights and permissions

Reprints 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)

Publish with us

Policies and ethics