skip to main content

Plausible sealing for gradual parametricity

Published:29 April 2022Publication History
Skip Abstract Section

Abstract

Graduality and parametricity have proven to be extremely challenging notions to bring together. Intuitively, enforcing parametricity gradually requires possibly sealing values in order to detect violations of uniform behavior. Toro et al. (2019) argue that the two notions are incompatible in the context of System F, where sealing is transparently driven by potentially imprecise type information, while New et al. (2020) reconcile both properties at the cost of abandoning the syntax of System F and requiring user-provided sealing annotations that are not subject to graduality guarantees. Furthermore, all current proposals rely on a global form of dynamic sealing in order to enforce parametric behavior at runtime, which weakens parametric reasoning and breaks equivalences in the static language. Based on the observation that the tension between graduality and parametricity comes from the early commitment to seal values based on type information, we propose plausible sealing as a new intermediate language mechanism that allows postponing such decisions to runtime. We propose an intermediate language for gradual parametricity, Funky, which supports plausible sealing in a simplified setting where polymorphism is restricted to instantiations with base and variable types. We prove that Funky satisfies both parametricity and graduality, mechanizing key lemmas in Agda. Additionally, we avoid global dynamic sealing and instead propose a novel lexically-scoped form of sealing realized using a representation of evidence inspired by the category of spans. As a consequence, Funky satisfies a standard formulation of parametricity that does not break System F equivalences. In order to show the practicality of plausible sealing, we describe a translation from Funk, a source language without explicit sealing, to Funky, that takes care of inserting plausible sealing forms. We establish graduality of Funk, subject to a restriction on type applications, and explain the source-level parametric reasoning it supports. Finally, we provide an interactive prototype along with illustrative examples both novel and from the literature.

