|
ABSTRACT
We study the complexity of type inference for programming languages with subtypes. There are three language variations that effect the problem: (i) basic functions may have polymorphic or more limited types, (ii) the subtype hierarchy may be fixed or vary as a result of subtype declarations within a program, and (iii) the subtype hierarchy may be an arbitrary partial order or may have a more restricted form, such as a tree or lattice. The naive algorithm for infering a most general polymorphic type, undervariable subtype hypotheses, requires deterministic exponential time. If we fix the subtype ordering, this upper bound grows to nondeterministic exponential time. We show that it is NP-hard to decide whether a lambda term has a type with respect to a fixed subtype hierarchy (involving only atomic type names). This lower bound applies to monomorphic or polymorphic languages. We give PSPACE upper bounds for deciding polymorphic typability if the subtype hierarchy has a lattice structure or the subtype hierarchy varies arbitrarily. We also give a polynomial time algorithm for the limited case where there are of no function constants and the type hierarchy is either variable or any fixed lattice.
REFERENCES
Note: OCR errors may be found in this Reference List extracted from the full text article. ACM has opted to expose the complete List rather than only correct and linked references.
| |
FM90
|
|
| |
Hin89
|
|
| |
Jat89
|
L. Jategaonkar. ML with extended pattern matching and subtypes. Master's thesis, MIT, 1989.
|
 |
JM88
|
|
| |
KMM91
|
P.C. Kanell~kis, H.G. Mairson, and J.C. Mitchell. Unification and ML type reconstruction. In Computational Logic, essays in honor of Alan Robinson, page to appear. MIT Press, 1991.
|
| |
Mey88
|
|
 |
Mit84
|
|
| |
Mit91
|
J.C. Mitchell. Type inference with simple subtypes. J. Functional Programming, 1(3):245- 286, 1991.
|
| |
PT91
|
V. Pratt and J. Tiuryn. Satisfiability of inequations in a poser. Manuscript, October 1991.
|
| |
PW78
|
M.S. Paterson and M.N. Wegman. Linear unification. JCSS, 16:158-167, 1978.
|
| |
Str86
|
|
| |
Tiu91
|
J. Tiuryn. Solving term inequalities is PSPACE- hard. Manuscript, October 1991.
|
| |
Wan87
|
M. Wand. A simple algorithm and proof for type inference. Fundamcnta Informaticae, 10:115-122, 1987.
|
| |
Wan91
|
M. Wand. Personal communication, 1991.
|
 |
WO89
|
|
|