multimodal dependent type theory
play

Multimodal Dependent Type Theory Daniel Gratzer 0 Alex Kavvos 0 - PowerPoint PPT Presentation

Multimodal Dependent Type Theory Daniel Gratzer 0 Alex Kavvos 0 Andreas Nuyts 1 Lars Birkedal 0 ICMS 2020 0 Aarhus University 1 imec-DistriNet, KU Leuven 0 The problem Wed like extend Martin-L of Type Theory and apply it to new situations.


  1. Multimodal Dependent Type Theory Daniel Gratzer 0 Alex Kavvos 0 Andreas Nuyts 1 Lars Birkedal 0 ICMS 2020 0 Aarhus University 1 imec-DistriNet, KU Leuven 0

  2. The problem We’d like extend Martin-L¨ of Type Theory and apply it to new situations. • Staged programming [PD01]. • Exotic models of computation [Bir00]. • Proof-irrelevance [Pfe01]. • (Abstract) topology [Shu18]. • Guarded recursion [Clo+15; BGM17; Gua18]. • Differential geometry [Wel18]. • Parametric quantification [ND18]. Let’s extend MLTT to these situations... 1

  3. The problem We’d like extend Martin-L¨ of Type Theory and apply it to new situations. • Staged programming [PD01]. • Exotic models of computation [Bir00]. • Proof-irrelevance [Pfe01]. • (Abstract) topology [Shu18]. • Guarded recursion [Clo+15; BGM17; Gua18]. • Differential geometry [Wel18]. • Parametric quantification [ND18]. Let’s extend MLTT to these situations... and use modalities to tame these extensions. 1

  4. A tangent: what exactly is a modality? In general, people use modality to mean many different things: 1. Any unary type constructor. 2. A unary type constructor which is an internal functor . 3. A unary type constructor equipped with a monad structure. For our work, a modality is essentially a right adjoint. 1 This restriction yields a practical syntax and still includes many examples. 1 More specifically, a modality is essentially a dependent right adjoint [Bir+20] 2

  5. A story of several type theories Let us consider a representative example of how modal type theories are developed. 1. Work on guarded recursion converges towards the Fitch-style [BGM17; Clo18]. 2. Birkedal et al. [Bir+20] isolate this into paradigmatic type theory. 3. Gratzer, Sterling, and Birkedal [GSB19] prove normalization for a similar system. Each of these type theories build upon each other... but no reuse is possible. 3

  6. Our Contribution: MTT We introduce MTT: a type theory parameterized by a collection of modalities. • MTT features usual connectives of Martin-L¨ of Type Theory, including a universe. • The user can instantiate MTT with different collections of modalities. • Important results such as canonicity are proven irrespective of the modalities. We have applied MTT to several different situations: • Axiomatic cohesion [Shu18] • Guarded recursion [Biz+16] • Parametricity [ND18] • And many more... 4

  7. Modes and mode theories MTT is a multi mode type theory, not just multi modal . • Each mode is its own separate type theory, with modalities bridging between them. • As an example, spatial type theory has two modes: sets and spaces. 5

  8. Modes and mode theories MTT is a multi mode type theory, not just multi modal . • Each mode is its own separate type theory, with modalities bridging between them. • As an example, spatial type theory has two modes: sets and spaces. We follow [LS16] and specify our modalities as a mode theory, a (strict) 2-category: object ∼ mode morphism ∼ modality 2-cell ∼ coercion (a natural map between modalities) 5

  9. An example: an idempotent comonad The mode theory for an idempotent comonad is generated from the following data: objects: { m } morphisms: { µ : m → m } 2-cells: { ǫ : µ ⇒ 1 } Furthermore, µ ◦ µ = µ and that α = β for any pair of 2-cells. 6

  10. An example: an idempotent comonad The mode theory for an idempotent comonad is generated from the following data: objects: { m } morphisms: { µ : m → m } 2-cells: { ǫ : µ ⇒ 1 } Furthermore, µ ◦ µ = µ and that α = β for any pair of 2-cells. This induces a single modality � µ | −� with the following coercions: Γ ⊢ M : � µ | A � @ m Γ ⊢ M : � µ | A � @ m Γ ⊢ extract( M ) : A @ m Γ ⊢ duplicate( M ) : � µ | � µ | A �� @ m These satisfy the comonad laws. 6

  11. An example: an idempotent comonad The mode theory for an idempotent comonad is generated from the following data: objects: { m } morphisms: { µ : m → m } 2-cells: { ǫ : µ ⇒ 1 } Furthermore, µ ◦ µ = µ and that α = β for any pair of 2-cells. This induces a single modality � µ | −� with the following coercions: A mode annotation . Γ ⊢ M : � µ | A � @ m Γ ⊢ M : � µ | A � @ m Γ ⊢ extract( M ) : A @ m Γ ⊢ duplicate( M ) : � µ | � µ | A �� @ m These satisfy the comonad laws. 6

  12. MTT, more formally We will now introduce MTT a bit more carefully. Let us fix a mode theory M . MTT is stratified into the following judgments: Γ ctx @ m Γ ⊢ A type @ m Γ ⊢ M : A @ m Each judgment is localized to a mode and each mode contains a copy of MLTT. 7

  13. Modal types Slogan: modalities act like functors between modes. Given a closed type A @ n and µ : n → m , there is a closed type � µ | A � @ m . 8

  14. Modal types Slogan: modalities act like functors between modes. Given a closed type A @ n and µ : n → m , there is a closed type � µ | A � @ m . This doesn’t easily scale to open types: Γ ⊢ A type @ n µ : n → m One of these must Γ ⊢ � µ | A � type @ m live in the wrong mode. 8

  15. Modal types Slogan: modalities act like functors between modes. Given a closed type A @ n and µ : n → m , there is a closed type � µ | A � @ m . This doesn’t easily scale to open types: Γ ⊢ A type @ n µ : n → m One of these must Γ ⊢ � µ | A � type @ m live in the wrong mode. We require additional judgmental structure to make sense of modal types. 8

  16. Fitch-style contexts MTT uses a Fitch-style context so modalities to have an action on contexts: µ : n → m Γ ctx @ m Intuition: − , � µ ⊣ � µ | −� Γ , � µ ctx @ n 9

  17. Fitch-style contexts MTT uses a Fitch-style context so modalities to have an action on contexts: µ : n → m Γ ctx @ m Intuition: − , � µ ⊣ � µ | −� Γ , � µ ctx @ n Accordingly, the introduction and formation rules are transposition: Γ , � µ ⊢ M : A @ n µ : n → m Γ ⊢ mod µ ( M ) : � µ | A � @ m Follows the Fitch-style [BGM17; Clo18; Bir+20; GSB19] (whence the � notation!) 9

  18. Fitch-style contexts with multiple modalities Prior work had one modality, hence one lock. How do we scale to many modalities? Γ ctx @ m ν : o → n µ : n → m Γ ctx @ m Γ = Γ , � 1 ctx @ m Γ , � µ , � ν = Γ , � µ ◦ ν ctx @ o 10

  19. Fitch-style contexts with multiple modalities Prior work had one modality, hence one lock. How do we scale to many modalities? Γ ctx @ m ν : o → n µ : n → m Γ ctx @ m Γ = Γ , � 1 ctx @ m Γ , � µ , � ν = Γ , � µ ◦ ν ctx @ o In fact, � is part of a 2-functor from M coop to contexts giving an admissible rule Γ , � ν ⊢ M : A @ n µ, ν : n → m α : µ ⇒ ν Γ , � µ ⊢ M α : A α @ n (NB: − α must be applied to both the term and the type.) 10

  20. What about variables? Locks allow us to state the formation rule for modalities, but what about variables? With the standard variable rule, we again have a mode error! µ : n → m x : A , � µ ⊢ x : A @ n 11

  21. What about variables? Locks allow us to state the formation rule for modalities, but what about variables? With the standard variable rule, we again have a mode error! µ : n → m x : A , � µ ⊢ x : A @ n A must live in mode m A must live in mode n 11

  22. What about variables? Locks allow us to state the formation rule for modalities, but what about variables? With the standard variable rule, we again have a mode error! µ : n → m x : A , � µ ⊢ x : A @ n • Previous Fitch-style type theories handled this through an elimination rule. • In MTT, we will introduce a final piece of judgmental structure. 11

  23. Variable annotations In addition to locks, each variable in the context will be annotated with a modality. Γ , � µ ⊢ A type @ n µ : n → m Γ ctx @ m Γ , x : ( µ | A ) ctx @ m Intuition: Γ , x : ( µ | A ) is roughly Γ , x : � µ | A � . 12

  24. Variable annotations In addition to locks, each variable in the context will be annotated with a modality. Γ , � µ ⊢ A type @ n µ : n → m Γ ctx @ m Γ , x : ( µ | A ) ctx @ m Intuition: Γ , x : ( µ | A ) is roughly Γ , x : � µ | A � . µ : n → m Γ , x : ( µ | A ) , � µ ⊢ x : A @ n Γ ⊢ M 0 : � µ | A � @ m Γ , y : ( µ | A ) ⊢ M 1 : B [mod µ ( y ) / x ] @ m Γ ⊢ let mod µ ( y ) ← M 0 in M 1 : B [ M 0 / x ] @ m 12

  25. Variable annotations In addition to locks, each variable in the context will be annotated with a modality. Γ , � µ ⊢ A type @ n µ : n → m Γ ctx @ m Γ , x : ( µ | A ) ctx @ m Intuition: Γ , x : ( µ | A ) is roughly Γ , x : � µ | A � . µ : n → m Γ , x : ( µ | A ) , � µ ⊢ x : A @ n Counit of − , � µ ⊣ � µ | −� Γ ⊢ M 0 : � µ | A � @ m Γ , y : ( µ | A ) ⊢ M 1 : B [mod µ ( y ) / x ] @ m Γ ⊢ let mod µ ( y ) ← M 0 in M 1 : B [ M 0 / x ] @ m 12

  26. Variable annotations In addition to locks, each variable in the context will be annotated with a modality. Γ , � µ ⊢ A type @ n µ : n → m Γ ctx @ m Γ , x : ( µ | A ) ctx @ m Intuition: Γ , x : ( µ | A ) is roughly Γ , x : � µ | A � . µ : n → m Γ , x : ( µ | A ) , � µ ⊢ x : A @ n Γ ⊢ M 0 : � µ | A � @ m Γ , y : ( µ | A ) ⊢ M 1 : B [mod µ ( y ) / x ] @ m Shift from Γ ⊢ let mod µ ( y ) ← M 0 in M 1 : B [ M 0 / x ] @ m Γ , x : � µ | A � to Γ , x : ( µ | A ) 12

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend