Abstract
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.
Chapter PDF
Similar content being viewed by others
References
Abadi, M., Banerjee, A., Heintze, N., Riecke, J.: A Core Calculus of Dependency. In: POPL. ACM (1999). https://doi.org/10.1145/292540.292555
Abel, A.: Resourceful Dependent Types. In: 24th International Conference on Types for Proofs and Programs, Abstracts (2018)
Abel, A., Bernardy, J.: A unified view of modalities in type systems. Proc. ACM Program. Lang. 4(ICFP), 90:1–90:28 (2020). https://doi.org/10.1145/3408972
Abel, A., Scherer, G.: On irrelevance and algorithmic equality in predicative type theory. Log. Methods Comput. Sci. 8(1) (2012). https://doi.org/10.2168/LMCS-8(1:29)2012
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). https://doi.org/10.4230/LIPIcs.TYPES.2017.1
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). https://doi.org/10.1145/3209108.3209189
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). https://doi.org/10.1145/2535838.2535852
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). https://doi.org/10.1145/3158093
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). https://doi.org/10.1007/978-3-540-24849-1_8
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). https://doi.org/10.1007/978-3-642-54833-8_19
Cardelli, L., Wegner, P.: On understanding types, data abstraction, and polymorphism. ACM Computing Surveys 17(4), 471–523 (Dec 1985). https://doi.org/10.1145/6041.6042
Cervesato, I., Pfenning, F.: A linear logical framework. Information and Computation 179(1), 19–75 (2002). https://doi.org/10.1109/LICS.1996.561339
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). https://doi.org/10.1145/3434331
Coquand, T., Huet, G.: The Calculus of Constructions. Ph.D. thesis, INRIA (1986)
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). https://doi.org/10.1109/LICS.2011.22
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). https://doi.org/10.1145/2746325.2746335
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). https://doi.org/10.1007/978-3-540-78800-3_24
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). https://doi.org/10.1007/978-3-540-85373-2_12
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). https://doi.org/10.1145/3290322
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). https://doi.org/10.1145/964001.964025
Eades, H., Stump, A.: Hereditary substitution for Stratified System F. In: International Workshop on Proof-Search in Type Theories, PSTT. vol. 10 (2010)
Gaboardi, M., Haeberlen, A., Hsu, J., Narayan, A., Pierce, B.C.: Linear dependent types for differential privacy. In: POPL. pp. 357–370 (2013). https://doi.org/10.1145/2429069.2429113
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). https://doi.org/10.1145/2951913.2951939
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). https://doi.org/10.1007/3-540-60579-7_2
Ghica, D.R., Smith, A.I.: Bounded linear types in a resource semiring. In: ESOP. pp. 331–350 (2014). https://doi.org/10.1007/978-3-642-54833-8_18
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)
Girard, J.Y.: Linear logic. Theoretical Computer Science 50, 1–102 (1987)
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). https://doi.org/10.1016/0304-3975(92)90386-T
Girard, J., Taylor, P., Lafont, Y.: Proofs and types, vol. 7. Cambridge University Press Cambridge (1989)
Gratzer, D., Sterling, J., Birkedal, L.: Implementing a modal dependent type theory. Proc. ACM Program. Lang. 3(ICFP), 107:1–107:29 (2019). https://doi.org/10.1145/3341711
Henglein, F., Makholm, H., Niss, H.: Effect types and region-based memory management. Advanced Topics in Types and Programming Languages pp. 87–135 (2005)
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)
Hofmann, M.: Syntax and semantics of dependent types. Semantics and logics of computation 14, 79 (1997)
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). https://doi.org/10.4204/EPTCS.292.4
Katsumata, S.: Parametric effect monads and semantics of effect systems. In: Proceedings of POPL. pp. 633–646. ACM (2014). https://doi.org/10.1145/2535838.2535846
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). https://doi.org/10.4230/LIPIcs.CSL.2013.432
Krishnaswami, N.R., Pradic, P., Benton, N.: Integrating linear and dependent types. In: ACM SIGPLAN Notices. vol. 50, pp. 17–30. ACM (2015)
Leivant, D.: Finitely stratified polymorphism. Information and Computation 93(1), 93–113 (1991). https://doi.org/10.1016/0890-5401(91)90053-5
Luo, Z., Zhang, Y.: A linear dependent type theory. Types for Proofs and Programs (TYPES 2016), Novi Sad (2016)
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). https://doi.org/10.1016/S0049-237X(08)71945-1
Martin-Löf, P.: Intuitionistic Type Theory (Jun 1980)
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). https://doi.org/10.1016/S0049-237X(09)70189-2
McBride, C.: I Got Plenty o’ Nuttin’, pp. 207–233. Springer International Publishing, Cham (2016). https://doi.org/10.1007/978-3-319-30936-1_12
Moon, B., Eades III, H., Orchard, D.: Graded modal dependent type theory. CoRR abs/2010.13163 (2020), https://arxiv.org/abs/2010.13163
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). https://doi.org/10.1145/3110276
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). https://doi.org/10.1145/3341714
Palmgren, E.: On universes in type theory. Twenty-five years of constructive type theory 36, 191–204 (1998)
Petricek, T., Orchard, D., Mycroft, A.: Coeffects: Unified Static Analysis of Context-Dependence. In: ICALP (2). pp. 385–397 (2013). https://doi.org/10.1007/978-3-642-39212-2_35
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). https://doi.org/10.1145/2628136.2628160
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). https://doi.org/10.1109/LICS.2001.932499
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). https://doi.org/10.1007/10930755_16
Reynolds, J.C.: Towards a theory of type structure. In: Programming Symposium. pp. 408–425. Springer (1974). https://doi.org/10.1007/3-540-06859-7_148
Reynolds, J.C.: Types, abstraction and parametric polymorphism. In: Information Processing 83, Proceedings of the IFIP 9th World Computer Congres. pp. 513–523 (1983)
Shi, R., Xi, H.: A linear type system for multicore programming in ATS. Science of Computer Programming 78(8), 1176–1192 (2013). https://doi.org/10.1016/j.scico.2012.09.005
Tofte, M., Talpin, J.P.: Region-based memory management. Information and computation 132(2), 109–176 (1997). https://doi.org/10.1006/inco.1996.2613
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). https://doi.org/10.1145/1926385.1926436
Wadler, P.: Theorems for free! In: Proceedings of the fourth international conference on Functional programming languages and computer architecture. pp. 347–359 (1989). https://doi.org/10.1145/99370.99404
Wadler, P.: Linear Types Can Change the World! In: Programming Concepts and Methods. North (1990)
Wadler, P.: Propositions as types. Communications of the ACM 58(12), 75–84 (2015). https://doi.org/10.1145/2699407
Walker, D.: Substructural type systems. Advanced Topics in Types and Programming Languages pp. 3–44 (2005)
Wood, J., Atkey, R.: A Linear Algebra Approach to Linear Metatheory. CoRR abs/2005.02247 (2020), https://arxiv.org/abs/2005.02247
Zalakain, U., Dardha, O.: Pi with leftovers: a mechanisation in Agda. arXiv preprint arXiv:2005.05902 (2020)
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Open Access This chapter is licensed under the terms of the Creative Commons Attribution 4.0 International License (http://creativecommons.org/licenses/by/4.0/), 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.
Copyright information
© 2021 The Author(s)
About this paper
Cite this paper
Moon, B., Eades III, H., Orchard, D. (2021). Graded Modal Dependent Type Theory. In: Yoshida, N. (eds) Programming Languages and Systems. ESOP 2021. Lecture Notes in Computer Science(), vol 12648. Springer, Cham. https://doi.org/10.1007/978-3-030-72019-3_17
Download citation
DOI: https://doi.org/10.1007/978-3-030-72019-3_17
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-030-72018-6
Online ISBN: 978-3-030-72019-3
eBook Packages: Computer ScienceComputer Science (R0)