skip to main content
research-article

Non-parametric parametricity

Published:31 August 2009Publication History
Skip Abstract Section

Abstract

Type abstraction and intensional type analysis are features seemingly at odds-type abstraction is intended to guarantee parametricity and representation independence, while type analysis is inherently non-parametric. Recently, however, several researchers have proposed and implemented "dynamic type generation" as a way to reconcile these features. The idea is that, when one defines an abstract type, one should also be able to generate at run time a fresh type name, which may be used as a dynamic representative of the abstract type for purposes of type analysis. The question remains: in a language with non-parametric polymorphism, does dynamic type generation provide us with the same kinds of abstraction guarantees that we get from parametric polymorphism?

Our goal is to provide a rigorous answer to this question. We define a step-indexed Kripke logical relation for a language with both non-parametric polymorphism (in the form of type-safe cast) and dynamic type generation. Our logical relation enables us to establish parametricity and representation independence results, even in a non-parametric setting, by attaching arbitrary relational interpretations to dynamically-generated type names. In addition, we explore how programs that are provably equivalent in a more traditional parametric logical relation may be "wrapped" systematically to produce terms that are related by our non-parametric relation, and vice versa. This leads us to a novel "polarized" form of our logical relation, which enables us to distinguish formally between positive and negative notions of parametricity.

Skip Supplemental Material Section

Supplemental Material

non-parametricparametricityonvimeo2.mp4

