skip to main content

Resolution as intersection subtyping via Modus Ponens

Published:13 November 2020Publication History
Skip Abstract Section

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.

Skip Supplemental Material Section

Supplemental Material

Auxiliary Presentation Video

This video presents our paper, accepted at OOPSLA 2020 in the research track, on subsuming resolution through subtyping with intersection types and modus ponens. 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 studied separately. This paper shows that, with a modus ponens 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.

References

  1. 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 ScholarGoogle Scholar
  2. 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 ScholarGoogle Scholar
  3. Nada Amin, Adriaan Moors, and Martin Odersky. 2012. Dependent Object Types. ( 2012 ). http://infoscience.epfl.ch/record/ 183030Google ScholarGoogle Scholar
  4. Jean-marc Andreoli. 1992. Logic Programming with Focusing Proofs in Linear Logic. Journal of Logic and Computation 2 ( 1992 ), 297-347.Google ScholarGoogle Scholar
  5. 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 ScholarGoogle ScholarCross RefCross Ref
  6. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  7. 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 ScholarGoogle Scholar
  8. 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 ScholarGoogle Scholar
  9. 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 ScholarGoogle Scholar
  10. 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 ScholarGoogle Scholar
  11. 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 ScholarGoogle Scholar
  12. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  13. Gilad Bracha and William R. Cook. 1990. Mixin-based Inheritance. In OOPSLA/ECOOP. ACM, 303-311.Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. 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 ScholarGoogle Scholar
  15. Luca Cardelli and Peter Wegner. 1985. On Understanding Types, Data Abstraction, and Polymorphism. ACM Comput. Surv. 17, 4 (Dec. 1985 ), 471-523.Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. 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 ScholarGoogle Scholar
  17. Gang Chen. 2003. Coercive subtyping for the Calculus of Constructions.. In POPL. 150-159.Google ScholarGoogle Scholar
  18. M. Coppo, M. Dezani-Ciancaglini, and B. Venneri. 1981. Functional Characters of Solvable Terms. Math. Log. Q. 27 ( 1981 ), 45-58.Google ScholarGoogle Scholar
  19. 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 ScholarGoogle Scholar
  20. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  21. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  22. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  23. Jana Dunfield. 2012. Elaborating Intersection and Union Types. SIGPLAN Not. 47, 9 (Sept. 2012 ), 17-28.Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Joshua Dunfield. 2015. Elaborating Evaluation-Order Polymorphism. SIGPLAN Not. 50, 9 (Aug. 2015 ), 256-268. https: //doi.org/10.1145/2858949.2784744 Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  26. 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 ScholarGoogle ScholarCross RefCross Ref
  27. 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 ScholarGoogle Scholar
  28. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  29. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  30. Robert A. Kowalski. 1974. Predicate Logic as Programming Language. In IFIP Congress. North-Holland, 569-574.Google ScholarGoogle Scholar
  31. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  32. Olivier Laurent. 2012. Intersection Types with Subtyping by Means of Cut Elimination. Fundam. Inf. 121, 1-4 ( Jan. 2012 ), 203-226.Google ScholarGoogle Scholar
  33. Chuck Liang and Dale Miller. 2009. Focusing and Polarization in Linear, Intuitionistic, and Classical Logics. Theor. Comput. Sci. 410, 46 ( 2009 ), 4747-4768.Google ScholarGoogle Scholar
  34. Zhaohui Luo. 1999. Coercive subtyping. Journal of Logic and Computation 9, 1 ( 1999 ), 105-130.Google ScholarGoogle ScholarCross RefCross Ref
  35. Dale Miller, Gopalan Nadathur, Frank Pfenning, and Andre Scedrov. 1989. Uniform Proofs As a Foundation for Logic Programming. Technical Report.Google ScholarGoogle Scholar
  36. Eugenio Moggi. 1991. Notions of Computation and Monads. Inf. Comput. 93, 1 ( July 1991 ), 55-92.Google ScholarGoogle Scholar
  37. Martin Odersky. 2010. The Scala language specification, version 2.8.Google ScholarGoogle Scholar
  38. 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 ScholarGoogle Scholar
  39. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  40. 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 ScholarGoogle Scholar
  41. Bruno C. d. S. Oliveira, Zhiyuan Shi, and João Alpuim. 2016. Disjoint Intersection Types. SIGPLAN Not. 51, 9 (Sept. 2016 ), 364-377.Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. Benjamin C. Pierce. 1989. A Decision Procedure for the Subtype Relation on Intersection Types with Bounded Variables. Technical Report. Carnegie Mellon University.Google ScholarGoogle Scholar
  43. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  44. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  45. B. C. Pierce and D. Sangiorgi. 1996. Typing and Subtyping for Mobile Processes. Math. Structures in Comput. Sci. 6, 5 ( 1996 ), 409-453.Google ScholarGoogle Scholar
  46. 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 ScholarGoogle Scholar
  47. Jef Raskin. 1974. FLOW: a teaching language for computer programming in the humanities. Computers and the Humanities 8, 4 ( 1974 ), 231-237.Google ScholarGoogle Scholar
  48. 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 ScholarGoogle ScholarCross RefCross Ref
  49. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  50. John C. Reynolds. 1974. Towards a Theory of Type Structure. Lecture Notes in Computer Science, Vol. 19. 408-425.Google ScholarGoogle ScholarCross RefCross Ref
  51. John C. Reynolds. 1988. Preliminary Design of the Programming Language Forsythe. Technical Report. Carnegie Mellon University.Google ScholarGoogle Scholar
  52. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  53. 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 ScholarGoogle Scholar
  54. Jan Schwinghammer. 2009. Coherence of Subsumption for Monadic Types. J. Funct. Program. 19, 2 (March 2009 ), 157-172.Google ScholarGoogle ScholarDigital LibraryDigital Library
  55. 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 ScholarGoogle Scholar
  56. M. Sozeau and N. Oury. 2008b. First-Class Type Classes. In TPHOLs.Google ScholarGoogle Scholar
  57. Rick Statman. 2014. A Finite Model Property for Intersection Types. In ITRS (EPTCS, Vol. 177 ). 1-9.Google ScholarGoogle Scholar
  58. Philip Wadler. 2015. Propositions as Types. Commun. ACM 58, 12 (Nov. 2015 ), 75-84.Google ScholarGoogle Scholar
  59. 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 ScholarGoogle Scholar
  60. Leo White, Frédéric Bour, and Jeremy Yallop. 2015. Modular implicits. Electronic Proceedings in Theoretical Computer Science 198 ( 12 2015 ).Google ScholarGoogle ScholarCross RefCross Ref
  61. 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 ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Resolution as intersection subtyping via Modus Ponens

        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!