Soft Contract Verification for Higher-Order Stateful Programs

by   Phuc C. Nguyen, et al.

Software contracts allow programmers to state rich program properties using the full expressive power of an object language. However, since they are enforced at runtime, monitoring contracts imposes significant overhead and delays error discovery. So contract verification aims to guarantee all or most of these properties ahead of time, enabling valuable optimizations and yielding a more general assurance of correctness. Existing methods for static contract verification satisfy the needs of more restricted target languages, but fail to address the challenges unique to those conjoining untyped, dynamic programming, higher-order functions, modularity, and statefulness. Our approach tackles all these features at once, in the context of the full Racket system---a mature environment for stateful, higher-order, multi-paradigm programming with or without types. Evaluating our method using a set of both pure and stateful benchmarks, we are able to verify 99.94 49, 861). Stateful, higher-order functions pose significant challenges for static contract verification in particular. In the presence of these features, a modular analysis must permit code from the current module to escape permanently to an opaque context (unspecified code from outside the current module) that may be stateful and therefore store a reference to the escaped closure. Also, contracts themselves, being predicates wri en in unrestricted Racket, may exhibit stateful behavior; a sound approach must be robust to contracts which are arbitrarily expressive and interwoven with the code they monitor. In this paper, we present and evaluate our solution based on higher-order symbolic execution, explain the techniques we used to address such thorny issues, formalize a notion of behavioral approximation, and use it to provide a mechanized proof of soundness.


page 1

page 2

page 3

page 4


Runtime verification in Erlang by using contracts

During its lifetime, a program suffers several changes that seek to impr...

Verification of a Smart Contract for a Simple Casino

We describe the verification of an existing smart contract for a simple ...

Corpse Reviver: Sound and Efficient Gradual Typing via Contract Verification

Gradually-typed programming languages permit the incremental addition of...

Scalable Typestate Analysis for Low-Latency Environments

Static analyses based on typestates are important in certifying correctn...

Compositional Reasoning for Side-effectful Iterators and Iterator Adapters

Iteration is a programming operation that traditionally refers to visiti...

Contract Strengthening through Constrained Horn Clause Verification

The functional properties of a program are often specified by providing ...

Learning and Coordination of Large and Uncertain Loads via Flexible Contracts with Commitment

Large electricity customers (e.g., large data centers) can exhibit huge ...

Please sign up or login with your details

Forgot password? Click here to reset