State-dependent representation independence

Mitchell's notion of representation independence is a particularly useful application of Reynolds' relational parametricity -- two different implementations of an abstract data type can be shown contextually equivalent so long as there exists a relation between their type representations that is preserved by their operations. There have been a number of methods proposed for proving representation independence in various pure extensions of System F (where data abstraction is achieved through existential typing), as well as in Algol- or Java-like languages (where data abstraction is achieved through the use of local mutable state). However, none of these approaches addresses the interaction of existential type abstraction and local state. In particular, none allows one to prove representation independence results for generative ADTs -- i.e. ADTs that both maintain some local state and define abstract types whose internal representations are dependent on that local state. In this paper, we present a syntactic, logical-relations-based method for proving representation independence of generative ADTs in a language supporting polymorphic types, existential types, general recursive types, and unrestricted ML-style mutable references. We demonstrate the effectiveness of our method by using it to prove several interesting contextual equivalences that involve a close interaction between existential typing and local state, as well as some well-known equivalences from the literature (such as Pitts and Stark's "awkward" example) that have caused trouble for previous logical-relations-based methods. The success of our method relies on two key technical innovations. First, in order to handle generative ADTs, we develop a possible-worlds model in which relational interpretations of types are allowed to grow over time in a manner that is tightly coupled with changes to some local state. Second, we employ a step-indexed stratification of possible worlds, which facilitates a simplified account of mutable references of higher type.

[1]  Anindya Banerjee,et al.  State Based Ownership, Reentrance, and Encapsulation , 2005, ECOOP.

[2]  Anindya Banerjee,et al.  Ownership confinement ensures representation independence for object-oriented programs , 2002, JACM.

[3]  Patricia Johann,et al.  Selective strictness and parametricity in structural operational semantics, inequationally , 2007, Theor. Comput. Sci..

[4]  Umut A. Acar,et al.  Imperative self-adjusting computation , 2008, POPL '08.

[5]  Davide Sangiorgi,et al.  Behavioral equivalence in the polymorphic pi-calculus , 2000, JACM.

[6]  Derek Dreyer,et al.  A type system for higher-order modules , 2003, POPL '03.

[7]  Lars Birkedal,et al.  Relational parametricity for references and recursive types , 2009, TLDI '09.

[8]  Derek Dreyer,et al.  State-Dependent Representation Independence ( Technical Appendix ) , 2008 .

[9]  Claudio V. Russo Non-dependent Types for Standard ML Modules , 1999, PPDP.

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

[11]  Lars Birkedal,et al.  Relational Reasoning for Recursive Types and References , 2006, APLAS.

[12]  John C. Reynolds,et al.  Separation logic: a logic for shared mutable data structures , 2002, Proceedings 17th Annual IEEE Symposium on Logic in Computer Science.

[13]  I. Stark,et al.  Operational reasoning for functions with local state , 1999 .

[14]  Jérôme Vouillon,et al.  Recursive polymorphic types and parametricity in an operational framework , 2005, 20th Annual IEEE Symposium on Logic in Computer Science (LICS' 05).

[15]  Lars Birkedal,et al.  Hoare type theory, polymorphism and separation1 , 2008, Journal of Functional Programming.

[16]  M. Wand,et al.  Reasoning About Class Behavior , 2006 .

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

[18]  Xavier Leroy,et al.  Applicative functors and fully transparent higher-order modules , 1995, POPL '95.

[19]  Mitchell Wand,et al.  Small bisimulations for reasoning about higher-order imperative programs , 2006, POPL '06.

[20]  Karl Crary,et al.  Syntactic Logical Relations for Polymorphic and Recursive Types , 2007, Computation, Meaning, and Logic.

[21]  John C. Mitchell,et al.  Representation independence and data abstraction , 1986, POPL '86.

[22]  Davide Sangiorgi,et al.  Environmental Bisimulations for Higher-Order Languages , 2007, 22nd Annual IEEE Symposium on Logic in Computer Science (LICS 2007).

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

[24]  Benjamin C. Pierce,et al.  A bisimulation for dynamic sealing , 2004, Theor. Comput. Sci..

[25]  Hongseok Yang,et al.  Correctness of Data Representations Involving Heap Data Structures , 2003, ESOP.

[26]  Matthias Blume,et al.  Typed closure conversion preserves observational equivalence , 2008, ICFP 2008.

[27]  Benjamin C. Pierce,et al.  A bisimulation for dynamic sealing , 2007, Theor. Comput. Sci..

[28]  Hongseok Yang,et al.  Correctness of data representations involving heap data structures , 2004, Sci. Comput. Program..

[29]  Benjamin C. Pierce,et al.  A bisimulation for type abstraction and recursion , 2005, POPL '05.

[30]  Nick Benton,et al.  Relational Reasoning in a Nominal Semantics for Storage , 2005, TLCA.