Abstract
Resolution and subtyping are two common mechanisms in programming languages. Resolution is used by features such as type classes or Scala-style implicits to synthesize values automatically from contextual type information. Subtyping is commonly used to automatically convert the type of a value into another compatible type. So far the two mechanisms have been considered independently of each other. This paper shows that, with a small extension, subtyping with intersection types can subsume resolution. This has three main consequences. Firstly, resolution does not need to be implemented as a separate mechanism. Secondly, the interaction between resolution and subtyping becomes apparent. Finally, the integration of resolution into subtyping enables first-class (implicit) environments. The extension that recovers the power of resolution via subtyping is the modus ponens rule of propositional logic. While it is easily added to declarative subtyping, significant care needs to be taken to retain desirable properties, such as transitivity and decidability of algorithmic subtyping, and coherence. To materialize these ideas we develop λiMP, a calculus that extends a iprevious calculus with disjoint intersection types, and develop its metatheory in the Coq theorem prover.
Supplemental Material
- João Alpuim, Bruno C. d. S. Oliveira, and Zhiyuan Shi. 2017. Disjoint Polymorphism. In ESOP (Lecture Notes in Computer Science, Vol. 10201 ). Springer, 1-28.Google Scholar
- Nada Amin, Karl 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 ( 2016 ), 249-272. http://infoscience.epfl.ch/record/215280Google Scholar
- Nada Amin, Adriaan Moors, and Martin Odersky. 2012. Dependent Object Types. ( 2012 ). http://infoscience.epfl.ch/record/ 183030Google Scholar
- Jean-marc Andreoli. 1992. Logic Programming with Focusing Proofs in Linear Logic. Journal of Logic and Computation 2 ( 1992 ), 297-347.Google Scholar
- Henk Barendregt, Mario Coppo, and Mariangiola Dezani-Ciancaglini. 1983. A Filter Lambda Model and the Completeness of Type Assignment. J. Symb. Log. 48, 4 ( 1983 ), 931-940.Google Scholar
Cross Ref
- Véronique Benzaken, Giuseppe Castagna, and Alain Frisch. 2003. CDuce: An XML-Centric General-Purpose Language. SIGPLAN Not. 38, 9 (Aug. 2003 ), 51-63. https://doi.org/10.1145/944746.944711 Google Scholar
Digital Library
- Jan Bessai, Boris Düdder, Andrej Dudenhefner, Tzu-Chun Chen, and Ugo de'Liguoro. 2014. Typing Classes and Mixins with Intersection Types. In ITRS (EPTCS, Vol. 177 ). 79-93.Google Scholar
- Jan Bessai, Andrej Dudenhefner, Boris Düdder, and Jakob Rehof. 2016. Extracting a Formally Verified Subtyping Algorithm for Intersection Types from Ideals and Filters (TYPES).Google Scholar
- Xuan Bi, Bruno C. d. S. Oliveira, and Tom Schrijvers. 2018. The Essence of Nested Composition. In ECOOP (LIPIcs, Vol. 109 ). Schloss Dagstuhl-Leibniz-Zentrum fuer Informatik, 22 : 1-22 : 33.Google Scholar
- Xuan Bi, Ningning Xie, Bruno C. d. S. Oliveira, and Tom Schrijvers. 2019. Distributive Disjoint Polymorphism for Compositional Programming. In Programming Languages and Systems, Luís Caires (Ed.). Springer International Publishing, Cham, 381-409.Google Scholar
- Dariusz Biernacki and Piotr Polesiuk. 2015. Logical Relations for Coherence of Efect Subtyping. In TLCA (LIPIcs, Vol. 38 ). Schloss Dagstuhl-Leibniz-Zentrum fuer Informatik, 107-122.Google Scholar
- Gert-Jan Bottu, Georgios Karachalias, Tom Schrijvers, Bruno C. d. S. Oliveira, and Philip Wadler. 2017. Quantified Class Constraints. SIGPLAN Not. 52, 10 (Sept. 2017 ), 148-161.Google Scholar
Digital Library
- Gilad Bracha and William R. Cook. 1990. Mixin-based Inheritance. In OOPSLA/ECOOP. ACM, 303-311.Google Scholar
Digital Library
- Val Breazu-Tannen, Thierry Coquand, Carl A. Gunter, and Andre Scedrov. 1991. Inheritance As Implicit Coercion. Inf. Comput. 93, 1 ( July 1991 ), 172-221.Google Scholar
- Luca Cardelli and Peter Wegner. 1985. On Understanding Types, Data Abstraction, and Polymorphism. ACM Comput. Surv. 17, 4 (Dec. 1985 ), 471-523.Google Scholar
Digital Library
- Giuseppe Castagna, Giorgio Ghelli, and Giuseppe Longo. 1992. A Calculus for Overloaded Functions with Subtyping. SIGPLAN Lisp Pointers V, 1 (Jan. 1992 ), 182-192.Google Scholar
- Gang Chen. 2003. Coercive subtyping for the Calculus of Constructions.. In POPL. 150-159.Google Scholar
- M. Coppo, M. Dezani-Ciancaglini, and B. Venneri. 1981. Functional Characters of Solvable Terms. Math. Log. Q. 27 ( 1981 ), 45-58.Google Scholar
- Pierre-Louis Curien and Giorgio Ghelli. 1994. Theoretical Aspects of Object-oriented Programming. MIT Press, Cambridge, MA, USA, Chapter Coherence of Subsumption, Minimum Typing and Type-checking in F &Le;, 247-292.Google Scholar
- Rowan Davies and Frank Pfenning. 2000. Intersection Types and Computational Efects. SIGPLAN Not. 35, 9 (Sept. 2000 ), 198-208. https://doi.org/10.1145/357766.351259 Google Scholar
Digital Library
- Dominique Devriese and Frank Piessens. 2011. On the bright side of type classes: instance arguments in Agda. In ICFP '11: Proceedings of the 16th ACM SIGPLAN international conference on Functional programming. ACM, 143-155.Google Scholar
Digital Library
- Joshua Dunfield. 2007. Refined Typechecking with Stardust. In Proceedings of the 2007 Workshop on Programming Languages Meets Program Verification (Freiburg, Germany) (PLPV '07). Association for Computing Machinery, New York, NY, USA, 21-32. https://doi.org/10.1145/1292597.1292602 Google Scholar
Digital Library
- Jana Dunfield. 2012. Elaborating Intersection and Union Types. SIGPLAN Not. 47, 9 (Sept. 2012 ), 17-28.Google Scholar
Digital Library
- Joshua Dunfield. 2015. Elaborating Evaluation-Order Polymorphism. SIGPLAN Not. 50, 9 (Aug. 2015 ), 256-268. https: //doi.org/10.1145/2858949.2784744 Google Scholar
Digital Library
- Tim Freeman and Frank Pfenning. 1991. Refinement types for ML. In Proceedings of the ACM SIGPLAN 1991 conference on Programming language design and implementation. 268-277.Google Scholar
Digital Library
- Simon J. Gay and Malcolm J. Hole. 2005. Subtyping for Session Types in the Pi Calculus. Acta Informatica 42, 2 /3 ( 2005 ), 191-225.Google Scholar
Cross Ref
- J. Giesl, C. Aschermann, M. Brockschmidt, et al. 2017. Analyzing Program Termination and Complexity Automatically with AProVE. J Autom Reasoning 58 ( 2017 ), 3-31.Google Scholar
- Cordelia V. Hall, Kevin Hammond, Simon L. Peyton Jones, and Philip L. Wadler. 1996. Type classes in Haskell. ACM Transactions on Programming Languages and Systems 18, 2 ( 1996 ), 109-138.Google Scholar
Digital Library
- Alex Jefery. 2019. Dependent Object Types with Implicit Functions. In Proceedings of the Tenth ACM SIGPLAN Symposium on Scala (Scala '19). Association for Computing Machinery, New York, NY, USA, 1-11.Google Scholar
Digital Library
- Robert A. Kowalski. 1974. Predicate Logic as Programming Language. In IFIP Congress. North-Holland, 569-574.Google Scholar
- Toshihiko Kurata and Masako Takahashi. 1995. Decidable Properties of Intersection Type Systems. In Proceedings of the Second International Conference on Typed Lambda Calculi and Applications (TLCA '95). Springer-Verlag, Berlin, Heidelberg, 297-311.Google Scholar
Digital Library
- Olivier Laurent. 2012. Intersection Types with Subtyping by Means of Cut Elimination. Fundam. Inf. 121, 1-4 ( Jan. 2012 ), 203-226.Google Scholar
- Chuck Liang and Dale Miller. 2009. Focusing and Polarization in Linear, Intuitionistic, and Classical Logics. Theor. Comput. Sci. 410, 46 ( 2009 ), 4747-4768.Google Scholar
- Zhaohui Luo. 1999. Coercive subtyping. Journal of Logic and Computation 9, 1 ( 1999 ), 105-130.Google Scholar
Cross Ref
- Dale Miller, Gopalan Nadathur, Frank Pfenning, and Andre Scedrov. 1989. Uniform Proofs As a Foundation for Logic Programming. Technical Report.Google Scholar
- Eugenio Moggi. 1991. Notions of Computation and Monads. Inf. Comput. 93, 1 ( July 1991 ), 55-92.Google Scholar
- Martin Odersky. 2010. The Scala language specification, version 2.8.Google Scholar
- Martin Odersky, Olivier Blanvillain, Fengyun Liu, Aggelos Biboudis, Heather Miller, and Sandro Stucki. 2017. Simplicitly: Foundations and Applications of Implicit Function Types. Proc. ACM Program. Lang. 2, POPL ( 2017 ).Google Scholar
- Bruno C.d.S. Oliveira, Adriaan Moors, and Martin Odersky. 2010. Type Classes As Objects and Implicits. In Proceedings of the ACM International Conference on Object Oriented Programming Systems Languages and Applications (OOPSLA '10). ACM, 341-360.Google Scholar
Digital Library
- Bruno C.d.S. Oliveira, Tom Schrijvers, Wontae Choi, Wonchan Lee, and Kwangkeun Yi. 2012. The Implicit Calculus: A New Foundation for Generic Programming. 47, 6 ( 2012 ).Google Scholar
- Bruno C. d. S. Oliveira, Zhiyuan Shi, and João Alpuim. 2016. Disjoint Intersection Types. SIGPLAN Not. 51, 9 (Sept. 2016 ), 364-377.Google Scholar
Digital Library
- Benjamin C. Pierce. 1989. A Decision Procedure for the Subtype Relation on Intersection Types with Bounded Variables. Technical Report. Carnegie Mellon University.Google Scholar
- Benjamin C. Pierce. 1991. Programming with Intersection Types and Bounded Polymorphism. Ph.D. Dissertation. Carnegie Mellon University. Available as School of Computer Science technical report CMU-CS-91-205.Google Scholar
Digital Library
- Benjamin C. Pierce. 1997. Intersection types and bounded polymorphism. Mathematical Structures in Computer Science 7, 2 ( 1997 ), 129-193. https://doi.org/10.1017/S096012959600223X Google Scholar
Digital Library
- B. C. Pierce and D. Sangiorgi. 1996. Typing and Subtyping for Mobile Processes. Math. Structures in Comput. Sci. 6, 5 ( 1996 ), 409-453.Google Scholar
- Garrel Pottinger. 1980. A type assignment for the strongly normalizable-terms. To HB Curry: essays on combinatory logic, lambda calculus and formalism ( 1980 ), 561-577.Google Scholar
- Jef Raskin. 1974. FLOW: a teaching language for computer programming in the humanities. Computers and the Humanities 8, 4 ( 1974 ), 231-237.Google Scholar
- Jakob Rehof and PawełUrzyczyn. 2011. Finite Combinatory Logic with Intersection Types. In Proceedings of the 10th International Conference on Typed Lambda Calculi and Applications (Novi Sad, Serbia) ( TLCA'11). Springer-Verlag, Berlin, Heidelberg, 169-183.Google Scholar
Cross Ref
- John C. Reynolds. 1972. Definitional Interpreters for Higher-order Programming Languages. In Proceedings of the ACM Annual Conference-Volume 2 (Boston, Massachusetts, USA) ( ACM '72). ACM, New York, NY, USA, 717-740.Google Scholar
Digital Library
- John C. Reynolds. 1974. Towards a Theory of Type Structure. Lecture Notes in Computer Science, Vol. 19. 408-425.Google Scholar
Cross Ref
- John C. Reynolds. 1988. Preliminary Design of the Programming Language Forsythe. Technical Report. Carnegie Mellon University.Google Scholar
- John C. Reynolds. 1991. The Coherence of Languages with Intersection Types. In Proceedings of the International Conference on Theoretical Aspects of Computer Software (TACS '91). Springer-Verlag, Berlin, Heidelberg, 675-700.Google Scholar
Digital Library
- Tom Schrijvers, Bruno C. d. S. Oliveira, Philip Wadler, and Koar Marntirosian. 2019. COCHIS: Stable and coherent implicits. Journal of Functional Programming 29 ( 2019 ), e3.Google Scholar
- Jan Schwinghammer. 2009. Coherence of Subsumption for Monadic Types. J. Funct. Program. 19, 2 (March 2009 ), 157-172.Google Scholar
Digital Library
- Matthieu Sozeau and Nicolas Oury. 2008a. First-Class Type Classes. In TPHOLs '08: Proceedings of the 21st International Conference on Theorem Proving in Higher Order Logics.Google Scholar
- M. Sozeau and N. Oury. 2008b. First-Class Type Classes. In TPHOLs.Google Scholar
- Rick Statman. 2014. A Finite Model Property for Intersection Types. In ITRS (EPTCS, Vol. 177 ). 1-9.Google Scholar
- Philip Wadler. 2015. Propositions as Types. Commun. ACM 58, 12 (Nov. 2015 ), 75-84.Google Scholar
- P. Wadler and S. Blott. 1989. How to Make Ad-hoc Polymorphism Less Ad Hoc. In Proceedings of the 16th ACM SIGPLANSIGACT Symposium on Principles of Programming Languages (Austin, Texas, USA) ( POPL '89). ACM, New York, NY, USA, 60-76.Google Scholar
- Leo White, Frédéric Bour, and Jeremy Yallop. 2015. Modular implicits. Electronic Proceedings in Theoretical Computer Science 198 ( 12 2015 ).Google Scholar
Cross Ref
- Thomas Winant and Dominique Devriese. 2018. Coherent Explicit Dictionary Application for Haskell. In Proceedings of the 11th ACM SIGPLAN International Symposium on Haskell (St. Louis, MO, USA) ( Haskell 2018 ). Association for Computing Machinery, New York, NY, USA, 81-93.Google Scholar
Digital Library
Index Terms
Resolution as intersection subtyping via Modus Ponens
Recommendations
Higher-order subtyping and its decidability
We define the typed lambda calculus F^ω (F-omega-meet), a natural generalization of Girard's system Fω (F-omega) with intersection types and bounded polymorphism. A novel aspect of our presentation is the use of term rewriting techniques to present ...
Gradual typing with union and intersection types
We propose a type system for functional languages with gradual types and set-theoretic type connectives and prove its soundness. In particular, we show how to lift the definition of the domain and result type of an application from non-gradual types to ...
A typed lambda calculus with intersection types
Intersection types are well known to type theorists mainly for two reasons. Firstly, they type all and only the strongly normalizable lambda terms. Secondly, the intersection type operator is a meta-level operator, that is, there is no direct logical ...






Comments