Nothing Special   »   [go: up one dir, main page]

skip to main content
research-article

A Category Theoretic View of Contextual Types: From Simple Types to Dependent Types

Published: 20 October 2022 Publication History

Abstract

We describe the categorical semantics for a simply typed variant and a simplified dependently typed variant of Cocon, a contextual modal type theory where the box modality mediates between the weak function space that is used to represent higher-order abstract syntax (HOAS) trees and the strong function space that describes (recursive) computations about them. What makes Cocon different from standard type theories is the presence of first-class contexts and contextual objects to describe syntax trees that are closed with respect to a given context of assumptions. Following M. Hofmann’s work, we use a presheaf model to characterise HOAS trees. Surprisingly, this model already provides the necessary structure to also model Cocon. In particular, we can capture the contextual objects of Cocon using a comonad ♭ that restricts presheaves to their closed elements. This gives a simple semantic characterisation of the invariants of contextual types (e.g. substitution invariance) and identifies Cocon as a type-theoretic syntax of presheaf models. We further extend this characterisation to dependent types using categories with families and show that we can model a fragment of Cocon without recursor in the Fitch-style dependent modal type theory presented by Birkedal et al.

References

[1]
Danil Annenkov, Paolo Capriotti, and Nicolai Kraus. 2017. Two-level type theory and applications. ArXiv E-prints (May 2017). Retrieved from http://arxiv.org/abs/1705.03307.
[2]
Andrew Barber and Gordon Plotkin. 1996. Dual Intuitionistic Linear Logic. University of Edinburgh, Department of Computer Science, Laboratory for Foundations of Computer Science.
[3]
P. N. Benton, Gavin M. Bierman, Valeria de Paiva, and Martin Hyland. 1993. A term calculus for intuitionistic linear logic. In Typed Lambda Calculi and Applications, International Conference on Typed Lambda Calculi and Applications, TLCA ’93, Utrecht, The Netherlands, March 16–18, 1993, Proceedings, Marc Bezem and Jan Friso Groote (Eds.), Vol. 664. Springer, 75–90.
[4]
Lars Birkedal, Ranald Clouston, Bassel Mannaa, Rasmus Ejlers Møgelberg, Andrew M. Pitts, and Bas Spitters. 2020. Modal dependent type theory and dependent right adjoints. Math. Struct. Comput. Sci. 30, 2 (2020), 118–138. DOI:
[5]
Paolo Capriotti. 2016. Models of Type Theory with Strict Equality. Ph.D. Dissertation. School of Computer Science, University of Nottingham, UK, Nottingham. Retrieved from http://arxiv.org/abs/1702.04912.
[6]
Pierre Clairambault and Peter Dybjer. 2014. The biequivalence of locally Cartesian closed categories and Martin-öf type theories. Math. Struct. Comput. Sci. 24, 6 (2014). DOI:
[7]
Rowan Davies and Frank Pfenning. 2001. A modal analysis of staged computation. J. ACM 48, 3 (2001), 555–604. DOI:
[8]
Peter Dybjer. 1995. Internal type theory. In Types for Proofs and Programs, International Workshop TYPES’95, Torino, Italy, June 5–8, 1995, Selected Papers. Springer, 120–134. DOI:
[9]
M. Fiore, G. D. Plotkin, and D. Turi. 1999. Abstract syntax and variable binding. In Proceedings of the 14th Annual Symposium on Logic in Computer Science (LICS’99). IEEE Computer Society Press, 193–202.
[10]
Murdoch Gabbay and Andrew Pitts. 1999. A new approach to abstract syntax involving binders. In Proceedings of the 14th Annual Symposium on Logic in Computer Science (LICS’99). IEEE Computer Society Press, 214–224. Retrieved from citeseer.ist.psu.edu/gabbay99new.html.
[11]
Murdoch J. Gabbay and Aleksandar Nanevski. 2013. Denotation of contextual modal type theory (CMTT): Syntax and meta-programming. J. Appl. Log. 11, 1 (Mar. 2013), 1–29. DOI:
[12]
Daniel Gratzer, Jonathan Sterling, and Lars Birkedal. 2019. Implementing a modal dependent type theory. Proc. ACM Program. Lang. 3, ICFP (2019), 107:1–107:29. DOI:
[13]
Robert Harper, Furio Honsell, and Gordon Plotkin. 1993. A framework for defining logics. J. ACM 40, 1 (Jan. 1993), 143–184.
[14]
Martin Hofmann. 1997. Syntax and Semantics of Dependent Types. Cambridge University Press, 79–130.
[15]
Martin Hofmann. 1999. Semantical analysis of higher-order abstract syntax. In Proceedings of the 14th Annual IEEE Symposium on Logic in Computer Science (LICS’99). IEEE Computer Society, 204–213.
[16]
Bart Jacobs. 1993. Comprehension categories and the semantics of type dependency. Theor. Comput. Sci. 107, 2 (1993), 169–207.
[17]
G. A. Kavvos. 2017. Intensionality, intensional recursion, and the Gödel-Löb axiom.
[18]
Daniel R. Licata, Ian Orton, Andrew M. Pitts, and Bas Spitters. 2018. Internal universes in models of homotopy type theory. In Proceedings of the Formal Structures for Computation and Deduction Conference (FSCD’18). 22:1–22:17.
[19]
Dale Miller and Catuscia Palamidessi. 1999. Foundational aspects of syntax. ACM Comput. Surv. 31, 3es (Sept. 1999). DOI:
[20]
Aleksandar Nanevski, Frank Pfenning, and Brigitte Pientka. 2008. Contextual modal type theory. ACM Trans. Computat. Log. 9, 3 (2008), 1–49.
[21]
Frank Pfenning and Conal Elliott. 1988. Higher-order abstract syntax. In Proceedings of the ACM SIGPLAN Symposium on Language Design and Implementation (PLDI’88). 199–208.
[22]
Brigitte Pientka. 2008. A type-theoretic foundation for programming with higher-order abstract syntax and first-class substitutions. In Proceedings of the 35th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL’08). ACM Press, 371–382.
[23]
Brigitte Pientka and Andreas Abel. 2015. Structural recursion over contextual objects. In Proceedings of the 13th International Conference on Typed Lambda Calculi and Applications (TLCA’15). Leibniz International Proceedings in Informatics (LIPIcs) of Schloss Dagstuhl, 273–287.
[24]
Brigitte Pientka and Joshua Dunfield. 2008. Programming with proofs and explicit contexts. In Proceedings of the ACM SIGPLAN Symposium on Principles and Practice of Declarative Programming (PPDP’08). ACM Press, 163–173.
[25]
Brigitte Pientka and Ulrich Schöpp. 2020. Semantical analysis of contextual types. In Foundations of Software Science and Computation Structures - 23rd International Conference, FOSSACS 2020, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2020, Dublin, Ireland, April 25–30, 2020, Proceedings(Lecture Notes in Computer Science, Vol. 12077), Jean Goubault-Larrecq and Barbara König (Eds.). Springer, 502–521. DOI:
[26]
Brigitte Pientka, David Thibodeau, Andreas Abel, Francisco Ferreira, 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. IEEE, 1–13. DOI:
[27]
Andrew M. Pitts. 1987. Polymorphism is set theoretic, constructively. In Category Theory and Computer Science, Edinburgh, UK, September 7–9, 1987, Proceedings(Lecture Notes in Computer Science, Vol. 283), David H. Pitt, Axel Poigné, and David E. Rydeheard (Eds.). Springer, 12–39. DOI:
[28]
Michael Shulman. 2018. Brouwer’s fixed-point theorem in real-cohesive homotopy type theory. Math. Struct. Comput. Sci. 28, 6 (2018), 856–941.

