Skip to main content Accessibility help

The complexity of type inference for higher-order typed lambda calculi

  • Fritz Henglein (a1) and Harry G. Mairson (a2)


We analyse the computational complexity of type inference for untyped λ-terms in the second-order polymorphic typed λ-calculus (F2) invented by Girard and Reynolds, as well as higher-order extensions F3, F4, …, Fω proposed by Girard. We prove that recognising the F2-typable terms requires exponential time, and for Fω the problem is non-elementary. We show as well a sequence of lower bounds on recognising the Fk-typable terms, where the bound for Fk+1 is exponentially larger than that for Fk.

The lower bounds are based on generic simulation of Turing Machines, where computation is simulated at the expression and type level simultaneously. Non-accepting computations are mapped to non-normalising reduction sequences, and hence non-typable terms. The accepting computations are mapped to typable terms, where higher-order types encode reduction sequences, and first-order types encode the entire computation as a circuit, based on a unification simulation of Boolean logic. A primary technical tool in this reduction is the composition of polymorphic functions having different domains and ranges.

These results are the first nontrivial lower bounds on type inference for the Girard/Reynolds system as well as its higher-order extensions. We hope that the analysis provides important combinatorial insights which will prove useful in the ultimate resolution of the complexity of the type inference problem.



Hide All
Appel, A.W. and Jim, T. (1989) Continuation-passing, closure-passing style. In: Proc. 16th ACM Symposium on the Principles of Programming Languages, pp. 293302, 01.
Cardelli, L. (1989) Typeful programming. Lecture Notes for the IFIP Advanced Seminar on Formal Methods in Programming Language Semantics, Rio de Janeiro, Brazil (see also SRC Report 45, Digital Equipment Corporation).
Cook, S.A. (1971) The complexity of theorem-proving procedures. In: Proc. 3rd Annual ACM Symposium on the Theory of Computing, pp. 151158.
Damas, L. (1985) Type assignment in programming languages. PhD dissertation, CST-33-85, Computer Science Department, Edinburgh University.
Damas, L. and Milner, R. (1982) Principal type schemes for functional programs. In: Proc. 9th ACM Symposium on Principles of Programming Languages, pp. 207212, 01.
Dwork, C., Kanellakis, P.C. and Mitchell, J.C. (1984) On the sequential nature of unification. J. Logic Programming 1:3550.
Gallier, J. (1990) On Girard's ‘Candidats de Reducibilité’. In: Logic and Computer Science (Odifreddi, P., ed.), pp. 123203. Academic Press.
Garey, M.R. and Johnson, D.S. (1979) Computers and Intractibility: A Guide to the Theory of NP-Completeness. W.H. Freeman.
Giannini, P. and Ronchi Della Rocca, S. (1988) Characterization of typings in polymorphic type discipline. In: Proc. 3rd IEEE Symposium on Logic in Computer Science, pp. 6170, 07.
Girard, J.-Y. (1972) Interprétation Fonctionnelle et Elimination des Coupures de l'Arithmétique d'Ordre Supérieur. Thèse de Doctorat d'Etat, Université de Paris VII.
Girard, J.-Y., Lafont, Y. and Taylor, P. (1989) Proofs and Types. Cambridge University Press.
Harper, R., Milner, R. and Tofte, M. (1990) The Definition of Standard ML. MIT Press.
Hartmanis, J. and Stearns, R.E. (1965) On the computational complexity of algorithms. Trans. American Math. Soc. 117: 285306.
Henglein, F. (1990) A lower bound for full polymorphic type inference: Girard/Reynolds typability is DEXPTIME-hard. University of Utrecht, Technical Report RUU-CS-90-14, April.
Henglein, F. and Mairson, H.G. (1991) The complexity of type inference for higher-order typed lambda calculi. In. Proc. 18th ACM Symposium on the Principles of Programming Languages, pp. 119130, 01.
Hindley, R. (1969) The principal type scheme of an object in combinatory logic. Trans. American Math. Soc. 146:2960.
Hindley, J.R. and Seldin, J.P. (1986) Introduction to Combinators and Lambda Calculus. Cambridge University Press.
Hopcroft, J.E. and Ullman, J.D. (1979) Introduction to Automata Theory, Languages, and Computation. Addison-Wesley.
Hudak, P. and Wadler, P.L. (eds.) (1988) Report on the functional programming language Haskell. Yale University Technical Report YALEU/DCS/RR656.
Kanellakis, P.C. and Mitchell, J.C. (1989) Polymorphic unification and ML typing. Brown University Technical Report CS-89-40, 08 1989. (Also in Proc. 16th ACM Symposium on the Principles of Programming Languages, pp. 105115, January.)
Kanellakis, P.C., Mairson, H.G. and Mitchell, J.C. (1991) Unification and ML type reconstruction. In: Computational Logic: Essays in Honor of Alan Robinson. (Lassez, J.-L. and Plotkin, G. eds.). MIT Press.
Kelsey, R. and Hudak, P. (1989) Realistic Compilation by Program Transformation. In: Proc. 16th ACM Symposium on the Principles of Programming Languages, pp. 281292, 01.
Kfoury, A.J., Tiuryn, J. and Urzyczyn, P. (1990) ML typability is DEXPTIME-complete. In: Proc. 15th Colloquium on Trees in Algebra and Programming, 05. (See also Boston University Technical Report, October 1989.)
Kfoury, A.J. and Tiuryn, J. (1990) Type reconstruction in finite rank fragments of the second-order lambda calculus. Technical Report BUCS 89-11, Boston University, 10. (Also in Proc. 5th IEEE Symposium on Logic in Computer Science, pp. 211, June.)
Ladner, R.E. (1975) The circuit value problem is log space complete for P. SIGACT News 7(1): 1820.
Landin, P. (1966) The next 700 programming languages. Commun. ACM 9(3): 157166.
Mairson, H.G. (1990) Deciding ML typability is complete for deterministic exponential time. In: Proc. 17th ACM Symposium on the Principles of Programming Languages, pp. 382401, 01.
Mairson, H.G. (1992 a)Quantifier elimination and parametric polymorphism in programming languages. J. Functional Programming 2(2): 213226, 04.
Mairson, H.G. (1992b) A simple proof of a theory of Statman. Theoretical Computer Science 103: 387394.
Meyer, A.R. (1974) The inherent computational complexity of theories of ordered sets. In: Proc. Int. Congress of Mathematicians, pp. 477482.
Milner, R. (1978) A theory of type polymorphism in programming. J. Computer and System Sciences 17: 348375.
Mitchell, J.C. (1990) Type systems for programming languages. In: Handbook of Theoretical Computer Science, vol. B, pp. 365468 (van Leeuwen, J. et al. , eds). North-Holland.
Paterson, M.S. and Wegman, M.N. (1978) Linear unification. J. Computer and System Sciences 16: 158167.
Pfenning, F. and Lee, P. (1989) LEAP: a language with eval and polymorphism. In: TAPSOFT 1989: Proc. Int. Joint Conference on Theory and Practice in Software Development,Barcelona,Spain. (See also CMU Ergo Report 88–065.)
Pfenning, F. (1988) Partial polymorphic type inference and higher-order unification. In: Proc. ACM Conference on Lisp and Functional Programming, pp. 153163.
Pierce, B., Dietzen, S. and Michaylov, S. (1989) Programming in higher-order typed lambda calculi. Technical Report CMU-CS-89-111, Carnegie Mellon University, 03.
Reynolds, J.C. (1974) Towards a theory of type structure. In Proc. Paris Colloquium on Programming: Lecture Notes in Computer Science 19, pp. 408425. Springer-Verlag.
Robinson, J.A. (1965) A machine oriented logic based on the resolution principle. J. ACM 12 (1): 2341.
Sannella, D.T. (ed.) (1988) Postgraduate Examination Questions in Computation Theory, 1978–1988. Laboratory for Foundations of Computer Science, Report ECS-LFCS-88-64.
Schwichtenberg, H. (1982) Complexity of normalisation in the pure typed lambda calculus. In: The L. E. J. Brouwer Centenary Symposium (Troelstra, A.S. and van Dalen, D., eds.), pp. 453457. North-Holland.
Scott, D.S. (1977) Logic and programming languages. Commun. ACM 20 (9):634641.
Statman, R. (1979) The typed λ-calculus is not elementary recursive. Theoretical Computer Science 9:7381.
Stockmeyer, L.J. and Meyer, A.R. (1973) Word problems requiring exponential time. In: Proc. 5th Annual ACM Symposium on Theory of Computing, pp. 19.
Stoy, J. (1977) Denotational Semantics: The Scott-Strachey Approach to Programming Language Theory. MIT Press.
Strachey, C. (1973) The varieties of programming language. Technical Monograph PRG-10, Programming Research Group, Oxford University.
Tait, W.W. (1967) Intensional interpretation of functionals of finite type I. J. Symbolic Logic 32: 198212.
Turner, D.A. (1985) Miranda: A non-strict functional language with polymorphic types. In: IFIP Int. Conference on Functional Programming and Computer Architecture: Lecture Notes in Computer Science 201, pp. 116. Springer-Verlag.
Wand, M. (1989) A simple algorithm and proof for type inference. Fundamenta Informaticae 10.
Wand, M. (1992) Correctness of Procedure Representations in Higher-Order Assembly Language. In: Mathematical Foundations of Programming Language Semantics 1991: Lecture Notes in Computer Science 598, (Brookes, S., ed.), pp. 294311. Springer-Verlag.

The complexity of type inference for higher-order typed lambda calculi

  • Fritz Henglein (a1) and Harry G. Mairson (a2)


Full text views

Total number of HTML views: 0
Total number of PDF views: 0 *
Loading metrics...

Abstract views

Total abstract views: 0 *
Loading metrics...

* Views captured on Cambridge Core between <date>. This data will be updated every 24 hours.

Usage data cannot currently be displayed

The complexity of type inference for higher-order typed lambda calculi

  • Fritz Henglein (a1) and Harry G. Mairson (a2)
Submit a response


No Discussions have been published for this article.


Reply to: Submit a response

Your details

Conflicting interests

Do you have any conflicting interests? *