Hostname: page-component-7479d7b7d-q6k6v Total loading time: 0 Render date: 2024-07-13T20:04:25.808Z Has data issue: false hasContentIssue false

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

Published online by Cambridge University Press:  07 November 2008

Fritz Henglein
Affiliation:
DIKU, University of Copenhagen, Universitetsparken 1, 2100 Copenhagen, Denmark
Harry G. Mairson
Affiliation:
Computer Science Department, Brandeis University, Waltham, MA 02254, USA
Rights & Permissions [Opens in a new window]

Abstract

Core share and HTML view are not available for this content. However, as you have access to this content, a full PDF is available via the ‘Save PDF’ action button.

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.

Type
Articles
Copyright
Copyright © Cambridge University Press 1994

References

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.CrossRefGoogle Scholar
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).Google Scholar
Cook, S.A. (1971) The complexity of theorem-proving procedures. In: Proc. 3rd Annual ACM Symposium on the Theory of Computing, pp. 151158.CrossRefGoogle Scholar
Damas, L. (1985) Type assignment in programming languages. PhD dissertation, CST-33-85, Computer Science Department, Edinburgh University.Google Scholar
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.CrossRefGoogle Scholar
Dwork, C., Kanellakis, P.C. and Mitchell, J.C. (1984) On the sequential nature of unification. J. Logic Programming 1:3550.CrossRefGoogle Scholar
Gallier, J. (1990) On Girard's ‘Candidats de Reducibilité’. In: Logic and Computer Science (Odifreddi, P., ed.), pp. 123203. Academic Press.Google Scholar
Garey, M.R. and Johnson, D.S. (1979) Computers and Intractibility: A Guide to the Theory of NP-Completeness. W.H. Freeman.Google Scholar
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.CrossRefGoogle Scholar
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.Google Scholar
Girard, J.-Y., Lafont, Y. and Taylor, P. (1989) Proofs and Types. Cambridge University Press.Google Scholar
Harper, R., Milner, R. and Tofte, M. (1990) The Definition of Standard ML. MIT Press.Google Scholar
Hartmanis, J. and Stearns, R.E. (1965) On the computational complexity of algorithms. Trans. American Math. Soc. 117: 285306.CrossRefGoogle Scholar
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.Google Scholar
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.Google Scholar
Hindley, R. (1969) The principal type scheme of an object in combinatory logic. Trans. American Math. Soc. 146:2960.Google Scholar
Hindley, J.R. and Seldin, J.P. (1986) Introduction to Combinators and Lambda Calculus. Cambridge University Press.Google Scholar
Hopcroft, J.E. and Ullman, J.D. (1979) Introduction to Automata Theory, Languages, and Computation. Addison-Wesley.Google Scholar
Hudak, P. and Wadler, P.L. (eds.) (1988) Report on the functional programming language Haskell. Yale University Technical Report YALEU/DCS/RR656.Google Scholar
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.)Google Scholar
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.Google Scholar
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.Google Scholar
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.)CrossRefGoogle Scholar
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.)Google Scholar
Ladner, R.E. (1975) The circuit value problem is log space complete for P. SIGACT News 7(1): 1820.CrossRefGoogle Scholar
Landin, P. (1966) The next 700 programming languages. Commun. ACM 9(3): 157166.CrossRefGoogle Scholar
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.CrossRefGoogle Scholar
Mairson, H.G. (1992 a)Quantifier elimination and parametric polymorphism in programming languages. J. Functional Programming 2(2): 213226, 04.CrossRefGoogle Scholar
Mairson, H.G. (1992b) A simple proof of a theory of Statman. Theoretical Computer Science 103: 387394.CrossRefGoogle Scholar
Meyer, A.R. (1974) The inherent computational complexity of theories of ordered sets. In: Proc. Int. Congress of Mathematicians, pp. 477482.Google Scholar
Milner, R. (1978) A theory of type polymorphism in programming. J. Computer and System Sciences 17: 348375.CrossRefGoogle Scholar
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.Google Scholar
Paterson, M.S. and Wegman, M.N. (1978) Linear unification. J. Computer and System Sciences 16: 158167.CrossRefGoogle Scholar
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.)Google Scholar
Pfenning, F. (1988) Partial polymorphic type inference and higher-order unification. In: Proc. ACM Conference on Lisp and Functional Programming, pp. 153163.CrossRefGoogle Scholar
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.Google Scholar
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.Google Scholar
Robinson, J.A. (1965) A machine oriented logic based on the resolution principle. J. ACM 12 (1): 2341.CrossRefGoogle Scholar
Sannella, D.T. (ed.) (1988) Postgraduate Examination Questions in Computation Theory, 1978–1988. Laboratory for Foundations of Computer Science, Report ECS-LFCS-88-64.Google Scholar
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.Google Scholar
Scott, D.S. (1977) Logic and programming languages. Commun. ACM 20 (9):634641.CrossRefGoogle Scholar
Statman, R. (1979) The typed λ-calculus is not elementary recursive. Theoretical Computer Science 9:7381.CrossRefGoogle Scholar
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.Google Scholar
Stoy, J. (1977) Denotational Semantics: The Scott-Strachey Approach to Programming Language Theory. MIT Press.Google Scholar
Strachey, C. (1973) The varieties of programming language. Technical Monograph PRG-10, Programming Research Group, Oxford University.Google Scholar
Tait, W.W. (1967) Intensional interpretation of functionals of finite type I. J. Symbolic Logic 32: 198212.CrossRefGoogle Scholar
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.CrossRefGoogle Scholar
Wand, M. (1989) A simple algorithm and proof for type inference. Fundamenta Informaticae 10.Google Scholar
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.Google Scholar
Submit a response

Discussions

No Discussions have been published for this article.