Graded Modal Dependent Type Theory

Open Access
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 12648)


Graded type theories are an emerging paradigm for augmenting the reasoning power of types with parameterizable, fine-grained analyses of program properties. There have been many such theories in recent years which equip a type theory with quantitative dataflow tracking, usually via a semiring-like structure which provides analysis on variables (often called ‘quantitative’ or ‘coeffect’ theories). We present Graded Modal Dependent Type Theory (Grtt for short), which equips a dependent type theory with a general, parameterizable analysis of the flow of data, both in and between computational terms and types. In this theory, it is possible to study, restrict, and reason about data use in programs and types, enabling, for example, parametric quantifiers and linearity to be captured in a dependent setting. We propose Grtt, study its metatheory, and explore various case studies of its use in reasoning about programs and studying other type theories. We have implemented the theory and highlight the interesting details, including showing an application of grading to optimising the type checking procedure itself.


  1. 1.
    Abadi, M., Banerjee, A., Heintze, N., Riecke, J.: A Core Calculus of Dependency. In: POPL. ACM (1999).
  2. 2.
    Abel, A.: Resourceful Dependent Types. In: 24th International Conference on Types for Proofs and Programs, Abstracts (2018)Google Scholar
  3. 3.
    Abel, A., Bernardy, J.: A unified view of modalities in type systems. Proc. ACM Program. Lang. 4(ICFP), 90:1–90:28 (2020).
  4. 4.
    Abel, A., Scherer, G.: On irrelevance and algorithmic equality in predicative type theory. Log. Methods Comput. Sci. 8(1) (2012).
  5. 5.
    Allais, G.: Typing with Leftovers - A mechanization of Intuitionistic Multiplicative-Additive Linear Logic. In: Abel, A., Forsberg, F.N., Kaposi, A. (eds.) 23rd International Conference on Types for Proofs and Programs (TYPES 2017). Leibniz International Proceedings in Informatics (LIPIcs), vol. 104, pp. 1:1–1:22. Schloss Dagstuhl–Leibniz-Zentrum fuer Informatik, Dagstuhl, Germany (2018).
  6. 6.
    Atkey, R.: 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. pp. 56–65 (2018).
  7. 7.
    Atkey, R., Ghani, N., Johann, P.: A relationally parametric model of dependent type theory. In: Proceedings of the 41st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. pp. 503–515 (2014).
  8. 8.
    Bernardy, J.P., Boespflug, M., Newton, R.R., Peyton Jones, S., Spiwack, A.: Linear Haskell: practical linearity in a higher-order polymorphic language. Proceedings of the ACM on Programming Languages 2(POPL),  5 (2017).
  9. 9.
    Brady, E., McBride, C., McKinna, J.: Inductive families need not store their indices. In: International Workshop on Types for Proofs and Programs. pp. 115–129. Springer (2003).
  10. 10.
    Brunel, A., Gaboardi, M., Mazza, D., Zdancewic, S.: A Core Quantitative Coeffect Calculus. In: Shao, Z. (ed.) Programming Languages and Systems - 23rd European Symposium on Programming, ESOP 2014, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2014, Grenoble, France, April 5-13, 2014, Proceedings. Lecture Notes in Computer Science, vol. 8410, pp. 351–370. Springer (2014).
  11. 11.
    Cardelli, L., Wegner, P.: On understanding types, data abstraction, and polymorphism. ACM Computing Surveys 17(4), 471–523 (Dec 1985).
  12. 12.
    Cervesato, I., Pfenning, F.: A linear logical framework. Information and Computation 179(1), 19–75 (2002).
  13. 13.
    Choudhury, P., Eades III, H., Eisenberg, R.A., Weirich, S.: A Graded Dependent Type System with a Usage-Aware Semantics. Proc. ACM Program. Lang. 5(POPL) (Jan 2021).
  14. 14.
    Coquand, T., Huet, G.: The Calculus of Constructions. Ph.D. thesis, INRIA (1986)Google Scholar
  15. 15.
    Dal Lago, U., Gaboardi, M.: Linear dependent types and relative completeness. In: Logic in Computer Science (LICS), 2011 26th Annual IEEE Symposium on. pp. 133–142. IEEE (2011).
  16. 16.
    De Amorim, A.A., Gaboardi, M., Gallego Arias, E.J., Hsu, J.: Really Natural Linear Indexed Type Checking. In: Proceedings of the 26nd 2014 International Symposium on Implementation and Application of Functional Languages. p. 5. ACM (2014).
  17. 17.
    De Moura, L., Bjørner, N.: Z3: An efficient SMT solver. In: International conference on Tools and Algorithms for the Construction and Analysis of Systems. pp. 337–340. Springer (2008).
  18. 18.
    De Vries, E., Plasmeijer, R., Abrahamson, D.M.: Uniqueness typing simplified. In: Symposium on Implementation and Application of Functional Languages. pp. 201–218. Springer (2007).
  19. 19.
    Dunfield, J., Krishnaswami, N.R.: Sound and complete bidirectional typechecking for higher-rank polymorphism with existentials and indexed types. PACMPL 3(POPL), 9:1–9:28 (2019).
  20. 20.
    Dunfield, J., Pfenning, F.: Tridirectional typechecking. In: Proceedings of the 31st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. pp. 281–292. POPL ’04, ACM, New York, NY, USA (2004).
  21. 21.
    Eades, H., Stump, A.: Hereditary substitution for Stratified System F. In: International Workshop on Proof-Search in Type Theories, PSTT. vol. 10 (2010)Google Scholar
  22. 22.
    Gaboardi, M., Haeberlen, A., Hsu, J., Narayan, A., Pierce, B.C.: Linear dependent types for differential privacy. In: POPL. pp. 357–370 (2013).
  23. 23.
    Gaboardi, M., Katsumata, S.y., Orchard, D., Breuvart, F., Uustalu, T.: Combining Effects and Coeffects via Grading. In: Proceedings of the 21st ACM SIGPLAN International Conference on Functional Programming. p. 476–489. ICFP 2016, Association for Computing Machinery, New York, NY, USA (2016).
  24. 24.
    Geuvers, H.: A short and flexible proof of strong normalization for the calculus of constructions. In: Dybjer, P., Nordström, B., Smith, J. (eds.) Types for Proofs and Programs. pp. 14–38. Springer Berlin Heidelberg, Berlin, Heidelberg (1995).
  25. 25.
    Ghica, D.R., Smith, A.I.: Bounded linear types in a resource semiring. In: ESOP. pp. 331–350 (2014).
  26. 26.
    Girard, J.Y.: Une extension de l’interpretation de gödel a l’analyse, et son application a l’elimination des coupures dans l’analyse et la theorie destypes. In: Studies in Logic and the Foundations of Mathematics, vol. 63, pp. 63–92. Elsevier (1971)Google Scholar
  27. 27.
    Girard, J.Y.: Linear logic. Theoretical Computer Science 50, 1–102 (1987)Google Scholar
  28. 28.
    Girard, J.Y., Scedrov, A., Scott, P.J.: Bounded linear logic: a modular approach to polynomial-time computability. Theoretical computer science 97(1), 1–66 (1992).
  29. 29.
    Girard, J., Taylor, P., Lafont, Y.: Proofs and types, vol. 7. Cambridge University Press Cambridge (1989)Google Scholar
  30. 30.
    Gratzer, D., Sterling, J., Birkedal, L.: Implementing a modal dependent type theory. Proc. ACM Program. Lang. 3(ICFP), 107:1–107:29 (2019).
  31. 31.
    Henglein, F., Makholm, H., Niss, H.: Effect types and region-based memory management. Advanced Topics in Types and Programming Languages pp. 87–135 (2005)Google Scholar
  32. 32.
    Hodas, J.S.: Logic programming in intutionistic linear logic: Theory, design and implementation. PhD Thesis, University of Pennsylvania, Department of Computer and Information Science (1994)Google Scholar
  33. 33.
    Hofmann, M.: Syntax and semantics of dependent types. Semantics and logics of computation 14,  79 (1997)Google Scholar
  34. 34.
    Jiang, J., Eades III, H., de Paiva, V.: On the lambek calculus with an exchange modality. In: Ehrhard, T., Fernández, M., de Paiva, V., de Falco, L.T. (eds.) Proceedings Joint International Workshop on Linearity & Trends in Linear Logic and Applications, Linearity-TLLA@FLoC 2018, Oxford, UK, 7-8 July 2018. EPTCS, vol. 292, pp. 43–89 (2018).
  35. 35.
    Katsumata, S.: Parametric effect monads and semantics of effect systems. In: Proceedings of POPL. pp. 633–646. ACM (2014).
  36. 36.
    Krishnaswami, N.R., Dreyer, D.: Internalizing relational parametricity in the extensional calculus of constructions. In: Computer Science Logic 2013 (CSL2013). Schloss Dagstuhl-Leibniz-Zentrum fuer Informatik (2013).
  37. 37.
    Krishnaswami, N.R., Pradic, P., Benton, N.: Integrating linear and dependent types. In: ACM SIGPLAN Notices. vol. 50, pp. 17–30. ACM (2015)Google Scholar
  38. 38.
    Leivant, D.: Finitely stratified polymorphism. Information and Computation 93(1), 93–113 (1991).
  39. 39.
    Luo, Z., Zhang, Y.: A linear dependent type theory. Types for Proofs and Programs (TYPES 2016), Novi Sad (2016)Google Scholar
  40. 40.
    Martin-Löf, P.: An Intuitionistic Theory of Types: Predicative Part. In: Rose, H.E., Shepherdson, J.C. (eds.) Studies in Logic and the Foundations of Mathematics, Logic Colloquium ’73, vol. 80, pp. 73–118. Elsevier (Jan 1975).
  41. 41.
    Martin-Löf, P.: Intuitionistic Type Theory (Jun 1980)Google Scholar
  42. 42.
    Martin-Löf, P.: Constructive Mathematics and Computer Programming. In: Cohen, L.J., Łoś, J., Pfeiffer, H., Podewski, K.P. (eds.) Studies in Logic and the Foundations of Mathematics, Logic, Methodology and Philosophy of Science VI, vol. 104, pp. 153–175. Elsevier (Jan 1982).
  43. 43.
    McBride, C.: I Got Plenty o’ Nuttin’, pp. 207–233. Springer International Publishing, Cham (2016).
  44. 44.
    Moon, B., Eades III, H., Orchard, D.: Graded modal dependent type theory. CoRR abs/2010.13163 (2020),
  45. 45.
    Nuyts, A., Vezzosi, A., Devriese, D.: Parametric quantifiers for dependent typetheory. Proceedings of the ACM on Programming Languages 1(ICFP), 32:1–32:29 (Aug 2017).
  46. 46.
    Orchard, D., Liepelt, V.B., Eades III, H.: Quantitative Program Reasoning with Graded Modal Types. Proc. ACM Program. Lang. 3(ICFP), 110:1–110:30 (Jul 2019).
  47. 47.
    Palmgren, E.: On universes in type theory. Twenty-five years of constructive type theory 36, 191–204 (1998)Google Scholar
  48. 48.
    Petricek, T., Orchard, D., Mycroft, A.: Coeffects: Unified Static Analysis of Context-Dependence. In: ICALP (2). pp. 385–397 (2013).
  49. 49.
    Petricek, T., Orchard, D., Mycroft, A.: Coeffects: A calculus of context-dependent computation. In: Proceedings of the 19th ACM SIGPLAN International Conference on Functional Programming. pp. 123–135. ICFP ’14, ACM (2014).
  50. 50.
    Pfenning, F.: Intensionality, extensionality, and proof irrelevance in modal type theory. In: Proceedings 16th Annual IEEE Symposium on Logic in Computer Science. pp. 221–230. IEEE (2001).
  51. 51.
    Reed, J.: Extending higher-order unification to support proof irrelevance. In: International Conference on Theorem Proving in Higher Order Logics. pp. 238–252. Springer (2003).
  52. 52.
    Reynolds, J.C.: Towards a theory of type structure. In: Programming Symposium. pp. 408–425. Springer (1974).
  53. 53.
    Reynolds, J.C.: Types, abstraction and parametric polymorphism. In: Information Processing 83, Proceedings of the IFIP 9th World Computer Congres. pp. 513–523 (1983)Google Scholar
  54. 54.
    Shi, R., Xi, H.: A linear type system for multicore programming in ATS. Science of Computer Programming 78(8), 1176–1192 (2013).
  55. 55.
    Tofte, M., Talpin, J.P.: Region-based memory management. Information and computation 132(2), 109–176 (1997).
  56. 56.
    Tov, J.A., Pucella, R.: Practical affine types. In: Proceedings of the 38th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2011, Austin, TX, USA, January 26-28, 2011. pp. 447–458 (2011).
  57. 57.
    Wadler, P.: Theorems for free! In: Proceedings of the fourth international conference on Functional programming languages and computer architecture. pp. 347–359 (1989).
  58. 58.
    Wadler, P.: Linear Types Can Change the World! In: Programming Concepts and Methods. North (1990)Google Scholar
  59. 59.
    Wadler, P.: Propositions as types. Communications of the ACM 58(12), 75–84 (2015).
  60. 60.
    Walker, D.: Substructural type systems. Advanced Topics in Types and Programming Languages pp. 3–44 (2005)Google Scholar
  61. 61.
    Wood, J., Atkey, R.: A Linear Algebra Approach to Linear Metatheory. CoRR abs/2005.02247 (2020),
  62. 62.
    Zalakain, U., Dardha, O.: Pi with leftovers: a mechanisation in Agda. arXiv preprint arXiv:2005.05902 (2020)

Copyright information

© The Author(s) 2021

Open Access This chapter is licensed under the terms of the Creative Commons Attribution 4.0 International License (, 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.

Authors and Affiliations

  1. 1.University of KentCanterburyUK
  2. 2.Augusta UniversityAugustaUSA

Personalised recommendations