The complexity of type inference for higher-order lambda calculi

We analyse the computational complexity of type inference for untyped X,-terms in the secondorder polymorphic typed X-calculus (F2) invented by Girard and Reynolds, as well as higherorder extensions F3,F4, ...,/^ proposed by Girard. We prove that recognising the i^-typable terms requires exponential time, and for Fa the problem is non-elementary. We show as well a sequence of lower bounds on recognising the i^-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.

[1]  Benjamin C. Pierce,et al.  Programming in higher-order typed lambda-calculi , 1989 .

[2]  Peter Lee,et al.  LEAP: A Language with Eval And Polymorphism , 1989, TAPSOFT, Vol.2.

[3]  William W. Tait,et al.  Intensional interpretations of functionals of finite type I , 1967, Journal of Symbolic Logic.

[4]  J. Hartmanis,et al.  On the Computational Complexity of Algorithms , 1965 .

[5]  J. Gallier On Girard's "Candidats de Reductibilité" , 1989 .

[6]  John C. Reynolds,et al.  Towards a theory of type structure , 1974, Symposium on Programming.

[7]  Robin Milner,et al.  A Theory of Type Polymorphism in Programming , 1978, J. Comput. Syst. Sci..

[8]  Robin Milner,et al.  Principal type-schemes for functional programs , 1982, POPL '82.

[9]  S ScottDana Logic and programming languages , 1977 .

[10]  Helmat Schwichtenberg,et al.  Complexity of Normalization in the Pure Typed Lambda – Calculus , 1982 .

[11]  John C. Mitchell,et al.  Polymorphic unification and ML typing , 1989, POPL '89.

[12]  Andrew W. Appel,et al.  Continuation-passing, closure-passing style , 1989, POPL '89.

[13]  D. A. Turner,et al.  Miranda: A Non-Strict Functional language with Polymorphic Types , 1985, FPCA.

[14]  J. A. Robinson,et al.  A Machine-Oriented Logic Based on the Resolution Principle , 1965, JACM.

[15]  Fritz Henglein A lower bound for full polymorphic type inference: Girard-Reynolds Typability is DEXPTIME-hard , 1990 .

[16]  Paul Hudak,et al.  Realistic Compilation by Program Transformation. , 1989 .

[17]  Paola Giannini,et al.  Characterization of typings in polymorphic type discipline , 1988, [1988] Proceedings. Third Annual Information Symposium on Logic in Computer Science.

[18]  John C. Mitchell,et al.  On the Sequential Nature of Unification , 1984, J. Log. Program..

[19]  Jerzy Tiuryn,et al.  Type Reconstruction in Finite Rank Fragments of the Second-Order lambda-Calculus , 1992, Inf. Comput..

[20]  Jeffrey D. Ullman,et al.  Introduction to Automata Theory, Languages and Computation , 1979 .

[21]  Albert R. Meyer The inherent computational complexity of theories of ordered sets , 1974 .

[22]  J. Girard,et al.  Proofs and types , 1989 .

[23]  J. Y. Girard,et al.  Interpretation fonctionelle et elimination des coupures dans l'aritmetique d'ordre superieur , 1972 .

[24]  Robin Milner,et al.  Definition of standard ML , 1990 .

[25]  Joseph E. Stoy,et al.  Denotational Semantics: The Scott-Strachey Approach to Programming Language Theory , 1981 .

[26]  David S. Johnson,et al.  Computers and Intractability: A Guide to the Theory of NP-Completeness , 1978 .

[27]  Stephen A. Cook,et al.  The complexity of theorem-proving procedures , 1971, STOC.

[28]  R. Hindley The Principal Type-Scheme of an Object in Combinatory Logic , 1969 .

[29]  C. A. R. Hoare,et al.  The Varieties of Programming Language , 1989, TAPSOFT, Vol.1.

[30]  Harry G. Mairson Quantifier elimination and parametric polymorphism in programming languages , 1992, Journal of Functional Programming.

[31]  Frank Pfenning,et al.  Partial polymorphic type inference and higher-order unification , 1988, LISP and Functional Programming.

[32]  Mitchell Wand Correctness of Procedure Representations in Higher-Order Assembly Language , 1991, MFPS.

[33]  Richard Statman,et al.  The typed λ-calculus is not elementary recursive , 1977, 18th Annual Symposium on Foundations of Computer Science (sfcs 1977).

[34]  R. Ladner The circuit value problem is log space complete for P , 1975, SIGA.

[35]  Harry G. Mairson,et al.  Unification and ML-Type Reconstruction , 1991, Computational Logic - Essays in Honor of Alan Robinson.

[36]  J. Roger Hindley,et al.  Introduction to Combinators and Lambda-Calculus , 1986 .

[37]  John C. Mitchell,et al.  Type Systems for Programming Languages , 1991, Handbook of Theoretical Computer Science, Volume B: Formal Models and Sematics.

[38]  Luís Damas Type assignment in programming languages , 1984 .

[39]  Dana S. Scott,et al.  Logic and programming languages , 1977, CACM.

[40]  Harry G. Mairson Deciding ML typability is complete for deterministic exponential time , 1989, POPL '90.

[41]  P. J. Landin,et al.  The next 700 programming languages , 1966, CACM.

[42]  Mike Paterson,et al.  Linear unification , 1976, STOC '76.

[43]  E LadnerRichard The circuit value problem is log space complete for P , 1975 .

[44]  Richard Statman,et al.  The Typed lambda-Calculus is not Elementary Recursive , 1979, Theor. Comput. Sci..

[45]  Harry G. Mairson A Simple Proof of a Theorem of Statman , 1992, Theor. Comput. Sci..