Parametric Polymorphism through Run-Time Sealing or, Theorems for Low, Low Prices!

We show how to extend System F's parametricity guarantee to a Matthews-Findler-style multi-language system that combines System F with an untyped language by use of dynamic sealing. While the use of sealing for this purpose has been suggested before, it has never been proven to preserve parametricity. In this paper we prove that it does using step-indexed logical relations. Using this result we show a scheme for implementing parametric higher-order contracts in an untyped setting which corresponds to a translation given by Sumii and Pierce. These contracts satisfy rich enough guarantees that we can extract analogues to Wadler's free theorems that rely on run-time enforcement of dynamic seals.

[1]  S. Zdancewic,et al.  Principals in Programming Languages: A Syntactic Proof Technique , 1999, ICFP.

[2]  Matthew Flatt,et al.  PLT MzScheme: Language Manual , 2000 .

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

[4]  Dan Grossman,et al.  Principals in programming languages: a syntactic proof technique , 1999, ICFP '99.

[5]  Dan Grossman,et al.  Syntactic type abstraction , 2000, TOPL.

[6]  Benjamin C. Pierce,et al.  Logical relations for encryption , 2001, Proceedings. 14th IEEE Computer Security Foundations Workshop, 2001..

[7]  Philip Wadler,et al.  Theorems for free! , 1989, FPCA.

[8]  Benjamin C. Pierce,et al.  Relating Cryptography and Polymorphism , 2000 .

[9]  James H. Morris,et al.  Types are not sets , 1973, POPL.

[10]  Matthias Felleisen,et al.  Contracts for higher-order functions , 2002, ICFP '02.

[11]  Robert Bruce Findler,et al.  Contracts as Pairs of Projections , 2006, FLOPS.

[12]  Robert Bruce Findler,et al.  Operational semantics for multi-language programs , 2009 .

[13]  Benjamin C. Pierce,et al.  Logical relation for encryption , 2003 .

[14]  Andreas Rossberg,et al.  Typed open programming: a higher-order, typed approach to dynamic modularity and distribution , 2007 .

[15]  Andreas Rossberg,et al.  Generativity and dynamic opacity for abstract types , 2003, PPDP '03.

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

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