A logical relation for monadic encapsulation of state: proving contextual equivalences in the presence of runST

We present a logical relations model of a higher-order functional programming language with impredicative polymorphism, recursive types, and a Haskell-style ST monad type with runST. We use our logical relations model to show that runST provides proper encapsulation of state, by showing that effectful computations encapsulated by runST are heap independent. Furthermore, we show that contextual refinements and equivalences that are expected to hold for pure computations do indeed hold in the presence of runST. This is the first time such relational results have been proven for a language with monadic encapsulation of state. We have formalized all the technical development and results in Coq.

[1]  John C. Reynolds,et al.  Types, Abstraction and Parametric Polymorphism , 1983, IFIP Congress.

[2]  David K. Gifford,et al.  Integrating functional and imperative programming , 1986, LFP '86.

[3]  Robert Hieb,et al.  The Revised Report on the Syntactic Theories of Sequential Control and State , 1992, Theor. Comput. Sci..

[4]  Simon L. Peyton Jones,et al.  Lazy functional state threads , 1994, PLDI '94.

[5]  Simon L. Peyton Jones,et al.  State in Haskell , 1995, LISP Symb. Comput..

[6]  Amr Sabry,et al.  Monadic encapsulation in ML , 1999, ICFP '99.

[7]  Amr Sabry,et al.  Monadic encapsulation of effects: a revised approach (extended version) , 2001, J. Funct. Program..

[8]  Andrew W. Appel,et al.  An indexed model of recursive types for foundational proof-carrying code , 2001, TOPL.

[9]  Andrew W. Appel,et al.  A stratified semantics of general references embeddable in higher-order logic , 2002, Proceedings 17th Annual IEEE Symposium on Logic in Computer Science.

[10]  Amal Ahmed,et al.  Semantics of types for mutable state , 2004 .

[11]  Martin Hofmann,et al.  Reading, Writing and Relations , 2006, APLAS.

[12]  Amal Ahmed,et al.  Step-Indexed Syntactic Logical Relations for Recursive and Quantified Types , 2006, ESOP.

[13]  Nick Benton,et al.  Semantics of an effect analysis for exceptions , 2007, TLDI '07.

[14]  Martin Hofmann,et al.  Relational semantics for effect-based program transformations with dynamic allocation , 2007, PPDP '07.

[15]  Andrew W. Appel,et al.  A very modal model of a modern, major, general type system , 2007, POPL '07.

[16]  Lars Birkedal,et al.  Logical Step-Indexed Logical Relations , 2009, 2009 24th Annual IEEE Symposium on Logic In Computer Science.

[17]  Martin Hofmann,et al.  Relational semantics for effect-based program transformations: higher-order store , 2009, PPDP '09.

[18]  Lars Birkedal,et al.  A kripke logical relation for effect-based program transformations , 2011, ICFP '11.

[19]  Hongseok Yang,et al.  Step-indexed kripke models over recursive worlds , 2011, POPL '11.

[20]  Lars Birkedal,et al.  Iris: Monoids and Invariants as an Orthogonal Basis for Concurrent Reasoning , 2015, POPL.

[21]  Gert Smolka,et al.  Autosubst: Reasoning with de Bruijn Terms and Parallel Substitutions , 2015, ITP.

[22]  Lars Birkedal,et al.  Higher-order ghost state , 2016, ICFP.

[23]  Lars Birkedal,et al.  The Essence of Higher-Order Concurrent Separation Logic , 2017, ESOP.

[24]  Lars Birkedal,et al.  A relational model of types-and-effects in higher-order concurrent separation logic , 2017, POPL.

[25]  Lars Birkedal,et al.  Interactive proofs in higher-order concurrent separation logic , 2017, POPL.