Abstract

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.

Highlights

  • Logical relations are a powerful tool for proving properties about the behavior of programs in a compositional, type-directed way

  • 2.1 Asynchronous Programming using Asynchronous Channels In this and the following subsection, we explore how the asynchronous channels of λchan relate to asynchronous programming encountered in practice

  • We first motivate how, conceptually, channels enable a structured approach to asynchronous programming by generalizing continuation-passing style (CPS)

Read more

Summary

INTRODUCTION

Logical relations are a powerful tool for proving properties about the behavior of programs in a compositional, type-directed way. Our main result is that, despite the fact that λchan’s implementation of channels relies crucially on dynamically-allocated, shared, mutable, higher-order state, we can use a novel form of step-indexed logical relation to establish compositionally that all well-typed programs in λchan terminate. By employing ordinals in our step-indices, we can compute compositional termination bounds for functions, even though we do not know how their arguments will be instantiated or the heaps under which they will be executed This idea of transfinite step-indexing is not new: it has been previously proposed by Schwinghammer et al [2013] for defining logical relations for may and must equivalence in a pure λ-calculus with countable nondeterminism. The accompanying technical report contains detailed proofs of all of the theorems stated in the paper [Spies et al 2021]

ASYNCHRONOUS CHANNELS
Asynchronous Channels and Promises
Additional Features of λchan
KEY IDEAS
A Logical Relations Primer
Step-Indexed Termination
Towards a Transfinite Model of Resources
Computing Resource Bounds
LOGICAL RELATION
Kripke Relation
Semantic Typing
RELATED WORK
CONCLUSIONS AND FUTURE WORK
Full Text
Published version (Free)

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call