References

  1. Martin Abadi, Luca Cardelli, Benjamin Pierce, and Didier Remy. Dynamic typing in polymorphic languages. JFP, 5(1):111--130, 1995.Google ScholarGoogle ScholarCross RefCross Ref
  2. Amal Ahmed. Semantics of Types for Mutable State. PhD thesis, Princeton University, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Amal Ahmed. Step-indexed syntactic logical relations for recursive and quantified types. In ESOP, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Amal Ahmed. Personal communication, 2009.Google ScholarGoogle Scholar
  5. Amal Ahmed and Matthias Blume. Typed closure conversion preserves observational equivalence. In ICFP, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Amal Ahmed, Derek Dreyer, and Andreas Rossberg. State-dependent representation independence. In POPL, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Andrew W. Appel and David McAllester. An indexed model of recursive types for foundational proof-carrying code. TOPLAS, 23(5):657--683, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Karl Crary and Robert Harper. Syntactic logical relations for polymorphic and recursive types. In Computation, Meaning and Logic: Articles dedicated to Gordon Plotkin. 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Jean-Yves Girard. Interpretation fonctionelle et elimination des coupures de l'arithmetique d'ordre superieur. PhD thesis, Universite Paris VII, 1972.Google ScholarGoogle Scholar
  10. Dan Grossman, Greg Morrisett, and Steve Zdancewic. Syntactic type abstraction. TOPLAS, 22(6):1037--1080, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Robert Harper and John C. Mitchell. Parametricity and variants of Girard's J operator. Information Processing Letters, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Robert Harper and Greg Morrisett. Compiling polymorphism using intensional type analysis. In POPL, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. JacobMatthews and Amal Ahmed. Parametric polymorphism through run-time sealing, or, theorems for low, low prices! In ESOP, 2008.Google ScholarGoogle Scholar
  14. John C. Mitchell. Representation independence and data abstraction. In POPL, 1986. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. John C. Mitchell and Gordon D. Plotkin. Abstract types have existential type. TOPLAS, 10(3):470--502, 1988. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Georg Neis. Non-parametric parametricity. Master's thesis, Universitat des Saarlandes, 2009.Google ScholarGoogle Scholar
  17. Andrew Pitts. Typed operational reasoning. In Benjamin C. Pierce, editor, Advanced Topics in Types and Programming Languages, chapter 7. MIT Press, 2005.Google ScholarGoogle Scholar
  18. Andrew Pitts and Ian Stark. Observable properties of higher order functions that dynamically create local names, or: What's new? In MFCS, volume 711 of LNCS, 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Andrew Pitts and Ian Stark. Operational reasoning for functions with local state. In HOOTS, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. John C. Reynolds. Types, abstraction and parametric polymorphism. In Information Processing, 1983.Google ScholarGoogle Scholar
  21. Andreas Rossberg. Generativity and dynamic opacity for abstract types. In PPDP, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Andreas Rossberg. Dynamic translucency with abstraction kinds and higher-order coercions. In MFPS, 2008.Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Andreas Rossberg, Didier Le Botlan, Guido Tack, Thorsten Brunklaus, and Gert Smolka. Alice ML through the looking glass. In TFP, volume 5, 2004.Google ScholarGoogle Scholar
  24. Peter Sewell. Modules, abstract types, and distributed versioning. In POPL, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Peter Sewell, James Leifer, Keith Wansbrough, Francesco Zappa Nardelli, Mair Allen-Williams, Pierre Habouzit, and Viktor Vafeiadis. Acute: High-level programming language design for distributed computation. JFP, 17(4&5):547--612, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Eijiro Sumii and Benjamin C. Pierce. Logical relations for encryption. JCS, 11(4):521--554, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Eijiro Sumii and Benjamin C. Pierce. A bisimulation for dynamic sealing. TCS, 375(1-3):161--192, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Eijiro Sumii and Benjamin C. Pierce. A bisimulation for type abstraction and recursion. JACM, 54(5):1--43, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Dimitrios Vytiniotis, Geoffrey Washburn, and Stephanie Weirich. An open and shut typecase. In TLDI, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Philip Wadler. Theorems for free! In FPCA, 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Geoffrey Washburn and Stephanie Weirich. Generalizing parametricity using information flow. In LICS, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. Stephanie Weirich. Type-safe cast. JFP, 14(6):681--695, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Non-parametric parametricity

        Recommendations

        Reviews

        Markus Wolf

        Programming languages with language constructs for analyzing types or casting from some abstract type to its concrete implementation type seem to violate abstraction principles (especially the parametricity principle that the current concrete implementation of an abstract type can be replaced by any other concrete implementation conforming to the abstract type). However, if the type system carefully guards against "unsafe" applications of these constructs and allows concrete type instantiations to hide behind dynamically generated type names, then parametricity can be recovered. This is elaborated and rigorously proved in this paper. The first two sections introduce the topic, present the motivation, and define a simple polymorphic language (complete with syntax, type system, and operational semantics) with a cast function and a dynamic type name generation operation. The following two sections explain how parametricity for the language is proved via a classic technique using logical relations. The logical relation in itself combines a step-indexed logical relation with a Kripke logical relation. The main structure of the proof is shown. Some technical details are not fully presented in the paper, but can be downloaded in the form of a technical report from the homepage of one of the authors. The previous result showed that parametricity can be regained via the introduction of fresh type names. It is, however, not immediately obvious how to systematically replace an arbitrary expression with an expression that is parametric. To achieve this, a wrapping operator is defined. In the following sections, the logical relation is extended and refined in order to reason about parametricity in a more natural way and to include iso-recursive types. Finally, the authors show one direction of a full abstraction result of an embedding of System F (with recursion) into the language of the paper; the other direction is an open problem. The article concludes with references to related work and a conclusion. The article is very well written, but the density of technical definitions is quite high, making it difficult for the reader to follow all of the details. The basic ideas and the reasons why the technical results are correct are presented in a very compelling way. I recommended this paper to anyone interested in typed functional programming languages. Online Computing Reviews Service

        Access critical reviews of Computing literature here

        Become a reviewer for Computing Reviews.

        Comments

        Login options

        Check if you have access through your login credentials or your institution to get full access on this article.

        Sign in

        Full Access

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader
        About Cookies On This Site

        We use cookies to ensure that we give you the best experience on our website.

        Learn more

        Got it!