skip to main content
research-article
Open Access
Artifacts Available
Artifacts Evaluated & Functional

Quantitative program reasoning with graded modal types

Published:26 July 2019Publication History
Skip Abstract Section

Abstract

In programming, some data acts as a resource (e.g., file handles, channels) subject to usage constraints. This poses a challenge to software correctness as most languages are agnostic to constraints on data. The approach of linear types provides a partial remedy, delineating data into resources to be used but never copied or discarded, and unconstrained values. Bounded Linear Logic provides a more fine-grained approach, quantifying non-linear use via an indexed-family of modalities. Recent work on coeffect types generalises this idea to graded comonads, providing type systems which can capture various program properties. Here, we propose the umbrella notion of graded modal types, encompassing coeffect types and dual notions of type-based effect reasoning via graded monads. In combination with linear and indexed types, we show that graded modal types provide an expressive type theory for quantitative program reasoning, advancing the reach of type systems to capture and verify a broader set of program properties. We demonstrate this approach via a type system embodied in a fully-fledged functional language called Granule, exploring various examples.

Skip Supplemental Material Section

Supplemental Material

a110-orchard.webm

webm

103.4 MB

References

  1. Samson Abramsky. 1993. Computational interpretations of linear logic. Theoretical computer science 111, 1-2 (1993), 3–57. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Michael Arntzenius and Neelakantan R. Krishnaswami. 2016. Datafun: a functional Datalog. In Proceedings of the 21st ACM SIGPLAN International Conference on Functional Programming, ICFP 2016, Nara, Japan, September 18-22, 2016. 214–227. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Robert Atkey. 2018. Syntax and Semantics of Quantitative Type Theory. In Proceedings of the 33rd Annual ACM/IEEE Symposium on Logic in Computer Science, LICS 2018, Oxford, UK, July 09-12, 2018. 56–65. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Robert Atkey and James Wood. 2018. Context Constrained Computation. In Workshop on Type-Driven Development, colocated with ICFP 2018.Google ScholarGoogle Scholar
  5. Andrew Barber and Gordon Plotkin. 1996. Dual intuitionistic linear logic. University of Edinburgh, Department of Computer Science, Laboratory for Foundations of Computer Science.Google ScholarGoogle Scholar
  6. Clark Barrett, Aaron Stump, Cesare Tinelli, et al. 2010. The SMT-LIB Standard: Version 2.0. In Proceedings of the 8th International Workshop on Satisfiability Modulo Theories (Edinburgh, England), Vol. 13. 14.Google ScholarGoogle Scholar
  7. P. Nick Benton, Gavin M. Bierman, and Valeria de Paiva. 1998. Computational Types from a Logical Perspective. J. Funct. Program. 8, 2 (1998), 177–193. http://journals.cambridge.org/action/displayAbstract?aid=44159 Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Jean-Philippe Bernardy, Mathieu Boespflug, Ryan R Newton, Simon Peyton Jones, and Arnaud Spiwack. 2017. Linear Haskell: Practical linearity in a higher-order polymorphic language. Proceedings of the ACM on Programming Languages 2, POPL (2017), 5. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Gavin M. Bierman and Valeria CV de Paiva. 2000. On an intuitionistic modal logic. Studia Logica 65, 3 (2000), 383–416.Google ScholarGoogle ScholarCross RefCross Ref
  10. Flavien Breuvart and Michele Pagani. 2015. Modelling coeffects in the relational semantics of linear logic. In 24th EACSL Annual Conference on Computer Science Logic (CSL 2015). Schloss Dagstuhl-Leibniz-Zentrum fuer Informatik.Google ScholarGoogle Scholar
  11. Aloïs Brunel, Marco Gaboardi, Damiano Mazza, and Steve Zdancewic. 2014. A core quantitative coeffect calculus. In European Symposium on Programming Languages and Systems. Springer, 351–370. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. TH Brus, Marko CJD van Eekelen, MO Van Leer, and Marinus J Plasmeijer. 1987. Clean—a language for functional graph rewriting. In Conference on Functional Programming Languages and Computer Architecture. Springer, 364–384. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Luís Caires and Frank Pfenning. 2010. Session Types as Intuitionistic Linear Propositions. In CONCUR 2010 - Concurrency Theory, 21th International Conference, CONCUR 2010, Paris, France, August 31-September 3, 2010. Proceedings. 222–236. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Iliano Cervesato and Frank Pfenning. 2002. A linear logical framework. Information and Computation 179, 1 (2002), 19–75. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Ugo Dal Lago and Marco Gaboardi. 2011. Linear dependent types and relative completeness. In Logic in Computer Science (LICS), 2011 26th Annual IEEE Symposium on. IEEE, 133–142. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Nils Anders Danielsson. 2008. Lightweight semiformal time complexity analysis for purely functional data structures. In ACM SIGPLAN Notices, Vol. 43. ACM, 133–144. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Arthur Azevedo De Amorim, Marco Gaboardi, Emilio Jesús Gallego Arias, and Justin Hsu. 2014. Really Natural Linear Indexed Type Checking. In Proceedings of the 26nd 2014 International Symposium on Implementation and Application of Functional Languages. ACM, 5. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Arthur Azevedo de Amorim, Marco Gaboardi, Justin Hsu, Shin-ya Katsumata, and Ikram Cherigui. 2017. A semantic account of metric preservation. In Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages, POPL 2017, Paris, France, January 18-20, 2017. 545–556. http://dl.acm.org/citation.cfm?id=3009890 Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Leonardo De Moura and Nikolaj Bjørner. 2008. Z3: An efficient SMT solver. In International conference on Tools and Algorithms for the Construction and Analysis of Systems. Springer, 337–340. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Joshua Dunfield and Neelakantan R Krishnaswami. 2013. Complete and easy bidirectional typechecking for higher-rank polymorphism. In ACM SIGPLAN Notices, Vol. 48. ACM, 429–442. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Joshua Dunfield and Neelakantan R. Krishnaswami. 2019. Sound and complete bidirectional typechecking for higher-rank polymorphism with existentials and indexed types. PACMPL 3, POPL (2019), 9:1–9:28. https://dl.acm.org/citation.cfm? id=3290322 Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Joshua Dunfield and Frank Pfenning. 2004. Tridirectional Typechecking. In Proceedings of the 31st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’04). ACM, New York, NY, USA, 281–292. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Soichiro Fujii, Shinya Katsumata, and Paul-André Melliès. 2016. Towards a formal theory of graded monads. In FOSSACS. Springer, 513–530.Google ScholarGoogle Scholar
  24. Marco Gaboardi, Andreas Haeberlen, Justin Hsu, Arjun Narayan, and Benjamin C Pierce. 2013. Linear dependent types for differential privacy. In POPL. 357–370. http://dl.acm.org/citation.cfm?id=2429113 Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Marco Gaboardi, Shin-ya Katsumata, Dominic A. Orchard, Flavien Breuvart, and Tarmo Uustalu. 2016. Combining effects and coeffects via grading. In Proceedings of the 21st ACM SIGPLAN International Conference on Functional Programming, ICFP 2016, Nara, Japan, September 18-22, 2016. 476–489. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Simon J. Gay and Vasco Thudichum Vasconcelos. 2010. Linear type theory for asynchronous session types. J. Funct. Program. 20, 1 (2010), 19–50. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Dan R. Ghica and Alex I. Smith. 2014. Bounded linear types in a resource semiring. In Programming Languages and Systems. Springer, 331–350. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Jean-Yves Girard. 1987. Linear logic. Theoretical computer science 50, 1 (1987), 1–101. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Jean-Yves Girard, Andre Scedrov, and Philip J Scott. 1992. Bounded linear logic: a modular approach to polynomial-time computability. Theoretical computer science 97, 1 (1992), 1–66. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Joshua S Hodas. 1994. Logic Programming in Intutionistic Linear Logic: Theory, Design and Implementation. PhD Thesis, University of Pennsylvania, Department of Computer and Information Science (1994).Google ScholarGoogle Scholar
  31. Futoshi Iwama, Atsushi Igarashi, and Naoki Kobayashi. 2006. Resource usage analysis for a functional language with exceptions. In Proceedings of the 2006 ACM SIGPLAN symposium on Partial evaluation and semantics-based program manipulation (PEPM). ACM, 38–47. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. Simon Peyton Jones. 2003. Haskell 98 language and libraries: the revised report. Cambridge University Press.Google ScholarGoogle Scholar
  33. Shin-ya Katsumata. 2014. Parametric effect monads and semantics of effect systems. In Proceedings of POPL 2014. ACM, 633–645. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. Shin-ya Katsumata. 2018. A Double Category Theoretic Analysis of Graded Linear Exponential Comonads. In International Conference on Foundations of Software Science and Computation Structures. Springer, 110–127.Google ScholarGoogle Scholar
  35. Neelakantan R. Krishnaswami, Pierre Pradic, and Nick Benton. 2015. Integrating Linear and Dependent Types. In Proceedings of the 42Nd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’15). ACM, New York, NY, USA, 17–30. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. Nicholas D Matsakis and Felix S Klock II. 2014. The Rust Language. In ACM SIGAda Ada Letters, Vol. 34. ACM, 103–104. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. Karl Mazurak, Jianzhou Zhao, and Steve Zdancewic. 2010. Lightweight linear types in System F ◦ . In Proceedings of TLDI 2010: 2010 ACM SIGPLAN International Workshop on Types in Languages Design and Implementation, Madrid, Spain, January 23, 2010. 77–88. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. Conor McBride. 2016. I got Plenty o’ Nuttin’. In A List of Successes That Can Change the World. Springer, 207–233.Google ScholarGoogle Scholar
  39. Conor McBride and James McKinna. 2004. The view from the left. Journal of functional programming 14, 1 (2004), 69–111. Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. Stefan Milius, Dirk Pattinson, and Lutz Schröder. 2015. Generic trace semantics and graded monads. In 6th Conference on Algebra and Coalgebra in Computer Science (CALCO 2015). Schloss Dagstuhl-Leibniz-Zentrum fuer Informatik.Google ScholarGoogle Scholar
  41. Robin Milner, Mads Tofte, Robert Harper, and David MacQueen. 1997. The Definition of Standard ML: revised. MIT press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. J Garrett Morris. 2016. The best of both worlds: linear functional programming without compromise. In ACM SIGPLAN Notices, Vol. 51. ACM, 448–461.Google ScholarGoogle ScholarDigital LibraryDigital Library
  43. Alan Mycroft, Dominic Orchard, and Tomas Petricek. 2016. Effect systems revisited – control-flow algebra and semantics. In Semantics, Logics, and Calculi: Essays Dedicated to Hanne Riis Nielson and Flemming Nielson on the Occasion of Their 60th Birthdays. Springer, 1–32. Google ScholarGoogle ScholarDigital LibraryDigital Library
  44. Dominic Orchard and Vilem-Benjamin Liepelt. 2017. Gram: A linear functional language with graded modal (extended abstract). In Workshop on Trends in Linear Logic and Applications (TLLA).Google ScholarGoogle Scholar
  45. Dominic A. Orchard, Tomas Petricek, and Alan Mycroft. 2014. The semantic marriage of monads and effects. CoRR abs/1401.5391 (2014). http://arxiv.org/abs/1401.5391Google ScholarGoogle Scholar
  46. Tomas Petricek, Dominic Orchard, and Alan Mycroft. 2013. Coeffects: Unified Static Analysis of Context-Dependence. In ICALP (2). 385–397. Google ScholarGoogle ScholarDigital LibraryDigital Library
  47. Tomas Petricek, Dominic Orchard, and Alan Mycroft. 2014. Coeffects: a calculus of context-dependent computation. In Proceedings of the 19th ACM SIGPLAN international conference on Functional programming. ACM, 123–135. Google ScholarGoogle ScholarDigital LibraryDigital Library
  48. Simon Peyton Jones, Dimitrios Vytiniotis, Stephanie Weirich, and Geoffrey Washburn. 2006. Simple unification-based type inference for GADTs. In ACM SIGPLAN Notices, Vol. 41. ACM, 50–61. Google ScholarGoogle ScholarDigital LibraryDigital Library
  49. Frank Pfenning and Rowan Davies. 2001. A judgmental reconstruction of modal logic. Mathematical structures in computer science 11, 4 (2001), 511–540. Google ScholarGoogle ScholarDigital LibraryDigital Library
  50. Jeff Polakow. 2015. Embedding a Full Linear Lambda Calculus in Haskell. SIGPLAN Not. 50, 12, 177–188. Google ScholarGoogle ScholarDigital LibraryDigital Library
  51. Dag Prawitz. 1965. Natural Deduction: A proof-theoretical study. Stockholm Studies in Philosophy. Almqvist & Wiksell, Stockholm 3 (1965).Google ScholarGoogle Scholar
  52. A.L. Smirnov. 2008. Graded monads and rings of polynomials. Journal of Mathematical Sciences 151, 3 (2008), 3032–3051.Google ScholarGoogle ScholarCross RefCross Ref
  53. K. Terui. 2001. Light Affine Lambda Calculus and Polytime Strong Normalization. In LICS ’01. IEEE Computer Society, 209–220.Google ScholarGoogle Scholar
  54. Jesse A Tov and Riccardo Pucella. 2010. Stateful contracts for affine types. In European Symposium on Programming. Springer, 550–569. Google ScholarGoogle ScholarDigital LibraryDigital Library
  55. Jesse A. Tov and Riccardo Pucella. 2011. Practical Affine Types. In Proceedings of the 38th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’11). ACM, New York, NY, USA, 447–458. Google ScholarGoogle ScholarDigital LibraryDigital Library
  56. Philip Wadler. 1990. Linear types can change the world. In IFIP TC, Vol. 2. 347–359.Google ScholarGoogle Scholar
  57. Philip Wadler. 1992. There’s no substitute for linear logic. In 8th International Workshop on the Mathematical Foundations of Programming Semantics.Google ScholarGoogle Scholar
  58. Philip Wadler. 1993. A Syntax for Linear Logic. In Mathematical Foundations of Programming Semantics, 9th International Conference, New Orleans, LA, USA, April 7-10, 1993, Proceedings. 513–529. Google ScholarGoogle Scholar
  59. David Walker. 2005. Substructural type systems. Advanced Topics in Types and Programming Languages (2005), 3–44.Google ScholarGoogle Scholar
  60. Hongwei Xi. 2003. Applied type system. In International Workshop on Types for Proofs and Programs. Springer, 394–408.Google ScholarGoogle Scholar
  61. Nobuko Yoshida and Vasco Thudichum Vasconcelos. 2007. Language Primitives and Type Discipline for Structured Communication-Based Programming Revisited: Two Systems for Higher-Order Session Communication. Electr. Notes Theor. Comput. Sci. 171, 4 (2007), 73–93. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Quantitative program reasoning with graded modal types

            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