implementing a modal dependent type theory
play

Implementing a Modal Dependent Type Theory Daniel Gratzer 0 Jonathan - PowerPoint PPT Presentation

Implementing a Modal Dependent Type Theory Daniel Gratzer 0 Jonathan Sterling 1 Lars Birkedal 0 August 21, 2019 ICFP 19 0 Aarhus University 1 Carnegie Mellon University 0 Modalities an idempotent monad for a left adjoint. A Category


  1. Implementing a Modal Dependent Type Theory Daniel Gratzer 0 Jonathan Sterling 1 Lars Birkedal 0 August 21, 2019 ICFP ’19 0 Aarhus University 1 Carnegie Mellon University 0

  2. Modalities an idempotent monad for a left adjoint. A Category Theorist 1 We want to add a single modality MLTT, � . Γ ⊢ M : � A � M " : " A and M only mentions variables of the shape � B • In staged programming, � A represents precomputed values. • In modal FRP, � A represents stable types. • In distributed programming, � A represents globally available values. � is just a comonad with

  3. Our Contribution: MLTT  We contribute MLTT  , a dependent type theory with... decidability of type-checking for it. We have constructed a precise syntactic account of MLTT  , and proved the 2  • the box modality, � A      • dependent sums, Σ( A , B ) With both β and η    • dependent products, Π( A , B )   • natural numbers, nat • intensional identity types, Id ( A , M , N ) • a cumulative hierarchy of universes, U 0 , U 1 ...

  4. Typical Problems with Modalities tm/lock?! 1 Prawitz 1967 3 We could imagine just dropping all local variables when constructing � A : � Γ ⊢ M : A � Γ , ∆ ⊢ box ( M ) : � A In this case box ( M ) cannot commute with substitution: box ( M )[ N / x ] could be well-typed while box ( M [ N / x ]) is ill-typed! We can try versions of this rule, 1 but we’ll opt for another approach.

  5. M  Adding Judgmental Structure Crucially, later on we are able to unlock the context: 2 Clouston 2018 A A M  tm/unlock 4 tm/lock tm/var Instead of dropping part of the context we can lock it away: (Contexts) We’ll incorporate Fitch-style judgmental structure 2 to handle � A : Γ · | Γ , x : A | Γ .  � Γ .  ⊢ M : A Γ = Γ 0 , x : A , Γ 1  � Γ 1 Γ ⊢ [ M ]  : � A Γ ⊢ x : A

  6. Adding Judgmental Structure tm/lock 2 Clouston 2018 tm/unlock Crucially, later on we are able to unlock the context: tm/var (Contexts) Instead of dropping part of the context we can lock it away: 4 We’ll incorporate Fitch-style judgmental structure 2 to handle � A : Γ · | Γ , x : A | Γ .  � Γ .  ⊢ M : A Γ = Γ 0 , x : A , Γ 1  � Γ 1 Γ ⊢ [ M ]  : � A Γ ⊢ x : A Γ  ⊢ M : � A Γ ⊢ [ M ]  : A

  7. Adding Judgmental Structure tm/var 2 Clouston 2018 respect substitution! Not obvious, but these rules tm/unlock Crucially, later on we are able to unlock the context: 4 Instead of dropping part of the context we can lock it away: tm/lock (Contexts) We’ll incorporate Fitch-style judgmental structure 2 to handle � A : Γ · | Γ , x : A | Γ .  � Γ .  ⊢ M : A Γ = Γ 0 , x : A , Γ 1  � Γ 1 Γ ⊢ [ M ]  : � A Γ ⊢ x : A Γ  ⊢ M : � A Γ ⊢ [ M ]  : A

  8. dup A x A Small Programming Break Programs dup A A A Holes 5 How does our intuition for � A square with [ − ]  and [ − ]  ? extract A : � A → A extract A ( x ) � [ x ] 

  9. A Small Programming Break Programs Holes 5 How does our intuition for � A square with [ − ]  and [ − ]  ? extract A : � A → A extract A ( x ) � [ x ]  dup A : � A → �� A x : � A ⊢ ? : �� A dup A ( x ) � ?

  10. A Small Programming Break Programs Holes 5 How does our intuition for � A square with [ − ]  and [ − ]  ? extract A : � A → A extract A ( x ) � [ x ]  dup A : � A → �� A x : � A ,  ⊢ ? : � A dup A ( x ) � [?] 

  11. A Small Programming Break Programs Holes 5 How does our intuition for � A square with [ − ]  and [ − ]  ? extract A : � A → A extract A ( x ) � [ x ]  dup A : � A → �� A x : � A ,  ,  ⊢ ? : A dup A ( x ) � [[?]  ] 

  12. A Small Programming Break Programs Holes 5 How does our intuition for � A square with [ − ]  and [ − ]  ? extract A : � A → A extract A ( x ) � [ x ]  dup A : � A → �� A x : � A ⊢ ? : � A dup A ( x ) � [[[?]  ]  ] 

  13. A Small Programming Break Programs Holes 5 How does our intuition for � A square with [ − ]  and [ − ]  ? extract A : � A → A extract A ( x ) � [ x ]  dup A : � A → �� A dup A ( x ) � [[[ x ]  ]  ] 

  14.   M   M 3 Clouston 2018 and Birkedal, Clouston, Mannaa, Møgelberg, Pitts, Spitters 2019 A M A A M A Making Hard Choices: Defjnitional Equalities for MLTT  The premises of these rules are subtle and important! Notice, no commutating conversions, this is a win from the Fitch style. 3 tm/lock-unlock tm/unlock-lock 6 We are able to equip � A with both a β and η rule in MLTT  : Γ  .  ⊢ M : A Γ ⊢ M : � A Γ ⊢ [[ M ]  ]  = M : A Γ ⊢ M = [[ M ]  ]  : � A

  15. Making Hard Choices: Defjnitional Equalities for MLTT  tm/unlock-lock tm/lock-unlock Notice, no commutating conversions, this is a win from the Fitch style. 3 The premises of these rules are subtle and important! � 3 Clouston 2018 and Birkedal, Clouston, Mannaa, Møgelberg, Pitts, Spitters 2019 6 We are able to equip � A with both a β and η rule in MLTT  : Γ  .  ⊢ M : A Γ ⊢ M : � A Γ ⊢ [[ M ]  ]  = M : A Γ ⊢ M = [[ M ]  ]  : � A Γ  .  ⊢ M : A = ⇒ Γ ⊢ M : A Γ ⊢ [[ M ]  ]  : � A = ⇒ Γ ⊢ M : � A

  16. Taking Stock What do we have at this point? Big remaining question: can we implement this? 7 • MLTT  : a declarative modal dependent type theory. • We can prove the expected admissibilities: substitution, presupposition, ... • As well as modal admissibilities: lock contraction, strengthening... These are important checks to ensure that MLTT  behaves well.

  17. Taking Stock What do we have at this point? Complication: non-local and sensitive to extensions. Big remaining question: can we implement this? 7 • MLTT  : a declarative modal dependent type theory. • We can prove the expected admissibilities: substitution, presupposition, ... • As well as modal admissibilities: lock contraction, strengthening... These are important checks to ensure that MLTT  behaves well.

  18. Taking Stock What do we have at this point? Big remaining question: can we implement this? 7 • MLTT  : a declarative modal dependent type theory. • We can prove the expected admissibilities: substitution, presupposition, ... • As well as modal admissibilities: lock contraction, strengthening... These are important checks to ensure that MLTT  behaves well.

  19. Many of these proofs rely on the admissiblities we established! Implementing a Type Theory: A General Recipe 8 The process of implementing some type theory T might follow these steps: 1. Construct a bidirectional syntax for T : T ⇆ . 2. Prove that T admits a normalization theorem. 3. Conclude that T enjoys decidable conversion. 4. Prove that T ⇆ enjoys decidable type-checking. 5. Prove that every term of T is convertible with a term from T ⇆ . 6. Conclude that T ⇆ presents T and is implementable.

  20. Many of these proofs rely on the admissiblities we established! Implementing a Type Theory: A General Recipe 8 The process of implementing some type theory T might follow these steps: 1. Construct a bidirectional syntax for T : T ⇆ . 2. Prove that T admits a normalization theorem. 3. Conclude that T enjoys decidable conversion. 4. Prove that T ⇆ enjoys decidable type-checking. 5. Prove that every term of T is convertible with a term from T ⇆ . 6. Conclude that T ⇆ presents T and is implementable.

  21. Many of these proofs rely on the admissiblities we established! Implementing a Type Theory: A General Recipe 8 The process of implementing some type theory T might follow these steps: 1. Construct a bidirectional syntax for T : T ⇆ . 2. Prove that T admits a normalization theorem. 3. Conclude that T enjoys decidable conversion. 4. Prove that T ⇆ enjoys decidable type-checking. 5. Prove that every term of T is convertible with a term from T ⇆ . 6. Conclude that T ⇆ presents T and is implementable.

  22. Many of these proofs rely on the admissiblities we established! Implementing a Type Theory: A General Recipe 8 The process of implementing some type theory T might follow these steps: 1. Construct a bidirectional syntax for T : T ⇆ . 2. Prove that T admits a normalization theorem. 3. Conclude that T enjoys decidable conversion. 4. Prove that T ⇆ enjoys decidable type-checking. 5. Prove that every term of T is convertible with a term from T ⇆ . 6. Conclude that T ⇆ presents T and is implementable.

  23. Many of these proofs rely on the admissiblities we established! Implementing a Type Theory: A General Recipe 8 The process of implementing some type theory T might follow these steps: 1. Construct a bidirectional syntax for T : T ⇆ . 2. Prove that T admits a normalization theorem. 3. Conclude that T enjoys decidable conversion. 4. Prove that T ⇆ enjoys decidable type-checking. 5. Prove that every term of T is convertible with a term from T ⇆ . 6. Conclude that T ⇆ presents T and is implementable.

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