Abstract
Polarization of types in call-by-push-value naturally leads to the separation of inductively defined observable values (classified by positive types), and coinductively defined computations (classified by negative types), with adjoint modalities mediating between them. Taking this separation as a starting point, we develop a semantic characterization of typing with step indexing to capture observation depth of recursive computations. This semantics justifies a rich set of subtyping rules for an equirecursive variant of call-by-push-value, including variant and lazy records. We further present a bidirectional syntactic typing system for both values and computations that elegantly and pragmatically circumvents difficulties of type inference in the presence of width and depth subtyping for variant and lazy records. We demonstrate the flexibility of our system by systematically deriving related systems of subtyping for (a) isorecursive types, (b) call-by-name, and (c) call-by-value, all using a structural rather than a nominal interpretation of types.
Frank Pfenning: work performed prior to joining Amazon
Chapter PDF
Similar content being viewed by others
References
Abadi, M., Fiore, M.P.: Syntactic considerations on recursive types. In: Proceedings of the 11th Annual IEEE Symposium on Logic in Computer Science. pp. 242–252. IEEE Computer Society (1996), https://doi.org/10.1109/LICS.1996.561324
Abel, A.: Polarized subtyping for sized types. In: Computer Science - Theory and Applications, First International Computer Science Symposium in Russia, CSR 2006, St. Petersburg, Russia, June 8-12, 2006, Proceedings. Lecture Notes in Computer Science, vol. 3967, pp. 381–392. Springer (2006). https://doi.org/10.1007/11753728_39
Abel, A.: Mixed inductive/coinductive types and strong normalization. In: Programming Languages and Systems, 5th Asian Symposium, APLAS 2007, Singapore, November 29-December 1, 2007, Proceedings. Lecture Notes in Computer Science, vol. 4807, pp. 286–301. Springer (2007). https://doi.org/10.1007/978-3-540-76637-7_19
Abel, A.: Type-based termination, inflationary fixed-points, and mixed inductive-coinductive types. In: Miller, D., Ésik, Z. (eds.) Proceedings of the 8th Workshop on Fixed Points in Computer Science. pp. 1–11. FICS 2012, Electronic Proceedings in Theoretical Computer Science 77 (2012). https://doi.org/10.4204/EPTCS.77.1
Abel, A., Pientka, B.: Wellfounded recursion with copatterns: A unified approach to termination and productivity. In: Morrisett, G., Uustalu, T. (eds.) International Conference on Functional Programming (ICFP’13). pp. 185–196. ACM, Boston, Massachusetts (Sep 2013), https://doi.org/10.1145/2500365.2500591
Abel, A., Pientka, B.: Well-founded recursion with copatterns and sized types. Journal of Functional Programming 26, Â e2 (2016), https://doi.org/10.1017/S0956796816000022
Ahmed, A.J.: Semantics of Types for Mutable State. Ph.D. thesis, Princeton University (2004), http://www.ccs.neu.edu/home/amal/ahmedsthesis.pdf, aAI3136691
Ahmed, A.J.: Step-indexed syntactic logical relations for recursive and quantified types. In: Sestoft, P. (ed.) 15th European Symposium on Programming (ESOP 2006). pp. 69–83. Springer LNCS 3924, Vienna, Austria (Mar 2006). https://doi.org/10.1007/11693024_6
Amadio, R.M., Cardelli, L.: Subtyping recursive types. ACM Transactions on Programming Languages and Systems 15(4), 575–631 (1993), https://doi.org/10.1145/155183.155231
Appel, A.W., McAllester, D.A.: An indexed model of recursive types for foundational proof-carrying code. Transactions on Programming Languages and Systems 23(5), 657–683 (2001), https://doi.org/10.1145/504709.504712
Barwise, J.: The situation in logic, CSLI lecture notes series, vol. 17. CSLI (1989)
Berardi, S., Tatsuta, M.: Intuitionistic Podelski-Rybalchenko theorem and equivalence between inductive definitions and cyclic proofs. In: Cïrstea, C. (ed.) Workshop on Coalgebraic Methods in Computer Science (CMCS 2018). pp. 13–33. Springer LNCS 11202, Thessaloniki, Greece (Apr 2018), https://doi.org/10.1007/978-3-030-00389-0_3
Brandt, M., Henglein, F.: Coinductive axiomatization of recursive type equality and subtyping. Fundamenta Informaticae 33(4), 309–338 (1998), https://doi.org/10.3233/FI-1998-33401
Brotherston, J., Simpson, A.: Sequent calculi for induction and infinite descent. Journal of Logic and Computation 21(6), 1177–1216 (2011), https://doi.org/10.1093/logcom/exq052
Castagna, G., Frisch, A.: A gentle introduction to semantic subtyping. In: Proceedings of the 7th International ACM SIGPLAN Conference on Principles and Practice of Declarative Programming, July 11-13 2005, Lisbon, Portugal. pp. 198–199. ACM (2005), https://doi.org/10.1145/1069774.1069793
Castagna, G., Nguyen, K., Xu, Z., Abate, P.: Polymorphic functions with set-theoretic types: Part 2: Local type inference and type reconstruction. In: Proceedings of the 42nd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. p. 289–302. POPL ’15, Association for Computing Machinery, New York, NY, USA (2015). https://doi.org/10.1145/2676726.2676991
Castagna, G., Nguyen, K., Xu, Z., Im, H., Lenglet, S., Padovani, L.: Polymorphic functions with set-theoretic types: part 1: syntax, semantics, and evaluation. In: Proceedings of the 41st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. p. 5–17. POPL ’14 (2014). https://doi.org/10.1145/2535838.2535840
Castagna, G., Petrucciani, T., Nguyen, K.: Set-theoretic types for polymorphic variants. Proceedings of the 21st ACM SIGPLAN International Conference on Functional Programming (2016), https://doi.org/10.1145/3022670.2951928
Chen, T.C., Dezani-Ciancaglini, M., Yoshida, N.: On the preciseness of subtyping in session types. In: Proceedings of the Conference on Principles and Practice of Declarative Programming (PPDP’14). ACM, Canterbury, UK (Sep 2014), https://doi.org/10.1145/2643135.2643138
Cockett, J.R.B.: Deforestation, program transformation, and cut-elimination. In: Coalgebraic Methods in Computer Science, CMCS 2001, a Satellite Event of ETAPS 2001, Genova, Italy, April 6-7, 2001. Electronic Notes in Theoretical Computer Science, vol. 44, pp. 88–127. Elsevier (2001), https://doi.org/10.1016/S1571-0661(04)80904-6
Cohen, L., Rowe, R.N.S.: Integrating induction and coinduction via closure operators and proof cycles. In: 10th International Joint Conference on Automated Reasoning (IJCAR 2020). pp. 375–394. Springer LNCS 12166, Paris, France (Jul 2020), https://doi.org/10.1007/978-3-030-51074-9_21
Danielsson, N.A., Altenkirch, T.: Subtyping, declaratively. In: 10th International Conference on Mathematics of Program Construction (MPC 2010). pp. 100–118. Springer LNCS 6120, Québec City, Canada (Jun 2010), https://doi.org/10.1007/978-3-642-13321-3_8
Das, A., DeYoung, H., Mordido, A., Pfenning, F.: Nested session types. In: Yoshida, N. (ed.) 30th European Symposium on Programming. pp. 178–206. Springer LNCS, Luxembourg, Luxembourg (Mar 2021), http://www.cs.cmu.edu/~fp/papers/esop21.pdf, extended version available as arXiv:2010.06482
Davies, R.: Practical Refinement-Types Checking. Ph.D. thesis, Carnegie Mellon University (May 2005), https://www.cs.cmu.edu/~rwh/students/davies.pdf, available as Technical Report CMU-CS-05-110
Davies, R., Pfenning, F.: Intersection types and computational effects. In: Wadler, P. (ed.) Proceedings of the Fifth International Conference on Functional Programming (ICFP’00). pp. 198–208. ACM Press, Montreal, Canada (Sep 2000), https://doi.org/10.1145/351240.351259
Dolan, S.: Algebraic Subtyping: Distinguished Dissertation 2017. BCS, Swindon, GBR (2017), https://www.cs.tufts.edu/~nr/cs257/archive/stephen-dolan/thesis.pdf
Dreyer, D., Ahmed, A., Birkedal, L.: Logical step-indexed logical relations. In: Proceedings of the 24th Annual IEEE Symposium on Logic in Computer Science, LICS 2009, 11-14 August 2009, Los Angeles, CA, USA. pp. 71–80. IEEE Computer Society (2009), https://doi.org/10.1109/LICS.2009.34
Dreyer, D., Timany, A., Krebbers, R., Birkedal, L., Jung, R.: What type soundness theorem do you really want to prove? (Oct 2019), https://blog.sigplan.org/2019/10/17/what-type-soundness-theorem-do-you-really-want-to-prove
Dunfield, J., Krishnaswami, N.: Bidirectional typing. CoRR abs/1908.05839 (2019), http://arxiv.org/abs/1908.05839
Dunfield, J., Krishnaswami, N.R.: Sound and complete bidirectional typechecking for higher-rank polymorphism with existentials and indexed types. Proc. ACM Program. Lang. 3(POPL), 9:1–9:28 (2019). https://doi.org/10.1145/3290322
Dunfield, J., Pfenning, F.: Type assignment for intersections and unions in call-by-value languages. In: Gordon, A. (ed.) Proceedings of the 6th International Conference on Foundations of Software Science and Computation Structures (FOSSACS’03). pp. 250–266. Springer-Verlag LNCS 2620, Warsaw, Poland (Apr 2003), https://doi.org/10.1007/3-540-36576-1_16
Dunfield, J., Pfenning, F.: Tridirectional typechecking. In: X.Leroy (ed.) Conference Record of the 31st Annual Symposium on Principles of Programming Languages (POPL’04). pp. 281–292. ACM Press, Venice, Italy (Jan 2004), https://doi.org/10.1145/964001.964025, extended version available as Technical Report CMU-CS-04-117, March 2004
Ehrhard, T., Tasson, C.: Probabilistic call by push value. Log. Methods Comput. Sci. 15(1) (2019), https://doi.org/10.23638/LMCS-15(1:3)2019
Freeman, T., Pfenning, F.: Refinement types for ML. In: Proceedings of the SIGPLAN ’91 Symposium on Language Design and Implementation. pp. 268–277. ACM Press, Toronto, Ontario (Jun 1991), https://doi.org/10.1145/113445.113468
Frisch, A., Castagna, G., Benzaken, V.: Semantic subtyping. In: 17th IEEE Symposium on Logic in Computer Science (LICS 2002), 22-25 July 2002, Copenhagen, Denmark, Proceedings. pp. 137–146. IEEE Computer Society (2002), https://doi.org/10.1109/LICS.2002.1029823
Frisch, A., Castagna, G., Benzaken, V.: Semantic subtyping: Dealing set-theoretically with function, union, intersection, and negation types. J. ACM 55, 19:1–19:64 (2008), https://dl.acm.org/doi/10.1145/1391289.1391293
Gapeyev, V., Levin, M.Y., Pierce, B.C.: Recursive subtyping revealed: functional pearl. In: Proceedings of the Fifth ACM SIGPLAN International Conference on Functional Programming (ICFP ’00), Montreal, Canada, September 18-21, 2000. pp. 221–231. ACM (2000), https://doi.org/10.1145/351240.351261
Garcia, R., Tanter, É.: Gradual typing as if types mattered. In: Informal Proceedings of the ACM SIGPLAN Workshop on Gradual Typing (WGT20) (2020), https://wgt20.irif.fr/wgt20-final28-acmpaginated.pdf
Gay, S.J., Hole, M.: Subtyping for session types in the \(\pi \)-calculus. Acta Informatica 42(2–3), 191–225 (2005), https://doi.org/10.1007/s00236-005-0177-z
Gay, S.J., Vasconcelos, V.T.: Linear type theory for asynchronous session types. Journal of Functional Programming 20(1), 19–50 (Jan 2010), https://doi.org/10.1017/S0956796809990268
Grädel, E., Kreutzer, S.: Will deflation lead to depletion? On non-monotone fixed point inductions. In: Symposium on Logic in Computer Science (LICS 2003). pp. 158–167. IEEE Computer Society, Ottawa, Canada (Jun 2003), https://doi.org/10.1109/LICS.2003.1210055
Harper, R.: Practical Foundations for Programming Languages. Cambridge University Press, second edn. (Apr 2016)
Hermida, C., Jacobs, B.: Structural induction and coinduction in a fibrational setting. Inf. Comput. 145(2), 107–152 (1998), https://doi.org/10.1006/inco.1998.2725
Hinrichsen, J.K., Louwrink, D., Krebbers, R., Bengtson, J.: Machine-checked semantic session typing. In: CPP ’21: 10th ACM SIGPLAN International Conference on Certified Programs and Proofs, Virtual Event, Denmark, January 17-19, 2021. pp. 178–198. ACM (2021). https://doi.org/10.1145/3437992.3439914
Jafery, K.A., Dunfield, J.: Sums of uncertainty: refinements go gradual. In: Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages, POPL 2017, Paris, France, January 18-20, 2017. pp. 804–817. ACM (2017). https://doi.org/10.1145/3009837.3009865
Jones, T., Pearce, D.J.: A mechanical soundness proof for subtyping over recursive types. In: Proceedings of the 18th Workshop on Formal Techniques for Java-like Programs, FTfJP@ECOOP 2016, Rome, Italy, July 17-22, 2016. p. 1. ACM (2016). https://doi.org/10.1145/2955811.2955812
Jung, R., Jourdan, J., Krebbers, R., Dreyer, D.: Rustbelt: securing the foundations of the rust programming language. Proc. ACM Program. Lang. 2(POPL), 66:1–66:34 (2018). https://doi.org/10.1145/3158154
Komendantsky, V.: Subtyping by folding an inductive relation into a coinductive one. In: Trends in Functional Programming, 12th International Symposium, TFP 2011, Madrid, Spain, May 16-18, 2011, Revised Selected Papers. Lecture Notes in Computer Science, vol. 7193, pp. 17–32. Springer (2011), https://doi.org/10.1007/978-3-642-32037-8_2
Lakhani, Z., Das, A., DeYoung, H., Mordido, A., Pfenning, F.: Polarized subtyping. CoRR abs/2201.10998v1 (2022), https://arxiv.org/abs/2201.10998v1, extended version.
Lakhani, Z., Das, A., DeYoung, H., Mordido, A., Pfenning, F.: Polarized subtyping: Code/artifact (jan 2022). https://doi.org/10.5281/zenodo.5913940
Lepigre, R., Raffalli, C.: Subtyping-based type-checking for system F with induction and coinduction. CoRR abs/1604.01990 (2016), http://arxiv.org/abs/1604.01990
Lepigre, R., Raffalli, C.: Practical subtyping for Curry-style languages. ACM Transactions on Programming Languages and Systems (TOPLAS) 41, 1 – 58 (2019), https://doi.org/10.1145/3285955
Levy, P.B.: Call-by-Push-Value. Ph.D. thesis, University of London (2001), http://www.cs.bham.ac.uk/~pbl/papers/thesisqmwphd.pdf
Levy, P.B.: Call-by-push-value: Decomposing call-by-value and call-by-name. Higher-Order and Symbolic Computation 19(4), 377–414 (2006), https://doi.org/10.1007/s10990-006-0480-6
Ligatti, J., Blackburn, J., Nachtigal, M.: On subtyping-relation completeness, with an application to iso-recursive types. ACM Transactions on Programming Languages and Systems 39(4), 4:1–4:36 (Mar 2017), https://doi.org/10.1145/2994596
McDermott, D., Mycroft, A.: Extended call-by-push-value: Reasoning about effectful programs and evaluation order. In: Programming Languages and Systems - 28th European Symposium on Programming, ESOP 2019, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2019, Prague, Czech Republic, April 6-11, 2019, Proceedings. Lecture Notes in Computer Science, vol. 11423, pp. 235–262. Springer (2019), https://doi.org/10.1007/978-3-030-17184-1_9
Milner, R.: A theory of type polymorphism in programming. Journal of Computer and System Sciences 17, 348–375 (Aug 1978), https://doi.org/10.1016/0022-0000(78)90014-4
Munch-Maccagnoni, G.: Syntax and Models of a non-Associative Composition of Programs and Proofs. (Syntaxe et modèles d’une composition non-associative des programmes et des preuves). Ph.D. thesis, Paris Diderot University, France (2013), https://tel.archives-ouvertes.fr/tel-00918642
Nakata, K., Uustalu, T.: Resumptions, weak bisimilarity and big-step semantics for while with interactive I/O: an exercise in mixed induction-coinduction. In: Proceedings Seventh Workshop on Structural Operational Semantics, SOS 2010, Paris, France, 30 August 2010. EPTCS, vol. 32, pp. 57–75 (2010), https://doi.org/10.4204/EPTCS.32.5
New, M.S., Licata, D.R., Ahmed, A.: Gradual type theory. Proc. ACM Program. Lang. 3(POPL), 15:1–15:31 (2019), https://doi.org/10.1145/3290328
Park, D.M.R.: On the semantics of fair parallelism. In: Bjørner, D. (ed.) Abstract Software Specifications, 1979 Copenhagen Winter School, January 22 - February 2, 1979, Proceedings. Lecture Notes in Computer Science, vol. 86, pp. 504–526. Springer (1979), https://doi.org/10.1007/3-540-10007-5_47
Parreaux, L.: The simple essence of algebraic subtyping: principal type inference with subtyping made easy (functional pearl). Proc. ACM Program. Lang. 4(ICFP), 124:1–124:28 (2020), https://doi.org/10.1145/3409006
Patrignani, M., Martin, E.M., Devriese, D.: On the semantic expressiveness of recursive types. Proceedings of the ACM on Programming Languages 5, 1–29 (2021), https://doi.org/10.1145/3434302
Pédrot, P., Tabareau, N.: The fire triangle: how to mix substitution, dependent elimination, and effects. Proc. ACM Program. Lang. 4(POPL), 58:1–58:28 (2020), https://doi.org/10.1145/3371126
Petrucciani, T.: Polymorphic set-theoretic types for functional languages. (Types ensemblistes polymorphes pour les langages fonctionnels). Ph.D. thesis, Sorbonne Paris Cité, France (2019), https://tel.archives-ouvertes.fr/tel-02119930
Petrucciani, T., Castagna, G., Ancona, D., Zucca, E.: Semantic subtyping for non-strict languages. In: 24th International Conference on Types for Proofs and Programs, TYPES 2018, June 18-21, 2018, Braga, Portugal. LIPIcs, vol. 130, pp. 4:1–4:24. Schloss Dagstuhl - Leibniz-Zentrum für Informatik (2018). https://doi.org/10.4230/LIPIcs.TYPES.2018.4, https://arxiv.org/abs/1810.05555
Pierce, B.: Types and Programming Languages. MIT Press (2002)
Pierce, B.C., Turner, D.N.: Local type inference. In: Conference Record of the 25th Symposium on Principles of Programming Languages (POPL’98) (1998), https://doi.org/10.1145/268946.268967, full version in ACM Transactions on Programming Languages and Systems (TOPLAS), 22(1), January 2000, pp. 1–44
Raffalli, C.: L’arithmetique fonctionnelle du second ordre avec points fixes. Ph.D. thesis, Paris 7 (1994), http://www.theses.fr/1994PA077080, thèse de doctorat dirigée par Krivine, Jean-Louis Mathématiques. Logique et fondements de l’informatique Paris 7 1994
Reynolds, J.C.: Design of the programming language Forsythe. Tech. Rep. CMU-CS-96-146, Carnegie Mellon University (Jun 1996)
Rioux, N., Zdancewic, S.: Computation focusing. Proc. ACM Program. Lang. 4(ICFP), 95:1–95:27 (2020). https://doi.org/10.1145/3408977
Steffen, M.: Polarized higher-order subtyping. Ph.D. thesis, University of Erlangen-Nuremberg, Germany (1999), http://d-nb.info/958020493
Urzyczyn, P.: Positive recursive type assignment. In: Mathematical Foundations of Computer Science 1995. pp. 382–391. Springer Berlin Heidelberg, Berlin, Heidelberg (1995), https://doi.org/10.1007/3-540-60246-1_144
Vanderwaart, J., Dreyer, D., Petersen, L., Crary, K., Harper, R., Cheng, P.: Typed compilation of recursive datatypes. In: Proceedings of TLDI’03: 2003 ACM SIGPLAN International Workshop on Types in Languages Design and Implementation, New Orleans, Louisiana, USA, January 18, 2003. pp. 98–108. ACM (2003), https://doi.org/10.1145/604174.604187
Zeilberger, N.: The Logical Basis of Evaluation Order and Pattern-Matching. Ph.D. thesis, Carnegie Mellon University, USA (2009), http://noamz.org/thesis.pdf
Zhou, Y., d. S. Oliveira, B.C., Zhao, J.: Revisiting iso-recursive subtyping. Proc. ACM Program. Lang. 4(OOPSLA), 223:1–223:28 (2020), https://doi.org/10.1145/3428291
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Open Access This chapter is licensed under the terms of the Creative Commons Attribution 4.0 International License (http://creativecommons.org/licenses/by/4.0/), which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license and indicate if changes were made.
The images or other third party material in this chapter are included in the chapter's Creative Commons license, unless indicated otherwise in a credit line to the material. If material is not included in the chapter's Creative Commons license and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder.
Copyright information
© 2022 The Author(s)
About this paper
Cite this paper
Lakhani, Z., Das, A., DeYoung, H., Mordido, A., Pfenning, F. (2022). Polarized Subtyping. In: Sergey, I. (eds) Programming Languages and Systems. ESOP 2022. Lecture Notes in Computer Science, vol 13240. Springer, Cham. https://doi.org/10.1007/978-3-030-99336-8_16
Download citation
DOI: https://doi.org/10.1007/978-3-030-99336-8_16
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-030-99335-1
Online ISBN: 978-3-030-99336-8
eBook Packages: Computer ScienceComputer Science (R0)