Share on Facebook Tweet on Twitter Share on LinkedIn Share by email
Verified Stateful Programs with Substructural State and Hoare Types

Johannes Borgstrom, Juan Chen, and Nikhil swamy

Abstract

A variety of techniques have been proposed to verify stateful functional programs by developing Hoare logics for the state monad. For better automation, we explore a different point in the design space: we propose using affine types to model state, while relying on refinement type checking to prove assertion safety.

Our technique is based on verification by translation, starting from FX, an imperative object-based surface language with specifications including object invariants and Hoare triple computation types, and translating into Fine, a functional language with dependent refinements and affine types. The core idea of the translation is the division of a stateful object into a pure value and an affine token whose type mentions the current state of the object. We prove our methodology sound via a simulation between imperative FX programs and their functional Fine translation.

Our approach enables modular verification of FX programs supported by an SMT solver. We demonstrate its versatility by several examples, including verifying clients of stateful APIs, even in the presence of aliasing, and tracking information flow through side-effecting computations.

Details

Publication typeTechReport
NumberMSR-TR-2010-95
PublisherMicrosoft Research
> Publications > Verified Stateful Programs with Substructural State and Hoare Types