Abstract

Concurrent higher-order imperative programming languages with continuations are very flexible and allow for the implementation of sophisticated programming patterns. For instance, it is well known that continuations can be used to implement cooperative concurrency. Continuations can also simplify web server implementations. This, in particular, helps simplify keeping track of the state of server’s clients. However, such advanced programming languages are very challenging to reason about. One of the main challenges in reasoning about programs in the presence of continuations is due to the fact that the non-local flow of control breaks the bind rule, one of the important modular reasoning principles of Hoare logic. In this paper we present the first completely formalized tool for interactive mechanized relational verification of programs written in a concurrent higher-order imperative programming language with continuations (call/cc and throw). We develop novel logical relations which can be used to give mechanized proofs of relational properties. In particular, we prove correctness of an implementation of cooperative concurrency with continuations. In addition, we show that that a rudimentary web server implemented using the continuation-based pattern is contextually equivalent to one implemented without the continuation-based pattern. We introduce context-local reasoning principles for our calculus which allows us to regain modular reasoning principles for the fragment of the language without non-local control flow. These novel reasoning principles can be used in tandem with our (non-context-local) Hoare logic for reasoning about programs that do feature non-local control flow. Indeed, we use the combination of context-local and non-context-local reasoning to simplify reasoning about the examples.

Highlights

  • In a programming language with continuations, a computation can be suspended into a continuation object which can be resumed later

  • We develop a cross-language logical relation between Fcμc,ref and Fcμc,rceofop and use it to show correctness of a translation of cooperative concurrency into one based on continuations

  • We present a program logic for reasoning about programs written in Fcμo,nrecf,cc, a programming language with impredicative polymorphism, recursive types, higher-order functions, higher-order store, concurrency and first-class continuations

Read more

Summary

INTRODUCTION

In a programming language with continuations, a computation can be suspended into a continuation object which can be resumed later. We develop a new logical relations model for proving contextual refinement of programs written in Fcμo,nrecf,cc, a call-by-value programming language featuring concurrency (conc), impredicative polymorphism (F), recursive types (μ), dynamically allocated higher-order store (ref ) and first-class continuations (cc) with call/cc and throw primitives. We employ this logical relations model to prove (1) contextual equivalence of two simple web server implementations: a continuation-based one and a state-storing one; and (2) that one-shot continuations (continuations that can only be used once) can be used to simulate ordinary continuations [Friedman and Haynes 1985]. The mechanization has been done in Coq and all the results in the paper have been formally verified

Context-local Reasoning Principles
THE LANGUAGE
LOGICAL RELATIONS
Resources Used in Defining Logical Relations
Logical Relations in Iris
WEB SERVER REFINEMENT
CORRECTNESS OF CONTINUATION BASED COOPERATIVE CONCURRENCY
Cross-language Logical Relation
MECHANIZATION IN COQ
RELATED WORK
10 CONCLUSION 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