Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
research-article
Open access

Full Iso-Recursive Types

Published: 08 October 2024 Publication History

Abstract

There are two well-known formulations of recursive types: iso-recursive and equi-recursive types. Abadi and Fiore [LICS 1996] have shown that iso- and equi-recursive types have the same expressive power. However, their encoding of equi-recursive types in terms of iso-recursive types requires explicit coercions. These coercions come with significant additional computational overhead, and complicate reasoning about the equivalence of the two formulations of recursive types. This paper proposes a generalization of iso-recursive types called full iso-recursive types. Full iso-recursive types allow encoding all programs with equi-recursive types without computational overhead. Instead of explicit term coercions, all type transformations are captured by computationally irrelevant casts, which can be erased at runtime without affecting the semantics of the program. Consequently, reasoning about the equivalence between the two approaches can be greatly simplified. We present a calculus called λFiµ, which extends the simply typed lambda calculus (STLC) with full iso-recursive types. The λFiµ calculus is proved to be type sound, and shown to have the same expressive power as a calculus with equi-recursive types. We also extend our results to subtyping, and show that equi-recursive subtyping can be expressed in terms of iso-recursive subtyping with cast operators.

References

[1]
Martin Abadi and Luca Cardelli. 1996. A theory of objects. Springer Science & Business Media. https://doi.org/10.1007/978-1-4419-8598-9
[2]
Martin Abadi and Marcelo P Fiore. 1996. Syntactic considerations on recursive types. In Proceedings 11th Annual IEEE Symposium on Logic in Computer Science. 242–252. https://doi.org/10.1109/LICS.1996.561324
[3]
Roberto M Amadio and Luca Cardelli. 1993. Subtyping recursive types. ACM Transactions on Programming Languages and Systems (TOPLAS), 15, 4 (1993), 575–631. https://doi.org/10.1145/155183.155231
[4]
Nada Amin, Samuel Grütter, Martin Odersky, Tiark Rompf, and Sandro Stucki. 2016. The essence of dependent object types. A List of Successes That Can Change the World: Essays Dedicated to Philip Wadler on the Occasion of His 60th Birthday, 249–272. https://doi.org/10.1007/978-3-319-30936-1_14
[5]
Brian Aydemir, Arthur Charguéraud, Benjamin C. Pierce, Randy Pollack, and Stephanie Weirich. 2008. Engineering formal metatheory. Acm sigplan notices, 43, 1 (2008), 3–15. https://doi.org/10.1145/1328897.1328443
[6]
Michael Backes, Cătălin Hriţcu, and Matteo Maffei. 2014. Union, intersection and refinement types and reasoning about type disjointness for secure protocol implementations. J. Comput. Secur., 22, 2 (2014), mar, 301–353.
[7]
Jesper Bengtson, Karthikeyan Bhargavan, Cédric Fournet, Andrew D Gordon, and Sergio Maffeis. 2011. Refinement types for secure implementations. ACM Transactions on Programming Languages and Systems (TOPLAS), 33, 2 (2011), 1–45. https://doi.org/10.1145/1890028.1890031
[8]
Michael Brandt and Fritz Henglein. 1998. Coinductive axiomatization of recursive type equality and subtyping. Fundamenta Informaticae, 33, 4 (1998), 309–338. https://doi.org/10.3233/FI-1998-33401
[9]
Yufei Cai, Paolo G Giarrusso, and Klaus Ostermann. 2016. System F-omega with equirecursive types for datatype-generic programming. In Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. 30–43.
[10]
Luca Cardelli. 1985. Amber, Combinators and Functional Programming Languages. Proc. of the 13th Summer School of the LITP, Le Val D’Ajol, Vosges (France).
[11]
Luca Cardelli, Jim Donahue, Mick Jordan, Bill Kalsow, and Greg Nelson. 1989. The Modula–3 type system. In Proceedings of the 16th ACM SIGPLAN-SIGACT symposium on Principles of programming languages. 202–212. https://doi.org/10.1145/75277.75295
[12]
Giuseppe Castagna, Mariangiola Dezani-Ciancaglini, Elena Giachino, and Luca Padovani. 2009. Foundations of session types. In Proceedings of the 11th ACM SIGPLAN conference on Principles and practice of declarative programming. 219–230. https://doi.org/10.1145/1599410.1599437
[13]
Tzu-Chun Chen, Mariangiola Dezani-Ciancaglini, and Nobuko Yoshida. 2014. On the preciseness of subtyping in session types. In Proceedings of the 16th International Symposium on Principles and Practice of Declarative Programming. 135–146. https://doi.org/10.1145/2643135.2643138
[14]
Ravi Chugh. 2015. IsoLATE: A type system for self-recursion. In Programming Languages and Systems: 24th European Symposium on Programming, ESOP 2015, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2015, London, UK, April 11-18, 2015, Proceedings 24. 257–282. https://doi.org/10.1007/978-3-662-46669-8_11
[15]
Dario Colazzo and Giorgio Ghelli. 2005. Subtyping recursion and parametric polymorphism in kernel fun. Information and Computation, 198, 2 (2005), 71–147. https://doi.org/10.1016/j.ic.2004.11.003
[16]
Karl Crary. 2000. Typed compilation of inclusive subtyping. In Proceedings of the fifth ACM SIGPLAN international conference on Functional programming. 68–81. https://doi.org/10.1145/351240.351247
[17]
Karl Crary, Robert Harper, and Sidd Puri. 1999. What is a recursive module? In Proceedings of the ACM SIGPLAN 1999 conference on Programming language design and implementation. 50–63. https://doi.org/10.1145/301618.301641
[18]
Julien Cretin. 2014. Erasable coercions: a unified approach to type systems. Ph. D. Dissertation. Université Paris-Diderot-Paris VII.
[19]
Nils Anders Danielsson and Thorsten Altenkirch. 2010. Subtyping, declaratively: An exercise in mixed induction and coinduction. In Mathematics of Program Construction: 10th International Conference, MPC 2010, Québec City, Canada, June 21-23, 2010. Proceedings 10. 100–118. https://doi.org/10.1007/978-3-642-13321-3_8
[20]
Derek Dreyer. 2005. Understanding and Evolving the ML Module System. Ph. D. Dissertation. School of Computer Science, Carnegie Mellon University.
[21]
Derek R. Dreyer, Robert Harper, and Karl Krary. 2001. Toward a Practical Type Theory for Recursive Modules. School of Computer Science, Carnegie Mellon University.
[22]
Dominic Duggan. 2002. Type-safe linking with recursive DLLs and shared libraries. ACM Transactions on Programming Languages and Systems (TOPLAS), 24, 6 (2002), 711–804. https://doi.org/10.1145/586088.586093
[23]
Robert Bruce Findler and Matthias Felleisen. 2002. Contracts for higher-order functions. In Proceedings of the seventh ACM SIGPLAN international conference on Functional programming. 48–59. https://doi.org/10.1145/581478.581484
[24]
Vladimir Gapeyev, Michael Y Levin, and Benjamin C Pierce. 2002. Recursive subtyping revealed. Journal of Functional Programming, 12, 6 (2002), 511–548. https://doi.org/10.1017/S0956796802004318
[25]
Simon Gay and Malcolm Hole. 2005. Subtyping for session types in the pi calculus. Acta Informatica, 42 (2005), 191–225. https://doi.org/10.1007/s00236-005-0177-z
[26]
Simon J Gay and Vasco T Vasconcelos. 2010. Linear type theory for asynchronous session types. Journal of Functional Programming, 20, 1 (2010), 19–50. https://doi.org/10.1017/S0956796809990268
[27]
Giorgio Ghelli. 1993. Recursive types are not conservative over F≤. In International Conference on Typed Lambda Calculi and Applications. 146–162. https://doi.org/10.1007/BFb0037104
[28]
Adam Michael Gundry. 2013. Type inference, Haskell and dependent types.
[29]
Carl A Gunter. 1992. Semantics of programming languages: structures and techniques. MIT press.
[30]
Robert Harper and John C Mitchell. 1993. On the type structure of Standard ML. Acm transactions on programming languages and systems (TOPLAS), 15, 2 (1993), 211–252. https://doi.org/10.1145/169701.169696
[31]
Robert Harper and Christopher Stone. 2000. A type-theoretic interpretation of Standard ML. https://doi.org/10.7551/mitpress/5641.003.0019
[32]
Martin Hofmann and Benjamin Pierce. 1995. Positive subtyping. In Proceedings of the 22nd ACM SIGPLAN-SIGACT symposium on Principles of programming languages. 186–197.
[33]
Alan Jeffrey. 2001. A symbolic labelled transition system for coinductive subtyping of F< types. In 2001 IEEE Conference on Logic and Computer Science (LICS 2001). 323.
[34]
Timothy Jones and David J Pearce. 2016. A mechanical soundness proof for subtyping over recursive types. In Proceedings of the 18th Workshop on Formal Techniques for Java-like Programs. 1–6. https://doi.org/10.1145/2955811.2955812
[35]
Garrin Kimmell, Aaron Stump, Harley D Eades III, Peng Fu, Tim Sheard, Stephanie Weirich, Chris Casinghino, Vilhelm Sjöberg, Nathan Collins, and Ki Yung Ahn. 2012. Equational reasoning about programs with general recursion and call-by-value semantics. In Proceedings of the sixth workshop on Programming languages meets program verification. 15–26. https://doi.org/10.1145/2103776.2103780
[36]
Vladimir Komendantsky. 2011. Subtyping by folding an inductive relation into a coinductive one. In International Symposium on Trends in Functional Programming. 17–32.
[37]
Joseph Lee, Jonathan Aldrich, Troy Shaw, and Alex Potanin. 2015. A theory of tagged objects. In 29th European Conference on Object-Oriented Programming (ECOOP 2015).
[38]
Jay Ligatti, Jeremy Blackburn, and Michael Nachtigal. 2017. On subtyping-relation completeness, with an application to iso-recursive types. ACM Transactions on Programming Languages and Systems (TOPLAS), 39, 1 (2017), 1–36. https://doi.org/10.1145/2994596
[39]
James H Morris. 1968. Lambda calculus models of programming languages.
[40]
Martin Odersky, Philippe Altherr, Vincent Cremet, Burak Emir, Stphane Micheloud, Nikolay Mihaylov, Michel Schinz, Erik Stenman, and Matthias Zenger. 2004. The Scala language specification.
[41]
Marco Patrignani, Eric Mark Martin, and Dominique Devriese. 2021. On the semantic expressiveness of recursive types. Proceedings of the ACM on Programming Languages, 5, POPL (2021), 1–29. https://doi.org/10.1145/3434302
[42]
Benjamin C Pierce. 2002. Types and programming languages. MIT press.
[43]
Tiark Rompf and Nada Amin. 2016. Type soundness for dependent object types (DOT). In Proceedings of the 2016 ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and Applications. 624–641. https://doi.org/10.1145/2983990.2984008
[44]
Andreas Rossberg. 2023. Mutually Iso-Recursive Subtyping. Proceedings of the ACM on Programming Languages, 7, OOPSLA2 (2023), 347–373. https://doi.org/10.1145/3622809
[45]
Claudio V. Russo. 2001. Recursive Structures for Standard ML. In Proceedings of the Sixth ACM SIGPLAN International Conference on Functional Programming (ICFP ’01), Firenze (Florence), Italy, September 3-5, 2001, Benjamin C. Pierce (Ed.). ACM, 50–61.
[46]
Jeremy Siek and Walid Taha. 2007. Gradual typing for objects. In European Conference on Object-Oriented Programming. 2–27.
[47]
Jeremy G Siek and Sam Tobin-Hochstadt. 2016. The recursive union of some gradual types. In A List of Successes that can Change the World: Essays Dedicated to Philip Wadler on the Occasion of His 60th Birthday. Springer, 388–410. https://doi.org/10.1007/978-3-319-30936-1_21
[48]
Vilhelm Sjöberg, Chris Casinghino, Ki Yung Ahn, Nathan Collins, Harley D Eades III, Peng Fu, Garrin Kimmell, Tim Sheard, Aaron Stump, and Stephanie Weirich. 2012. Irrelevance, heterogeneous equality, and call-by-value dependent type systems. arXiv preprint arXiv:1202.2923.
[49]
Vilhelm Sjöberg and Stephanie Weirich. 2015. Programming up to congruence. In Proceedings of the 42nd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. 369–382. https://doi.org/10.1145/2676726.2676974
[50]
Aaron Stump, Morgan Deters, Adam Petcher, Todd Schiller, and Timothy Simpson. 2009. Verified programming in Guru. In Proceedings of the 3rd workshop on Programming languages meets program verification. 49–58. https://doi.org/10.1145/1481848.1481856
[51]
Martin Sulzmann, Manuel MT Chakravarty, Simon Peyton Jones, and Kevin Donnelly. 2007. System F with type equality coercions. In Proceedings of the 2007 ACM SIGPLAN international workshop on Types in languages design and implementation. 53–66. https://doi.org/10.1145/1190315.1190324
[52]
Nikhil Swamy, Juan Chen, Cédric Fournet, Pierre-Yves Strub, Karthikeyan Bhargavan, and Jean Yang. 2011. Secure distributed programming with value-dependent types. ACM SIGPLAN Notices, 46, 9 (2011), 266–278. https://doi.org/10.1145/2034574.2034811
[53]
Pawel Urzyczyn. 1995. Positive recursive type assignment. In International Symposium on Mathematical Foundations of Computer Science. 382–391.
[54]
Joseph C Vanderwaart, Derek Dreyer, Leaf Petersen, Karl Crary, Robert Harper, and Perry Cheng. 2003. Typed compilation of recursive datatypes. ACM SIGPLAN Notices, 38, 3 (2003), 98–108. https://doi.org/10.1145/640136.604187
[55]
Stephanie Weirich, Justin Hsu, and Richard A Eisenberg. 2013. System FC with explicit kind equality. ACM SIGPLAN Notices, 48, 9 (2013), 275–286. https://doi.org/10.1145/2544174.2500599
[56]
Stephanie Weirich, Antoine Voizard, Pedro Henrique Azevedo de Amorim, and Richard A Eisenberg. 2017. A specification for dependent types in Haskell. Proceedings of the ACM on Programming Languages, 1, ICFP (2017), 1–29. https://doi.org/10.1145/3110275
[57]
Stephanie Weirich, Dimitrios Vytiniotis, Simon Peyton Jones, and Steve Zdancewic. 2011. Generative type abstraction and type-level computation. ACM SIGPLAN Notices, 46, 1 (2011), 227–240. https://doi.org/10.1145/1925844.1926411
[58]
Yanpeng Yang and Bruno C. d. S. Oliveira. 2019. Pure iso-type systems. Journal of Functional Programming, 29 (2019), e14. https://doi.org/10.1017/S0956796819000108
[59]
Brent A Yorgey, Stephanie Weirich, Julien Cretin, Simon Peyton Jones, Dimitrios Vytiniotis, and José Pedro Magalhães. 2012. Giving Haskell a promotion. In Proceedings of the 8th ACM SIGPLAN Workshop on Types in Language Design and Implementation. 53–66. https://doi.org/10.1145/2103786.2103795
[60]
Litao Zhou, Qianyong Wan, and Bruno C. d. S. Oliveira. 2024. Full Iso-recursive Types (Artifact). https://doi.org/10.5281/zenodo.12669929
[61]
Litao Zhou, Yaoda Zhou, and Bruno C. d. S. Oliveira. 2023. Recursive Subtyping for All. Proceedings of the ACM on Programming Languages, 7, POPL (2023), 1396–1425. https://doi.org/10.1145/3571241
[62]
Yaoda Zhou, Bruno C. d. S. Oliveira, and Jinxu Zhao. 2020. Revisiting iso-recursive subtyping. Proceedings of the ACM on Programming Languages, 4, OOPSLA (2020), 1–28. https://doi.org/10.1145/3428291
[63]
Yaoda Zhou, Jinxu Zhao, and Bruno C. d. S. Oliveira. 2022. Revisiting Iso-recursive subtyping. ACM Transactions on Programming Languages and Systems (TOPLAS), 44, 4 (2022), 1–54. https://doi.org/10.1145/3549537

Recommendations

Comments

Information & Contributors

Information

Published In

cover image Proceedings of the ACM on Programming Languages
Proceedings of the ACM on Programming Languages  Volume 8, Issue OOPSLA2
October 2024
2691 pages
EISSN:2475-1421
DOI:10.1145/3554319
Issue’s Table of Contents
This work is licensed under a Creative Commons Attribution International 4.0 License.

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 08 October 2024
Published in PACMPL Volume 8, Issue OOPSLA2

Permissions

Request permissions for this article.

Check for updates

Badges

Author Tags

  1. Recursive types
  2. Subtyping
  3. Type system

Qualifiers

  • Research-article

Funding Sources

  • Hong Kong Research Grant Council

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • 0
    Total Citations
  • 131
    Total Downloads
  • Downloads (Last 12 months)131
  • Downloads (Last 6 weeks)49
Reflects downloads up to 01 Jan 2025

Other Metrics

Citations

View Options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Login options

Full Access

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media