Cited By

View all

Index Terms

  1. A Category Theoretic View of Contextual Types: From Simple Types to Dependent Types

      Recommendations

      Comments

      Please enable JavaScript to view thecomments powered by Disqus.

      Information & Contributors

      Information

      Published In

      cover image ACM Transactions on Computational Logic
      ACM Transactions on Computational Logic  Volume 23, Issue 4
      October 2022
      279 pages
      ISSN:1529-3785
      EISSN:1557-945X
      DOI:10.1145/3565891
      • Editor:
      • Anuj Dawar
      Issue’s Table of Contents

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      Published: 20 October 2022
      Online AM: 29 June 2022
      Accepted: 28 May 2022
      Revised: 27 May 2022
      Received: 04 May 2021
      Published in TOCL Volume 23, Issue 4

      Permissions

      Request permissions for this article.

      Check for updates

      Author Tags

      1. Category theory
      2. type theory
      3. contextual types
      4. dependent types

      Qualifiers

      • Research-article
      • Refereed

      Funding Sources

      • Natural Sciences and Engineering Research Council of Canada
      • Fonds de recherche du Québec - Nature et Technologies
      • Postgraduate Scholarship - Doctoral by the Natural Sciences and Engineering Research Council of Canada

      Contributors

      Other Metrics

      Bibliometrics & Citations

      Bibliometrics

      Article Metrics

      • 0
        Total Citations
      • 181
        Total Downloads
      • Downloads (Last 12 months)52
      • Downloads (Last 6 weeks)5
      Reflects downloads up to 19 Nov 2024

      Other Metrics

      Citations

      Cited By

      View all

      View Options

      Login options

      Full Access

      View options

      PDF

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader

      Full Text

      View this article in Full Text.

      Full Text

      HTML Format

      View this article in HTML Format.

      HTML Format

      Media

      Figures

      Other

      Tables

      Share

      Share

      Share this Publication link

      Share on social media