Programmers can use gradual types to migrate programs to have more precise type annotations and thereby improve their readability, efficiency, and safety. Such migration requires an exploration of the migration space and can benefit from tool support, as shown in previous work. Our goal is to provide a foundation for better tool support by settling decidability questions about migration with gradual types. We present three algorithms and a hardness result for deciding key properties and we explain how they can be useful during an exploration. In particular, we show how to decide whether the migration space is finite, whether it has a top element, and whether it is a singleton. We also show that deciding whether it has a maximal element is NP-hard. Our implementation of our algorithms worked as expected on a suite of microbenchmarks.We can use those properties to classify programs into five increasingly larger sets. Figure 1 illustrates both how those sets are nested (top half) and the migration possibilities (bottom half). Each of (a)ś(e) shows the original program as a circle and, above it, possible migrations; maximal migrations are shown as bold circles.Our contributions. We present algorithms (with names in bold below) and a hardness result for deciding the four questions above for the gradually typed λ-calculus [Siek and Taha 2006].
Singleton problem:decidable in O(n 2 ) time (Theorem 3.5) Singleton Checker Top-choice problem: decidable in EXPTIME (Theorem 5.3) Top-Choice Checker Finiteness problem: decidable in EXPTIME (Theorem 4.11) Finiteness Checker Maximality problem: NP-hard (Theorem 6.1).