Semi-continuous Sized Types and Termination
Some type-based approaches to termination use sized types: an ordinal bound for the size of a data structure is stored in its type. A recursive function over a sized type is accepted if it is visible in the type system that recursive calls occur just at a smaller size. This approach is only sound if the type of the recursive function is admissible, i.e., depends on the size index in a certain way. To explore the space of admissible functions in the presence of higher-kinded data types and impredicative polymorphism, a semantics is developed where sized types are interpreted as functions from ordinals into sets of strongly normalizing terms. It is shown that upper semi-continuity of such functions is a sufficient semantic criterion for admissibility. To provide a syntactical criterion, a calculus for semi-continuous functions is developed.
💡 Research Summary
**
The paper investigates a type‑based approach to guaranteeing termination of recursive programs by means of sized types. A sized type is a data type annotated with an ordinal index that bounds the size of the objects it describes. Traditional sized‑type systems require that the type of a recursive function be admissible: the type must depend on the size index in a way that ensures each recursive call is made at a strictly smaller index. In earlier work admissibility was essentially equivalent to monotonicity of the type‑level function mapping indices to sets of terms. This monotonicity condition, however, is too restrictive for many useful higher‑order and polymorphic constructions, such as the generic equality function for generalized rose trees (GRose) or types involving co‑variant and contra‑variant positions simultaneously.
To overcome this limitation the authors develop a semantic model in which a sized type A is interpreted as a function ⟦A⟧ from ordinals to saturated sets of strongly normalising terms. A saturated set is closed under β‑reduction, η‑expansion and contains all strongly normalising terms of the appropriate shape. Within this model, the crucial observation is that upper semi‑continuity of ⟦A⟧ is sufficient for admissibility in the limit case of transfinite induction. Upper semi‑continuity means that for any limit ordinal λ, the lim‑sup of the sets ⟦A⟧(α) for α<λ is included in ⟦A⟧(λ). Intuitively, if the type behaves “nicely” when the index approaches a limit, one can infer the existence of a fixed point at λ from the induction hypothesis for all smaller indices. Dually, lower semi‑continuity (lim‑inf inclusion) is required for types appearing in covariant positions.
The paper systematically derives composition rules for semi‑continuous types. For basic constructors the rules are straightforward: natural number types Nat α are upper semi‑continuous; function types A → B are admissible when the domain A is lower semi‑continuous and the codomain B is upper semi‑continuous; product and sum types preserve the appropriate continuity of their components; universal quantification ∀X. A inherits the continuity of A. For inductive (µ) and co‑inductive (ν) fixed points the authors prove that if the underlying functor H is monotone and upper semi‑continuous, then the fixed point type µX. H X (or νX. H X) is also upper semi‑continuous. This result allows the treatment of higher‑kinded data types such as GRose F A = µX. 1 + (A × F X), provided the functor F itself is upper semi‑continuous.
Having established the semantic criteria, the authors present a syntactic calculus that tracks continuity information through type derivations. Types are annotated with polarity symbols (↑ for upper, ↓ for lower) and the typing rules propagate these annotations according to the composition laws. This calculus yields a decidable check for admissibility of recursive definitions in the presence of higher‑rank polymorphism, impredicative quantification, and higher‑kinded inductive/co‑inductive types. The authors demonstrate the practicality of the system by encoding the generic equality function for GRose, showing that the system accepts it while rejecting ill‑typed variants that would lead to non‑termination (e.g., a loop built from successor and predecessor on Nat ω).
The paper also discusses counter‑examples that illustrate why certain naïve composition schemes fail: for instance, a type (Nat ω → Nat i) → Nat ω is not upper semi‑continuous, and using it as the result type of a recursive function yields a non‑terminating program. These examples justify the necessity of the semi‑continuity conditions.
In summary, the contribution of the paper is threefold:
- Semantic Insight – It identifies upper (and lower) semi‑continuity of the ordinal‑indexed interpretation of types as the right semantic condition for admissibility, extending beyond simple monotonicity.
- Compositional Theory – It provides a set of composition lemmas for semi‑continuous types covering all major type constructors, including higher‑kinded inductive and co‑inductive fixed points.
- Syntactic Realisation – It introduces a calculus that can be implemented in a type checker, enabling automatic verification of termination for a broad class of polymorphic recursive programs.
Overall, the work significantly broadens the expressive power of sized‑type based termination checking while preserving soundness, opening the way for practical adoption in languages that support advanced type features such as higher‑rank polymorphism and impredicative quantification.
Comments & Academic Discussion
Loading comments...
Leave a Comment