skip to main content
research-article
Free Access

Practical Subtyping for Curry-Style Languages

Authors Info & Claims
Published:28 February 2019Publication History
Skip Abstract Section

Abstract

We present a new, syntax-directed framework for Curry-style type systems with subtyping. It supports a rich set of features, and allows for a reasonably simple theory and implementation. The system we consider has sum and product types, universal and existential quantifiers, and inductive and coinductive types. The latter two may carry size invariants that can be used to establish the termination of recursive programs. For example, the termination of quicksort can be derived by showing that partitioning a list does not increase its size. The system deals with complex programs involving mixed induction and coinduction, or even mixed polymorphism and (co-)induction. One of the key ideas is to separate the notion of size from recursion. We do not check the termination of programs directly, but rather show that their (circular) typing proofs are well-founded. Termination is then obtained using a standard (semantic) normalisation proof. To demonstrate the practicality of the system, we provide an implementation accepting all the examples discussed in the article.

References

  1. Martín Abadi, Luca Cardelli, and Gordon Plotkin. 1993. Types for the Scott Numerals. Retrieved on the 12 September, 2016 from http://lucacardelli.name/papers/notes/scott2.ps.Google ScholarGoogle Scholar
  2. Martín Abadi, Georges Gonthier, and Benjamin Werner. 2004. Choice in dynamic linking. In FOSSACS’04 - Foundations of Software Science and Computation Structures 2004, Lecture Notes in Computer Science. Springer, 12--26.Google ScholarGoogle ScholarCross RefCross Ref
  3. Andreas Abel. 1998. Foetus - Termination Checker for Simple Functional Programs. Retrieved on the 7 July, 2017 from http://www2.tcs.ifi.lmu.de/∼abel/foetus.pdf.Google ScholarGoogle Scholar
  4. Andreas Abel. 2006. Semi-continuous Sized Types and Termination. Springer, 72--88. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Andreas Abel and Brigitte Pientka. 2013. Wellfounded recursion with copatterns: A unified approach to termination and productivity. In ICFP Proceedings, Greg Morrisett and Tarmo Uustalu (Eds.). ACM, 185--196. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Roberto M. Amadio and Luca Cardelli. 1993. Subtyping recursive types. ACM Transactions on Programming Languages and Systems 15 (1993). Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. David Baelde, Amina Doumane, and Alexis Saurin. 2015. Least and greatest fixed points in ludics. In CSL (LIPIcs), Vol. 41. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik, 549--566.Google ScholarGoogle Scholar
  8. David Baelde, Amina Doumane, and Alexis Saurin. 2016. Infinitary proof theory: The multiplicative additive case. In CSL (LIPIcs), Vol. 62. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik, 42:1--42:17.Google ScholarGoogle Scholar
  9. John L. Bell. 1993. Hilbert’s ϵ-operator in intuitionistic type theories. Mathematical Logic Quarterly 39, 1 (1993), 323--337.Google ScholarGoogle ScholarCross RefCross Ref
  10. Frédéric Blanqui. 2006. Decidability of type-checking in the calculus of algebraic constructions with size annotations. CoRR abs/cs/0608125.Google ScholarGoogle Scholar
  11. Frédéric Blanqui and Cody Roux. 2009. On the relation between sized-types based termination and semantic labelling. In Proceedings of the 23rd International Workshop on Computer Science Logic (CSL 2009) and the 18th Annual Conference of the EACSL. 147--162. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. James Brotherston. 2005. Cyclic proofs for first-order logic with inductive definitions. In Proceedings of TABLEAUX’05, Lecture Notes in Computer Science, Vol. 3702. Springer-Verlag, 78--92. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Luca Cardelli and Xavier Leroy. 1990. Abstract types and the dot notation. In Proceedings of the IFIP TC2 Working Conference on Programming Concepts and Methods. North-Holland, 479--504.Google ScholarGoogle Scholar
  14. L. Cardelli, S. Martini, J. C. Mitchell, and A. Scedrov. 1991. An extension of system F with subtyping. In Proceedings of TACS, T. Ito and A. R. Meyer (Eds.), Lecture Notes in Computer Science, Vol. 526. 750--770. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Judicaël Courant. 2007. MC<sub>2</sub> A module calculus for pure type systems. Journal of Functional Programming 17, 3 (2007), 287--352.Google ScholarGoogle ScholarCross RefCross Ref
  16. Julien Cretin and Didier Rémy. 2014. System F with coercion constraints. In CSL-LICS Proceedings, Thomas A. Henzinger and Dale Miller (Eds.). ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Luis Damas and Robin Milner. 1982. Principal type-schemes for functional programs. In Proceedings of the 9th ACM Symposium on Principles of Programming Languages. 207--212. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Martin Davis and Ronald Fechter. 1991. A free variable version of the first-order predicate calculus. Journal of Logic and Computation 1, 4 (1991), 431--451.Google ScholarGoogle ScholarCross RefCross Ref
  19. Stephen Dolan and Alan Mycroft. 2017. Polymorphism, subtyping, and type inference in MLsub. In Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages (POPL’17). ACM, 60--72. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Amina Doumane. 2017. On the infinitary proof theory of logics with fixed points. (Théorie de la démonstration infinitaire pour les logiques à points fixes). Ph.D. Dissertation. Paris Diderot University, France.Google ScholarGoogle Scholar
  21. Joshua Dunfield and Neelakantan R. Krishnaswami. 2013. Complete and easy bidirectional typechecking for higher-rank polymorphism. In Proceedings of the 18th ACM SIGPLAN International Conference on Functional Programming (ICFP’13). ACM, New York, 429--442. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Jérôme Fortier and Luigi Santocanale. 2013. Cuts for circular proofs. In TACL (EPiC Series in Computing), Vol. 25. EasyChair, 72--75.Google ScholarGoogle Scholar
  23. Jérôme Fortier and Luigi Santocanale. 2013. Cuts for circular proofs: Semantics and cut-elimination. In CSL (LIPIcs), Vol. 23. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik, 248--262.Google ScholarGoogle Scholar
  24. Jacques Garrigue. 1998. Programming with polymorphic variants. In ML Workshop.Google ScholarGoogle Scholar
  25. Jean-Yves Girard. 1972. Interprétation Fonctionnelle et Élimination des Coupures de l’Arithmétique d’Ordre Supérieur. Ph.D. Dissertation. Université Paris 7.Google ScholarGoogle Scholar
  26. Jean-Yves Girard, Paul Taylor, and Yves Lafont. 1989. Proofs and Types. Cambridge University Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Benjamin Grégoire and Jorge Luis Sacchini. 2010. On strong normalization of the calculus of constructions with type-based termination. In Proceedings of the 17th International Conference on Logic for Programming, Artificial Intelligence, and Reasoning (LPAR-17). 333--347. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. D. Hilbert and P. Bernays. 1968. Grundlagen der Mathematik. Grundlehren der Mathematischen Wissenschaften, Vol. 1.Google ScholarGoogle Scholar
  29. John Hughes, Lars Pareto, and Amr Sabry. 1996. Proving the correctness of reactive systems using sized types. In POPL Proceedings, Hans-Juergen Boehm and Guy L. Steele, Jr. (Eds.). ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Pierre Hyvernat. 2014. The size-change termination principle for constructor based languages. Logical Methods in Computer Science 10, 1 (2014).Google ScholarGoogle Scholar
  31. Frédéric Blanqui (INRIA). 2017. Size-Bases Termination of Higher-Order Rewrite Systems.Google ScholarGoogle Scholar
  32. Frédéric Blanqui (INRIA) and Colin Riba (INPL). 2006. Combining Typing and Size Constraints for Checking the Termination of Higher-Order Conditional Rewrite Systems. Springer, 105--119. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. Dexter Kozen and Rohit Parikh. 1983. A decision procedure for the propositional &mu;-calculus. In Logic of Programs, Lecture Notes in Computer Science, Vol. 164. Springer, 313--325. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. Jean-Louis Krivine. 1987. Un algorithme non typable dans le système F. CRAS 304 (1987).Google ScholarGoogle Scholar
  35. Didier Le Botlan and Didier Rémy. 2003. MLF: Raising ML to the power of system F. SIGPLAN Notices 38, 9 (Aug. 2003), 27--38. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. C. S. Lee, N. D. Jones, and A. M. Ben-Amram. 2001. The size-change principle for program termination. In POPL Proceedings. ACM, 81--92. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. Rodolphe Lepigre. 2016. A classical realizability model for a semantical value restriction. In Proceedings of the 25th European Symposium on Programming (ESOP’16), Peter Thiemann (Ed.), Lecture Notes in Computer Science, Vol. 9632. Springer, 476--502.Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. Rodolphe Lepigre. 2017. Semantics and Implementation of an Extension of ML for Proving Programs. (Sémantique et Implantation d’une Extension de ML pour la Preuve de Programmes). Ph.D. Dissertation. Université Grenoble Alpes, France.Google ScholarGoogle Scholar
  39. R. Lepigre and C. Raffalli. 2015. SubML Implementation. https://github.com/rlepigre/subml/.Google ScholarGoogle Scholar
  40. The Coq development team. 2004. The Coq Proof Assistant Reference Manual. LogiCal Project.Google ScholarGoogle Scholar
  41. John C. Mitchell. 1988. Polymorphic type inference and containment. Information and Computation 76, 2 (1988), 211--249. Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. John C. Mitchell, Sigurd Meldal, and Neel Madhav. 1991. An extension of standard ML modules with subtyping and inheritance. In POPL. ACM, 270--278. Google ScholarGoogle ScholarDigital LibraryDigital Library
  43. Ulf Norell. 2009. Dependently typed programming in agda. In Proceedings of the 4th International Workshop on Types in Language Design and Implementation (TLDI’09). Google ScholarGoogle ScholarDigital LibraryDigital Library
  44. Miche Parigot. 1992. Un récurseur fortement normalisable et typable pour les entiers de Scott. Private communication.Google ScholarGoogle Scholar
  45. Simon Peyton Jones, Dimitrios Vytiniotis, Stephanie Weirich, and Mark Shields. 2007. Practical type inference for arbitrary-rank types. Journal of Functional Programming 17, 1 (Jan. 2007), 1--82. Google ScholarGoogle ScholarDigital LibraryDigital Library
  46. Benjamin C. Pierce. 2002. Types and Programming Languages. MIT Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  47. François Pottier. 1998. Synthèse de types en présence de sous-typage: de la théorie à la pratique. Ph.D. Dissertation. Université Paris 7.Google ScholarGoogle Scholar
  48. C. Raffalli. 1998. Type checking in system F<sup>&eta;</sup>. In Prépublication 98-05a du LAMA.Google ScholarGoogle Scholar
  49. C. Raffalli. 2008. The PhoX Proof Assistant. Retrieved on the 12 September, 2016 from https://www.lama.univ-smb.fr/&sim;raffalli/phox.html.Google ScholarGoogle Scholar
  50. C. Raffalli. 2012. The PML Programming Language. Retrieved 12 September, 2016 from https://www.lama.univ-smb.fr/tracpml.Google ScholarGoogle Scholar
  51. Didier Rémy. 2005. Simple, partial type-inference for system F based on type-containment. In Proceedings of the 10th ACM SIGPLAN International Conference on Functional Programming (ICFP’05). ACM, New York, 130--143. Google ScholarGoogle ScholarDigital LibraryDigital Library
  52. Christian Retoré. 2014. Typed Hilbert epsilon operators and the semantics of determiner phrases. In Formal Grammar, Glyn Morrill, Reinhard Muskens, Rainer Osswald, and Frank Richter (Eds.). Springer, Berlin, 15--33. Google ScholarGoogle ScholarDigital LibraryDigital Library
  53. John C. Reynolds. 1974. Towards a theory of type structure. In Programming Symposium, Proceedings Colloque sur la Programmation. Springer-Verlag, 408--423. Google ScholarGoogle ScholarDigital LibraryDigital Library
  54. Jorge Luis Sacchini. 2013. Type-based productivity of stream definitions in the calculus of constructions. In Proceedings of the 28th Annual ACM/IEEE Symposium on Logic in Computer Science (LICS’13). 233--242. Google ScholarGoogle ScholarDigital LibraryDigital Library
  55. Jorge Luis Sacchini. 2015. Well-Founded Sized Types in the Calculus of (Co)Inductive Constructions. Retrieved on the 12 September, 2016 from http://cs.ioc.ee/types15/abstracts-book/contrib30.pdf.Google ScholarGoogle Scholar
  56. Luigi Santocanale. 2002. A calculus of circular proofs and its categorical semantics. In FoSSaCS, Lecture Notes in Computer Science, Vol. 2303. Springer, 357--371. Google ScholarGoogle ScholarDigital LibraryDigital Library
  57. Luigi Santocanale. 2002. From parity games to circular proofs. Electronic Notes in Theoretical Computer Science 65, 1 (2002), 305--316.Google ScholarGoogle ScholarCross RefCross Ref
  58. Ulrich Schöpp and Alex Simpson. 2002. Verifying temporal properties using explicit approximants: Completeness for context-free processes. In FOSSACS’02. Springer-Verlag, 372--386. Google ScholarGoogle ScholarDigital LibraryDigital Library
  59. Christoph Sprenger and Mads Dam. 2003. On global induction mechanisms in a &mu;-calculus with explicit approximations. ITA 37, 4 (2003), 365--391. https://dblp.uni-trier.de/rec/bibtex/journals/ita/SprengerD03.Google ScholarGoogle Scholar
  60. Christoph Sprenger and Mads Dam. 2003. On the structure of inductive reasoning: Circular and tree-shaped proofs in the &mu;-calculus. In Proceedings of FOSSACS 2003. Springer, 425--440. Google ScholarGoogle ScholarDigital LibraryDigital Library
  61. J. Tiuryn and P. Urzyczyn. 2002. The subtyping problem for second-order types is undecidable. Information and Computation 179, 1 (2002), 1--18. Google ScholarGoogle ScholarDigital LibraryDigital Library
  62. Klaus Von Heusinger. 1997. Definite Descriptions and Choice Functions. Springer Netherlands, Dordrecht, 61--91.Google ScholarGoogle Scholar
  63. J. B. Wells. 1994. Typability and type-checking in the second-order lambda-calculus are equivalent and undecidable. In LICS Proceedings. IEEE Computer Society, 176--185.Google ScholarGoogle Scholar
  64. J. B. Wells. 1996. Typability is Undecidable for F+Eta. Technical Report. Boston, MA. Google ScholarGoogle ScholarDigital LibraryDigital Library
  65. J. B. Wells. 1999. Typability and type checking in System F are equivalent and undecidable. Annals of Pure and Applied Logic 98, 1 (1999), 111--156.Google ScholarGoogle ScholarCross RefCross Ref

Index Terms

  1. Practical Subtyping for Curry-Style Languages

      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

      HTML Format

      View this article in HTML Format .

      View HTML Format
      About Cookies On This Site

      We use cookies to ensure that we give you the best experience on our website.

      Learn more

      Got it!