an:07179881
Zbl 1435.68059
Juma, Nahid; Dietl, Werner; Tripunitara, Mahesh
A computational complexity analysis of tunable type inference for Generic Universe Types
EN
Theor. Comput. Sci. 814, 189-209 (2020).
00447884
2020
j
68N15 68N19 68Q17 68Q25 68R07
computational complexity; programming languages; Java; type inference; type systems; object ownership; NP-hardness
Summary: We address questions related to the computational complexity of inferring types for a particular type system, Generic Universe Types (GUT), for Java programs. GUT is useful for many applications, such as program verification, thread synchronization, and memory management. However, requiring the programmer to explicitly provide type information is onerous, which motivates the problem of automatically inferring types. In contrast to classical type systems, ownership type systems such as GUT may have multiple typings that satisfy the type system's rules. It is therefore appropriate for the inference to be tunable -- that is, the programmer can indicate preferences for certain typings via breakable constraints and/or by partial annotations. A question then is whether efficient algorithms exist for the type inference problem. In this work we establish the following results for the type inference problem for GUT [\textit{W. Dietl} et al., Lect. Notes Comput. Sci. 6813, 333--357 (2011; Zbl 1435.68061)]. (1) The tunable type inference problem that allows breakable constraints is \textbf{NP}-hard, (2) an encoding of the problem as Boolean satisfiability (SAT), as in prior work, is indeed a polynomial-time reduction, (3) \(\mathbf{P} \neq \mathbf{NP}\) implies that the problem is not approximable in polynomial time within an approximation ratio of \(n^{1 - \epsilon}\) for any \(\epsilon > 0\), and (4) while some restricted versions of the problem of practical interest, such as when breakable constraints are forbidden, are in \textbf{P}, others remain \textbf{NP}-hard. Our results justify the prior approach to the problem that is based on reduction to SAT. Apart from these results, given the observation in prior work that instances of the problem that arise in practice appear to be easy, we address the natural question as to what hard instances may look like, and whether they may arise in practice. We identify a class of hard instances of the problem by devising a method to generate such instances starting at instances of the Vertex Cover problem, which is known to be \textbf{NP}-hard. We then analyze the structural properties of such instances as compared to easy instances of similar size. We find that for the classes of instances we consider, certain SAT structural parameters may be predictive of empirical hardness.
Zbl 1435.68061