References

  1. Amal Ahmed. 2004. Semantics of Types for Mutable State. Ph.D. Dissertation. Princeton University.Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Amal Ahmed. 2006. Step-Indexed Syntactic Logical Relations for Recursive and Quantified Types. In Proceedings of the 15th European Symposium on Programming Languages and Systems (ESOP 2006), Peter Sestoft (Ed.) (Lecture Notes in Computer Science, Vol. 3924). Springer-Verlag, Vienna, Austria. 69–83.Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Amal Ahmed, Robert Bruce Findler, Jacob Matthews, and Philip Wadler. 2009. Blame for All. In Workshop on Script to Program Evolution (STOP). Genova, Italy.Google ScholarGoogle Scholar
  4. Amal Ahmed, Dustin Jamner, Jeremy G. Siek, and Philip Wadler. 2017. Theorems for Free for Free: Parametricity, with and Without Types. 39:1–39:28.Google ScholarGoogle Scholar
  5. Andrew W. Appel and David McAllester. 2001. An Indexed Model of Recursive Types for Foundational Proof-carrying Code. ACM Transactions on Programming Languages and Systems, 23, 5 (2001), Sept., 657–683.Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Felipe Bañados Schwerter, Alison M. Clark, and Jafery. 2021. Abstracting Gradual Typing Moving Forward: Precise and Space-Efficient. 61:1–61:28.Google ScholarGoogle Scholar
  7. 2016. Proceedings of the 43rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL 2016), Rastislav Bodík and Rupak Majumdar (Eds.). ACM Press, St Petersburg, FL, USA.Google ScholarGoogle Scholar
  8. Matteo Cimini and Jeremy Siek. 2016. The gradualizer: a methodology and algorithm for generating gradual type systems. 443–455.Google ScholarGoogle Scholar
  9. Dominique Devriese, Marco Patrignani, and Frank Piessens. 2018. Parametricity versus the universal type. Proceedings of the ACM on Programming Languages, 2, POPL (2018), Jan., 38:1–38:23.Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Ronald Garcia, Alison M. Clark, and Éric Tanter. 2016. Abstracting Gradual Typing. 429–442. See erratum: https://www.cs.ubc.ca/ rxg/agt-erratum.pdf.Google ScholarGoogle Scholar
  11. Jean-Yves Girard. 1972. Interprétation Fonctionnelle et Élimination des Coupures de l’Arithmétique d’Ordre Supérieur. Ph.D. Dissertation. Université de Paris VII. Paris, France.Google ScholarGoogle Scholar
  12. David Herman, Aaron Tomb, and Cormac Flanagan. 2010. Space-efficient gradual typing. Higher-Order and Sympolic Computation, 23, 2 (2010), June, 167–189.Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. 2017.Google ScholarGoogle Scholar
  14. Yuu Igarashi, Taro Sekiyama, and Atsushi Igarashi. 2017. On Polymorphic Gradual Typing. 40:1–40:29.Google ScholarGoogle Scholar
  15. Koen Jacobs, Amin Timany, and Dominique Devriese. 2021. Fully abstract from static to gradual. 7:1–7:30.Google ScholarGoogle Scholar
  16. Nico Lehmann and Éric Tanter. 2017. Gradual Refinement Types. In Proceedings of the 44th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL 2017). ACM Press, Paris, France. 775–788.Google ScholarGoogle Scholar
  17. Jacob Matthews and Amal Ahmed. 2008. Parametric Polymorphism Through Run-Time Sealing, or, Theorems for Low, Low Prices!. In Proceedings of the 17th European Symposium on Programming Languages and Systems (ESOP 2008), Sophia Drossopoulou (Ed.) (Lecture Notes in Computer Science, Vol. 4960). Springer-Verlag, Budapest, Hungary. 16–31.Google ScholarGoogle ScholarCross RefCross Ref
  18. James H. Morris. 1973. Protection in Programming Languages. Commun. ACM, 16, 1 (1973), Jan., 15–21.Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Max S. New and Amal Ahmed. 2018. Graduality from Embedding-Projection Pairs. Proceedings of the ACM on Programming Languages, 2, ICFP (2018), Sept., 73:1–73:30.Google ScholarGoogle Scholar
  20. Max S. New, Dustin Jamner, and Amal Ahmed. 2020. Graduality and Parametricity: Together Again for the First Time. Proceedings of the ACM on Programming Languages, 4, POPL (2020), Jan., 46:1–46:32.Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. nLab contributors. 2021. pullback. https://ncatlab.org/nlab/show/pullbackGoogle ScholarGoogle Scholar
  22. nLab contributors. 2021. span. https://ncatlab.org/nlab/show/spanGoogle ScholarGoogle Scholar
  23. Benjamin Pierce and Eijiro Sumii. 2000. Relating Cryptography and Polymorphism. Manuscript.Google ScholarGoogle Scholar
  24. 2021.Google ScholarGoogle Scholar
  25. John C. Reynolds. 1974. Towards a Theory of Type Structure. In Porceedings of the Programming Symposium (Lecture Notes in Computer Science, Vol. 19). Springer-Verlag, 408–423.Google ScholarGoogle ScholarCross RefCross Ref
  26. John C. Reynolds. 1983. Types, abstraction, and parametric polymorphism. In Information Processing 83, R. E. A. Mason (Ed.). Elsevier, 513–523.Google ScholarGoogle Scholar
  27. Jeremy Siek and Walid Taha. 2006. Gradual Typing for Functional Languages. In Proceedings of the Scheme and Functional Programming Workshop. 81–92.Google ScholarGoogle Scholar
  28. Jeremy Siek and Philip Wadler. 2010. Threesomes, with and without blame. In Proceedings of the 37th annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL 2010). ACM Press, Madrid, Spain. 365–376.Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Jeremy G. Siek, Michael M. Vitousek, Matteo Cimini, and John Tang Boyland. 2015. Refined Criteria for Gradual Typing. In 1st Summit on Advances in Programming Languages (SNAPL 2015) (Leibniz International Proceedings in Informatics (LIPIcs), Vol. 32). Schloss Dagstuhl–Leibniz-Zentrum fuer Informatik, Asilomar, California, USA. 274–293.Google ScholarGoogle Scholar
  30. Eijiro Sumii and Benjamin C. Pierce. 2004. A Bisimulation for Dynamic Sealing. In Proceedings of the 31st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL 2005). ACM Press, Venice, Italy. 161–172.Google ScholarGoogle Scholar
  31. Matías Toro, Ronald Garcia, and Éric Tanter. 2018. Type-Driven Gradual Security with References. ACM Transactions on Programming Languages and Systems, 40, 4 (2018), Nov., 16:1–16:55.Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. Matías Toro, Elizabeth Labrada, and Éric Tanter. 2019. Gradual Parametricity, Revisited. Proceedings of the ACM on Programming Languages, 3, POPL (2019), Jan., 17:1–17:30.Google ScholarGoogle Scholar
  33. Matías Toro and Éric Tanter. 2020. Abstracting Gradual References. Science of Computer Programming, 197 (2020), Oct., 1–65.Google ScholarGoogle ScholarCross RefCross Ref
  34. Ningning Xie, Xuan Bi, and Bruno C. d. S. Oliveira. 2018. Consistent Subtyping for All. In Proceedings of the 27th European Symposium on Programming Languages and Systems (ESOP 2018), Amal Ahmed (Ed.) (Lecture Notes in Computer Science, Vol. 10801). Springer-Verlag, Thessaloniki, Greece. 3–30.Google ScholarGoogle Scholar

Index Terms

  1. Plausible sealing for gradual parametricity

    Recommendations

    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!