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

Implementing a modal dependent type theory

Published:26 July 2019Publication History
Skip Abstract Section

Abstract

Modalities are everywhere in programming and mathematics! Despite this, however, there are still significant technical challenges in formulating a core dependent type theory with modalities. We present a dependent type theory MLTT🔒 supporting the connectives of standard Martin-Löf Type Theory as well as an S4-style necessity operator. MLTT🔒 supports a smooth interaction between modal and dependent types and provides a common basis for the use of modalities in programming and in synthetic mathematics. We design and prove the soundness and completeness of a type checking algorithm for MLTT🔒, using a novel extension of normalization by evaluation. We have also implemented our algorithm in a prototype proof assistant for MLTT🔒, demonstrating the ease of applying our techniques.

Skip Supplemental Material Section

Supplemental Material

a107-gratzer.webm

References

  1. Martín Abadi, Anindya Banerjee, Nevin Heintze, and Jon G. Riecke. 1999. A Core Calculus of Dependency. Conference Record of the Annual ACM Symposium on Principles of Programming Languages, 147–160. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Andreas Abel. 2009. Extensional normalization in the logical framework with proof irrelevant equality. In 2009 Workshop on Normalization by Evaluation.Google ScholarGoogle Scholar
  3. Andreas Abel. 2013. Normalization by Evaluation: Dependent Types and Impredicativity.Google ScholarGoogle Scholar
  4. Andreas Abel, Klaus Aehlig, and Peter Dybjer. 2007. Normalization by Evaluation for Martin-LöF Type Theory with One Universe. Electron. Notes Theor. Comput. Sci. 173 (April 2007), 17–39. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Andreas Abel, Thierry Coquand, and Miguel Pagano. 2009. A Modular Type-Checking Algorithm for Type Theory with Singleton Types and Proof Irrelevance. In Typed Lambda Calculi and Applications, Pierre-Louis Curien (Ed.). Springer Berlin Heidelberg, 5–19. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Andreas Abel, Andrea Vezzosi, and Theo Winterhalter. 2017. Normalization by Evaluation for Sized Dependent Types. Proc. ACM Program. Lang. 1, ICFP (Aug. 2017), 33:1–33:30. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Stuart Frazier Allen. 1987. A non-type-theoretic semantics for type-theoretic language.Google ScholarGoogle Scholar
  8. Thorsten Altenkirch, Martin Hofmann, and Thomas Streicher. 1995. Categorical reconstruction of a reduction free normalization proof. In Category Theory and Computer Science, David Pitt, David E. Rydeheard, and Peter Johnstone (Eds.). Springer Berlin Heidelberg, 182–199. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Carlo Angiuli. 2019. Computational Semantics of Cartesian Cubical Type Theory. Ph.D. Dissertation. Carnegie Mellon University, Pittsburgh, PA, USA. To appear.Google ScholarGoogle Scholar
  10. Carlo Angiuli, Guillaume Brunerie, Thierry Coquand, Kuen-Bang Hou (Favonia), Robert Harper, and Daniel R. Licata. 2019. Cartesian Cubical Type Theory. (Feb. 2019). https://github.com/dlicata335/cart-cube Preprint.Google ScholarGoogle Scholar
  11. P. Bahr, H. B. Grathwohl, and R. E. Møgelberg. 2017. The clocks are ticking: No more delays!. In 2017 32nd Annual ACM/IEEE Symposium on Logic in Computer Science (LICS). 1–12. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Ulrich Berger and H Schwichtenberg. 1991. An inverse of the evaluation functional for typed λ-calculus. Proceedings -Symposium on Logic in Computer Science, 203–211.Google ScholarGoogle ScholarCross RefCross Ref
  13. Lars Birkedal, Aleš Bizjak, Ranald Clouston, Hans Bugge Grathwohl, Bas Spitters, and Andrea Vezzosi. 2016. Guarded Cubical Type Theory: Path Equality for Guarded Recursion. In 25th EACSL Annual Conference on Computer Science Logic (CSL 2016) (Leibniz International Proceedings in Informatics (LIPIcs)), Jean-Marc Talbot and Laurent Regnier (Eds.), Vol. 62. Schloss Dagstuhl–Leibniz-Zentrum fuer Informatik, 23:1–23:17.Google ScholarGoogle Scholar
  14. Lars Birkedal, Rasmus Ejlers Møgelberg, Jan Schwinghammer, and Kristian Stovring. 2011. First Steps in Synthetic Guarded Domain Theory: Step-Indexing in the Topos of Trees. In Proceedings of the 2011 IEEE 26th Annual Symposium on Logic in Computer Science (LICS ’11). IEEE Computer Society, 55–64. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Aleš Bizjak and Lars Birkedal. 2018. On Models of Higher-Order Separation Logic. Electr. Notes Theor. Comput. Sci. 336 (2018), 57–78.Google ScholarGoogle ScholarCross RefCross Ref
  16. Aleš Bizjak, Hans Bugge Grathwohl, Ranald Clouston, Rasmus E. Møgelberg, and Lars Birkedal. 2016. Guarded Dependent Type Theory with Coinductive Types. In Foundations of Software Science and Computation Structures: 19th International Conference, FOSSACS 2016, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2016, Eindhoven, The Netherlands, April 2–8, 2016, Proceedings, Bart Jacobs and Christof Löding (Eds.). Springer Berlin Heidelberg, 20–35.Google ScholarGoogle Scholar
  17. Aleš Bizjak and Rasmus Ejlers Møgelberg. 2015. A Model of Guarded Recursion With Clock Synchronisation. Electron. Notes Theor. Comput. Sci. 319, C (Dec. 2015), 83–101. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Mathieu Boespflug and Brigitte Pientka. 2011. Multi-level Contextual Type Theory. Electronic Proceedings in Theoretical Computer Science 71 (Oct. 2011).Google ScholarGoogle Scholar
  19. V. A. J. Borghuis. 1994. Coming to terms with modal logic : on the interpretation of modalities in typed lambda-calculus.Google ScholarGoogle Scholar
  20. Peter Brottveit Bock and Carsten Schürmann. 2015. A Contextual Logical Framework, Vol. 9450. 402–417.Google ScholarGoogle Scholar
  21. Ranald Clouston. 2018. Fitch-Style Modal Lambda Calculi. In Foundations of Software Science and Computation Structures, Christel Baier and Ugo Dal Lago (Eds.). Springer International Publishing, 258–275.Google ScholarGoogle Scholar
  22. Ranald Clouston, Aleš Bizjak, Hans Bugge Grathwohl, and Lars Birkedal. 2015. Programming and Reasoning with Guarded Recursion for Coinductive Types. In Foundations of Software Science and Computation Structures, Andrew Pitts (Ed.). Springer Berlin Heidelberg, 407–421.Google ScholarGoogle Scholar
  23. Ranald Clouston, Bassel Mannaa, Rasmus Ejlers Møgelberg, Andrew M. Pitts, and Bas Spitters. 2018. Modal Dependent Type Theory and Dependent Right Adjoints. (2018). https://arxiv.org/abs/1804.05236Google ScholarGoogle Scholar
  24. The Coq Development Team. 2016. The Coq Proof Assistant Reference Manual.Google ScholarGoogle Scholar
  25. Thierry Coquand. 1996. An algorithm for type-checking dependent types. Science of Computer Programming 26, 1 (1996), 167–177. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Thierry Coquand. 2018. Canonicity and normalization for Dependent Type Theory. https://arxiv.org/abs/1810.09367Google ScholarGoogle Scholar
  27. Rowan Davies and Frank Pfenning. 1999. A Modal Analysis of Staged Computation. J. ACM 48 (Sept. 1999). Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Jeff Epstein, Andrew Black, and Simon Peyton Jones. 2011. Towards Haskell in the cloud. https://www.microsoft.com/enus/research/publication/towards-haskell-cloud/Google ScholarGoogle Scholar
  29. Marcelo Fiore. 2002. Semantic Analysis of Normalisation by Evaluation for Typed Lambda Calculus. In Proceedings of the 4th ACM SIGPLAN International Conference on Principles and Practice of Declarative Programming (PPDP ’02). ACM, 26–37. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Peter Freyd. 1991. Algebraically complete categories. In Category Theory, Aurelio Carboni, Maria Cristina Pedicchio, and Guiseppe Rosolini (Eds.). Springer Berlin Heidelberg, 95–104.Google ScholarGoogle Scholar
  31. Johan G. Granström. 2013. Treatise on Intuitionistic Type Theory. Springer Publishing Company, Incorporated. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. Adrien Guatto. 2018. A Generalized Modality for Recursion. In Proceedings of the 33rd Annual ACM/IEEE Symposium on Logic in Computer Science, LICS 2018, Oxford, UK, July 09-12, 2018. 482–491. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. Robert Harper and Daniel R. Licata. 2007. Mechanizing Metatheory in a Logical Framework. Journal of Functional Programming 17, 4-5 (July 2007), 613–673. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. G. A. Kavvos. 2017. Dual-Context Calculi for Modal Logic. In Proceedings of the 32nd Annual ACM/IEEE Symposium on Logic in Computer Science (LICS). http://arxiv.org/abs/1602.04860 Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. Robbert Krebbers, Ralf Jung, Aleš Bizjak, Jacques-Henri Jourdan, Derek Dreyer, and Lars Birkedal. 2017. The Essence of Higher-Order Concurrent Separation Logic. In European Symposium on Programming. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. F. William Lawvere. 1992. Categories of Space and of Quantity. In The Space of Mathematics, Javier Echeverria, Andoni Ibarra, and Thomas Mormann (Eds.). De Gruyter, 14–30.Google ScholarGoogle Scholar
  37. F. William Lawvere. 2007. Axiomatic Cohesion. Theory and Applications of Categories 19 (June 2007).Google ScholarGoogle Scholar
  38. Daniel R. Licata, Ian Orton, Andrew M. Pitts, and Bas Spitters. 2018. Internal Universes in Models of Homotopy Type Theory. In 3rd International Conference on Formal Structures for Computation and Deduction, FSCD 2018, July 9-12, 2018, Oxford, UK. 22:1–22:17.Google ScholarGoogle Scholar
  39. Daniel R. Licata, Michael Shulman, and Mitchell Riley. 2017. A Fibrational Framework for Substructural and Modal Logics. In 2nd International Conference on Formal Structures for Computation and Deduction (FSCD 2017) (Leibniz International Proceedings in Informatics (LIPIcs)), Dale Miller (Ed.), Vol. 84. Schloss Dagstuhl–Leibniz-Zentrum fuer Informatik, 25:1– 25:22.Google ScholarGoogle Scholar
  40. Bassel Mannaa and Rasmus Ejlers Møgelberg. 2018. The Clocks They Are Adjunctions Denotational Semantics for Clocked Type Theory. In 3rd International Conference on Formal Structures for Computation and Deduction (FSCD 2018) (Leibniz International Proceedings in Informatics (LIPIcs)), Hélène Kirchner (Ed.), Vol. 108. Schloss Dagstuhl–Leibniz-Zentrum fuer Informatik, Dagstuhl, Germany, 23:1–23:17.Google ScholarGoogle Scholar
  41. Per Martin-Löf. 1975. An Intuitionistic Theory of Types: Predicative Part. In Logic Colloquium ’73, H. E. Rose and J. C. Shepherdson (Eds.). Studies in Logic and the Foundations of Mathematics, Vol. 80. Elsevier, 73–118.Google ScholarGoogle Scholar
  42. Per Martin-Löf. 1992. Substitution calculus. Notes from a lecture given in Göteborg.Google ScholarGoogle Scholar
  43. Per Martin-Löf. 1996. On the meanings of the logical constants and the justifications of the logical laws. Nordic Journal of Philosophical Logic 1, 1 (1996), 11–60.Google ScholarGoogle Scholar
  44. Simone Martini and Andrea Masini. 1996. A Computational Interpretation of Modal Proofs. Springer Netherlands, Dordrecht, 213–241.Google ScholarGoogle Scholar
  45. Conor McBride and Ross Paterson. 2008. Applicative Programming with Effects. J. Funct. Program. 18, 1 (Jan. 2008), 1–13. Google ScholarGoogle ScholarDigital LibraryDigital Library
  46. Tom Murphy, VII. 2008. Modal Types for Mobile Code. http://tom7.org/papers/ Available as technical report CMU-CS-08-126.Google ScholarGoogle ScholarDigital LibraryDigital Library
  47. Tom Murphy, VII, Karl Crary, Robert Harper, and Frank Pfenning. 2004. A Symmetric Modal Lambda Calculus for Distributed Computing. In Proceedings of the 19th IEEE Symposium on Logic in Computer Science (LICS 2004). IEEE Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  48. Aleksandar Nanevski, Frank Pfenning, and Brigitte Pientka. 2008. Contextual modal type theory. ACM Transactions Computational Logic 9 (June 2008). Google ScholarGoogle ScholarDigital LibraryDigital Library
  49. Ulf Norell. 2007. Towards a practical programming language based on dependent type theory. Ph.D. Dissertation. Department of Computer Science and Engineering, Chalmers University of Technology.Google ScholarGoogle Scholar
  50. Frank Pfenning and Rowan Davies. 2000. A Judgmental Reconstruction of Modal Logic. Mathematical Structures in Computer Science 11 (Feb. 2000). Google ScholarGoogle ScholarDigital LibraryDigital Library
  51. Brigitte Pientka, Andreas Abel, Francisco Ferreira, David Thibodeau, and Rébecca Zucchini. 2019. A Type Theory for Defining Logics and Proofs. In Proceedings of the 34th Annual ACM/IEEE Symposium on Logic in Computer Science (LICS).Google ScholarGoogle ScholarCross RefCross Ref
  52. Benjamin C. Pierce and David N. Turner. 2000. Local type inference. ACM Transactions Programming Language and Systems 22, 1 (2000), 1–44. Google ScholarGoogle ScholarDigital LibraryDigital Library
  53. Dag Prawitz. 1967. Natural Deduction. A Proof-Theoretical Study. Journal of Symbolic Logic 32, 2 (1967), 255–256.Google ScholarGoogle Scholar
  54. Urs Schreiber. 2013. Differential cohomology in a cohesive infinity-topos. arXiv e-prints, Article arXiv:1310.7930 (Oct 2013), arXiv:1310.7930 pages. arXiv: math-ph/1310.7930Google ScholarGoogle Scholar
  55. Urs Schreiber and Michael Shulman. 2014. Quantum Gauge Field Theory in Cohesive Homotopy Type Theory. In Proceedings 9th Workshop on Quantum Physics and Logic Brussels, Belgium, 10-12 October 2012. 109–126.Google ScholarGoogle ScholarCross RefCross Ref
  56. Peter Schroeder-Heister. 1987. Structural Frameworks with Higher-level Rules: Philosophical Investigations on the Foundations of Formal Reasoning. Habilitation thesis.Google ScholarGoogle Scholar
  57. Michael Shulman. 2018. Brouwer’s fixed-point theorem in real-cohesive homotopy type theory. Mathematical Structures in Computer Science 28, 6 (2018), 856–941.Google ScholarGoogle Scholar
  58. Thomas Streicher. 1998. Categorical intuitions underlying semantic normalisation proofs. In Preliminary Proceedings of the APPSEM Workshop on Normalisation by Evaluation, O. Danvy and P. Dybjer (Eds.). Department of Computer Science, Aarhus University.Google ScholarGoogle Scholar
  59. The Agda Development Team. 2018. agda-flat. https://github.com/agda/agda/tree/flatGoogle ScholarGoogle Scholar
  60. The Univalent Foundations Program. 2013. Homotopy Type Theory: Univalent Foundations of Mathematics. https: //homotopytypetheory.org/book .Google ScholarGoogle Scholar
  61. Paweł Wieczorek and Dariusz Biernacki. 2018. A Coq Formalization of Normalization by Evaluation for Martin-Löf Type Theory. In Proceedings of the 7th ACM SIGPLAN International Conference on Certified Programs and Proofs (CPP 2018). ACM, 266–279. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Implementing a modal dependent type theory

        Recommendations

        Reviews

        Temur Kutsia

        Modalities are widely used in mathematics and computer science as an abstraction tool, but it turns out to be difficult to incorporate them in rich type theories. The authors address this problem, proposing a new dependent type theory MLTT?? that integrates an S4-style necessity modality into the standard Martin-Löf type theory. The goal of this integration is to develop a powerful computational and logical framework, which, as it is stated in the paper, "can be used simultaneously as a basis for next-generation programming languages and as a metalanguage for synthetic mathematics." In type theories, type checking is a fundamental problem. At its core, there is the problem of deciding equality between types. For dependent types, this task involves the equality check between terms as well. A well-known approach to the latter is based on normalization by evaluation (NbE), reducing terms to a canonical representation in their equivalence class. The authors developed and investigated these techniques for MLTT??. NbE is extended to deal with modalities and is proved to be sound and complete. (For reasons of space, the paper does not contain the full proof and the reader is referred to the accompanying technical report, but the latter is not cited.) It is used in the design of a type checking algorithm for a version of MLTT?? with suitable type annotations. Type checking in this version is decidable. The algorithm is shown to be sound and complete. One may wonder why the lock symbol ?? appears in the name of MLTT??. It is related to the locking operation, used to make variables inaccessible it applies to (instead of dropping them) in the process of proving. Locked contexts may later get unlocked, thus making the locked variables accessible again. These operations are used in rules that handle : To prove A , one may lock the context and continue with proving A . On the other hand, it is possible to unlock the locked context to switch to proving A from proving A . After developing the (technically quite involved) theoretical part, the authors illustrate the practicality of their approach, providing an implementation of a prototype proof assistant based on the calculus. I think that researchers working in type theory, logical frameworks, proof assistant systems, and dependently typed programming will appreciate this work. Directions for future investigations, provided at the end of the paper, look interesting.

        Access critical reviews of Computing literature here

        Become a reviewer for Computing Reviews.

        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!