The Complexity of Type Inference for Higher-Order Typed lambda Calculi

We analyse the computational complexity of type inference for untyped λ-terms in the second-order polymorphic typed λ-calculus ( F 2 ) invented by Girard and Reynolds, as well as higher-order extensions F 3 , F 4 , …, F ω proposed by Girard. We prove that recognising the F 2 -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 F k -typable terms, where the bound for F k +1 is exponentially larger than that for F k . 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]  Luís Damas Type assignment in programming languages , 1984 .

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

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

[4]  J. Van Leeuwen,et al.  Handbook of theoretical computer science - Part A: Algorithms and complexity; Part B: Formal models and semantics , 1990 .

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

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

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

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

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

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

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

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

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

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

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

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

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

[18]  Paul Hudak,et al.  Realistic compilation by program transformation (detailed summary) , 1989, POPL '89.

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

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

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

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

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

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

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

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

[27]  Piergiorgio Odifreddi,et al.  Logic and computer science , 1990 .

[28]  Harry G. Mairson,et al.  The complexity of type inference for higher-order lambda calculi , 1991, POPL '91.

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

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

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

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

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

[34]  Jean-Louis Lassez,et al.  Computational logic: essays in honor of Alan Robinson , 1991 .

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

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

[37]  Jerzy Tiuryn,et al.  ML Typability is DEXTIME-Complete , 1990, CAAP.

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

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

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

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

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

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

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