A well known but incorrect piece of functional programming folklore is that ML expressions can be efficiently typed in polynomial time. In probing the truth of that folklore, various researchers, including Wand, Buneman, Kanellakis, and Mitchell, constructed simple counterexamples consisting of typable ML programs having length n, with principal types having &OHgr;(2cn) distinct type variables and length &OHgr;(22cn). When the types associated with these ML constructions were represented as directed acyclic graphs, their sizes grew as &OHgr;(2cn). The folklore was even more strongly contradicted by the recent result of Kanellakis and Mitchell that simply deciding whether or not an ML expression is typable is PSPACE-hard.
We improve the latter result, showing that deciding ML typability is DEXPTIME-hard. As Kanellakis and Mitchell have shown containment in DEXPTIME, the problem is DEXPTIME-complete. The proof of DEXPTIME-hardness is carried out via a generic reduction: it consists of a very straightforward simulation of any deterministic one-tape Turing machine M with input &khgr; running in &Ogr;(c|&khgr;|) time by a polynomial-sized ML formula &PHgr;M,&khgr;, such that M accepts &khgr; iff &PHgr;M,&khgr; is typable. The simulation of the transition function δ of the Turing Machine is realized uniquely through terms in the lambda calculus without the use of the polymorphic let construct. We use let for two purposes only: to generate an exponential amount of blank tape for the Turing Machine simulation to begin, and to compose an exponential number of applications of the ML formula simulating state transition.
It is purely the expressive power of ML polymorphism to succinctly express function composition which results in a proof of DEXPTIME-hardness. We conjecture that lower bounds on deciding typability for extensions to the typed lambda calculus can be regarded precisely in terms of this expressive capacity for succinct function composition.
To further understand this lower bound, we relate it to the problem of proving equality of type variables in a system of type equations generated from an ML expression with let-polymorphism. We show that given an oracle for solving this problem, deciding typability would be in PSPACE, as would be the actual computation of the principal type of the expression, were it indeed typable.
[1]
Gerald J. Sussman,et al.
Structure and interpretation of computer programs
,
1985,
Proceedings of the IEEE.
[2]
Frank Pfenning,et al.
Partial polymorphic type inference and higher-order unification
,
1988,
LISP and Functional Programming.
[3]
Jerzy Tiuryn,et al.
The undecidability of the semi-unification problem
,
1990,
STOC '90.
[4]
Alfred V. Aho,et al.
The Design and Analysis of Computer Algorithms
,
1974
.
[5]
John C. Mitchell,et al.
On the Sequential Nature of Unification
,
1984,
J. Log. Program..
[6]
Jeffrey D. Ullman,et al.
Introduction to Automata Theory, Languages and Computation
,
1979
.
[7]
Robin Milner,et al.
A Theory of Type Polymorphism in Programming
,
1978,
J. Comput. Syst. Sci..
[8]
John C. Mitchell,et al.
Polymorphic unification and ML typing
,
1989,
POPL '89.
[9]
Harry B. Hunt,et al.
The Equivalence Problem for Regular Expressions with Intersection is Not Polynomial in Tape
,
1973
.
[10]
J. Girard,et al.
Proofs and types
,
1989
.
[11]
Walter J. Savitch,et al.
Relationships Between Nondeterministic and Deterministic Tape Complexities
,
1970,
J. Comput. Syst. Sci..