Transfinite Step-Indexing for Termination

Simon Spies, Neel Krishnaswami, Derek Dreyer

Paper Technical Report

Step-indexed logical relations are an extremely useful technique for building operational-semantics-based models and program logics for realistic, richly-typed programming languages. They have proven to be indispensable for modeling features like higher-order state, which many languages support but which were difficult to accommodate using traditional denotational models. However, the conventional wisdom is that, because they only support reasoning about finite traces of computation, (unary) step-indexed models are only good for proving safety properties like "well-typed programs don't go wrong". There has consequently been very little work on using step-indexing to establish liveness properties, in particular termination.

In this paper, we show that step-indexing can in fact be used to prove termination of well-typed programs – even in the presence of dynamically-allocated, shared, mutable, higher-order state – so long as one's type system enforces disciplined use of such state. Specifically, we consider a language with asynchronous channels, inspired by promises in JavaScript, in which higher-order state is used to implement communication, and linearity is used to ensure termination. The key to our approach is to generalize from natural number step-indexing to transfinite step-indexing, which enables us to compute termination bounds for program expressions in a compositional way. Although transfinite step-indexing has been proposed previously, we are the first to apply this technique to reasoning about termination in the presence of higher-order state.