Skip to main content Accessibility help
  • Get access
    Check if you have access via personal or institutional login
  • Cited by 5
  • Print publication year: 2009
  • Online publication date: August 2010

16 - Nominal verification of algorithm W



The Milner-Damas typing algorithm W is one of the classic algorithms in computer science. In this paper we describe a formalized soundness and completeness proof for this algorithm. Our formalization is based on names for both term and type variables, and is carried out in Isabelle/HOL using the Nominal Datatype Package. It turns out that in our formalization we have to deal with a number of issues that are often overlooked in informal presentations of W.

Alpha-conversion always bites you when you least expect it.”

A remark made by Xavier Leroy when discussing with us the informal proof about W in his PhD thesis.


Milner's polymorphic type system for ML is probably the most influential programming language type system. The second author learned about it from a paper by Clément et al. He was immediately taken by their view that type inference can be viewed as Prolog execution, in particular because the Isabelle system, which he had started to work on, was based on a similar paradigm as the Typol language developed by Kahn and his coworkers. Milner himself had provided the explicit type inference algorithm W and proved its soundness. Completeness was later shown by Damas and Milner. Neither soundness nor completeness of W are trivial because of the presence of the Let-construct (which is not expanded during type inference).

[1]D., Clément, J., Despeyroux, T., Despeyroux, L., Hascoet and G., Kahn. Natural semantics on the computer. In K., Fuchi and M., Nivat (eds), Proceedings of the France-Japan AI and CS Symposium, ICOT, Japan, pp. 49–89, 1986. Also Technical Memorandum PL-86-6 Information Processing Society of Japan and Rapport de recherche #0416, INRIA.
[2]D., Clément, J., Despeyroux, T., Despeyroux and G., Kahn. A simple applicative language: Mini-ML. In Proc. ACM Conf. Lisp and Functional Programming, pp. 13–27, 1986.
[3]L., Damas. Type Assignment in Programming Languages. PhD thesis, University of Edinburgh, 1984.
[4]L., Damas and R., Milner. Principal type schemes for functional programs. In Proc. 9th ACM Symp. Principles of Programming Languages, pp. 207–212, 1982.
[5]C., Dubois and V., Ménissier-Morain. Certification of a type inference tool for ML: Damas-Milner within Coq. Journal of Automated Reasoning, 23:319–346, 1999.
[6]C. A., Gunter. Semantics of Programming Languages. MIT Press, 1992.
[7]X., Leroy. Polymorphic Typing of an Algorithmic Language. PhD thesis, University Paris 7, 1992. INRIA Research Report, No 1778.
[8]R., Milner. A theory of type polymorphism in programming. Journal of Computer Systems Science, 17:348–375, 1978.
[9]W., Naraschewski and T., Nipkow. Type inference verified: Algorithm W in Isabelle/HOL. Journal of Automated Reasoning, 23:299–318, 1999.
[10]T., Nipkow and L. C., Paulson. Proof pearl: Defining functions over finite sets. In J., Hurd (ed.) Theorem Proving in Higher Order Logics (TPHOLs 2005), volume 3603, Lecture Notes in Computer Science, pp. 385–396. Springer-Verlag, 2005.
[11]A. M., Pitts. Nominal logic, A first order theory of names and binding. Information and Computation, 186:165–193, 2003.
[12]A. M., Pitts and M. J., Gabbay. A metalanguage for programming with bound names modulo renaming. In Proc. of the 5th International Conference on Mathematics of Program Construction (MPC), volume 1837, Lecture Notes in Computer Science, pp. 230–255. Springer-Verlag, 2000.
[13]M., Tofte. Operational Semantics and Polymorphic Type Inference. PhD thesis. Edinburgh University, 1988.
[14]C., Urban and S., Berghofer. A recursion combinator for nominal datatypes implemented in Isabelle/HOL. In Proc. of the 3rd International Joint Conference on Automated Reasoning (IJCAR), volume 4130, Lecture Notes in Artificial Intelligence, pp. 498–512. Springer-Verlag, 2006.
[15]C., Urban, S., Berghofer and M., Norrish. Barendregt's variable convention in rule inductions. In Proc. of the 21th International Conference on Automated Deduction (CADE), volume 4603, Lecture Notes in Artificial Intelligence, pp. 35–50. Springer-Verlag, 2007.
[16]C., Urban and C., Tasson. Nominal Techniques in Isabelle/HOL. In Proc. of the 20th International Conference on Automated Deduction (CADE), volume 3632, Lecture Notes in Computer Science, pp. 38–53, Springer-Verlag, 2005.