2 dimensional directed type theory
play

2-Dimensional Directed Type Theory Dan Licata with Robert Harper - PowerPoint PPT Presentation

2-Dimensional Directed Type Theory Dan Licata with Robert Harper Carnegie Mellon University Martin-Lf Type Theory A type is specified by Elements M : A Equality M N : A Families of types respect equality: x:A


  1. 2-Dimensional Directed Type Theory Dan Licata with Robert Harper Carnegie Mellon University

  2. Martin-Löf Type Theory A type is specified by Elements Γ ⊢ M : A Equality Γ ⊢ M ≡ N : A Families of types respect equality: x:A ⊢ C : type M ≡ N : A P : C[M/x] P : C[N/x] 2

  3. Martin-Löf Type Theory A type is specified by Elements Γ ⊢ M : A Equality Γ ⊢ M ≡ N : A Families of types respect equality: x:A ⊢ C : type M ≡ N : A P : C[M/x] P : C[N/x] 2

  4. Martin-Löf Type Theory A type is specified by Elements Γ ⊢ M : A Equality Γ ⊢ M ≡ N : A Families of types respect equality: x:A ⊢ C : type M ≡ N : A universe : elements of type P : C[M/x] are classifiers P : C[N/x] 2

  5. Type Isomorphisms list A ≅ Σ n:nat. vec A n 3

  6. Type Isomorphisms list A ≅ Σ n:nat. vec A n Monoid : type → type Monoid X = Σ m : X → X → X. Σ u : X. ( Π x,y,z:X. Id (m x (m y z)) (m (m x y) z)) * ( Π x.Id (m x u) x) * ( Π x.Id (m u x) x) 3

  7. Type Isomorphisms list A ≅ Σ n:nat. vec A n Monoid : type → type Monoid X = Σ m : X → X → X. Σ u : X. ( Π x,y,z:X. Id (m x (m y z)) (m (m x y) z)) * ( Π x.Id (m x u) x) * ( Π x.Id (m u x) x) Want type families to respect iso, so Monoid(list A) ≅ Monoid( Σ n:nat. vec A n) 3

  8. Type Isomorphisms list A ≅ Σ n:nat. vec A n Monoid : type → type Monoid X = Σ m : X → X → X. Σ u : X. ( Π x,y,z:X. Id (m x (m y z)) (m (m x y) z)) * ( Π x.Id (m x u) x) * ( Π x.Id (m u x) x) Want type families to respect iso, so Monoid(list A) ≅ Monoid( Σ n:nat. vec A n) [cf. Voevodsky’s univalence axiom] 3

  9. Type Isomorphisms Cannot equate isomorphic types: Different representations! Types can be isomorphic in different ways: isomorphism is structure, not property Bool ≅ Bool by identity and by not 4

  10. 2-Dimensional Type Theory Elements Γ ⊢ M : A + equality of M’s and α ’s Equivalence Γ ⊢ α : M ≃ A N All families of types respect equivalence, but this has computational content: a generic x:A ⊢ C : type proof/program α : M ≃ A N defined for P : C [M/x] each family C map x.C α P : C[N/x] (e.g. Monoid) 5

  11. 2-Dimensional Type Theory Elements Γ ⊢ M : A + equality of M’s and α ’s Equivalence Γ ⊢ α : M ≃ A N All families of types respect equivalence, but this has computational content: a generic x:A ⊢ C : type proof/program α : M ≃ A N defined for P : C [M/x] each family C map x.C α P : C[N/x] (e.g. Monoid) essentially C[ α /x] 5

  12. Outline 1. 2-Dimensional Type Theory 2. 2-Dimensional Directed Type Theory a. Application to functorial syntax b. Semantics in Cat 3. Higher Dimensions 6

  13. Outline 1. 2-Dimensional Type Theory 2. 2-Dimensional Directed Type Theory a. Application to functorial syntax b. Semantics in Cat 3. Higher Dimensions 7

  14. 2-Dimensional Type Theory Define equivalence for each A Γ ⊢ α : M ≃ A N Define map for each C x:A ⊢ C : type α : M ≃ A N P : C [M/x] map x. C α P : C[N/x] 8

  15. Equivalence for types f : A → B g : B → A α : g o f ≃ id β : f o g ≃ id iso(f,g, α , β ) : A ≃ type B 9

  16. map for type iso(f,g, α , β ) : A ≃ type B map (a:type.a) (iso(f,g, α , β )) : A → B Computation rule: deploy the isomorphism! map (a.a) (iso(f,g, α , β )) ≡ f 10

  17. map for Functions map x:A.B → C ( α : M 1 ≃ A M 2 )) f ≡ λ x:B[M 2 ]. map x:A.C α (f (map x:A.B (sym α ) x)) 11

  18. map for Functions B[M 1 ] → C[M 1 ] map x:A.B → C ( α : M 1 ≃ A M 2 )) f ≡ λ x:B[M 2 ]. map x:A.C α (f (map x:A.B (sym α ) x)) 11

  19. map for Functions B[M 1 ] → C[M 1 ] map x:A.B → C ( α : M 1 ≃ A M 2 )) f ≡ Goal: B[M 2 ] → C[M 2 ] λ x:B[M 2 ]. map x:A.C α (f (map x:A.B (sym α ) x)) 11

  20. map for Functions B[M 1 ] → C[M 1 ] map x:A.B → C ( α : M 1 ≃ A M 2 )) f ≡ Goal: B[M 2 ] → C[M 2 ] λ x:B[M 2 ]. map x:A.C α (f (map x:A.B (sym α ) x)) Needs to be contravariant: B[M 2 ] → B[M 1 ] 11

  21. map for Functions B[M 1 ] → C[M 1 ] map x:A.B → C ( α : M 1 ≃ A M 2 )) f ≡ Goal: B[M 2 ] → C[M 2 ] λ x:B[M 2 ]. map x:A.C α (f (map x:A.B (sym α ) x)) Needs to be covariant: Needs to be contravariant: C[M 1 ] → C[M 2 ] B[M 2 ] → B[M 1 ] 11

  22. map for Functions B[M 1 ] → C[M 1 ] map x:A.B → C ( α : M 1 ≃ A M 2 )) f ≡ Goal: B[M 2 ] → C[M 2 ] λ x:B[M 2 ]. map x:A.C α (f (map x:A.B (sym α ) x)) Needs to be covariant: Needs to be contravariant: C[M 1 ] → C[M 2 ] B[M 2 ] → B[M 1 ] α : M 1 ≃ M 2 Requires sym α : M 2 ≃ M 1 11

  23. Symmetry for ≃ type f : A → B g : B → A symmetry requires α : g o f ≃ id backwards map! β : f o g ≃ id iso(f,g, α , β ) : A ≃ type B sym (iso(f,g, α , β )) ≡ iso(g,f, β , α ) 12

  24. [Hofmann&Streicher,Awodey, Semantics Warren,Lumsdaine,Garner, Voevodsky] type theory A : type M, N : A α : M ≃ A N category theory homotopy theory A is a groupoid α M,N objects M N α : M → N in A A 13

  25. [Hofmann&Streicher,Awodey, Semantics Warren,Lumsdaine,Garner, Voevodsky] α : M ≃ A N type theory sym( α ) : N ≃ A M A : type M, N : A α : M ≃ A N category theory homotopy theory A is a groupoid α M,N objects M N α : M → N in A A α -1 : N → M in A 14

  26. Summary map is a generic program definable for all types: above implementation for → extends to Π can also be defined for Σ , (co)inductives, … Let’s put it to use! 15

  27. Functorial Abstract Syntax [FPT’99,AR’99,H’99] A family of types Form[ Ψ :Ctx] for formulas in Ψ Ψ ’ ⊢ σ : Ψ Extends to a functor: Form[ Ψ ] → Form[ Ψ ’] that implements the structural properties: 16

  28. Functorial Abstract Syntax [FPT’99,AR’99,H’99] A family of types Form[ Ψ :Ctx] for formulas in Ψ Ψ ’ ⊢ σ : Ψ Extends to a functor: Form[ Ψ ] → Form[ Ψ ’] that implements the structural properties: σ is bijections: exchange 16

  29. Functorial Abstract Syntax [FPT’99,AR’99,H’99] A family of types Form[ Ψ :Ctx] for formulas in Ψ Ψ ’ ⊢ σ : Ψ Extends to a functor: Form[ Ψ ] → Form[ Ψ ’] that implements the structural properties: σ is bijections: exchange σ is var-for-var: weakening, exchange, contraction 16

  30. Functorial Abstract Syntax [FPT’99,AR’99,H’99] A family of types Form[ Ψ :Ctx] for formulas in Ψ Ψ ’ ⊢ σ : Ψ Extends to a functor: Form[ Ψ ] → Form[ Ψ ’] that implements the structural properties: σ is bijections: exchange σ is var-for-var: weakening, exchange, contraction σ is term-for-var: substitution, too 16

  31. Idea Given a datatype for syntax/judgement: data Form : Ctx → type where all : Form[ Ψ ,i] → Form[ Ψ ] ... data nd : ( Ψ : Ctx) → Form[ Ψ ] → type allR : ∀ { Ψ A} → nd ( Ψ ,i) A → nd Ψ (all A) automatically implement structural properties using map 17

  32. x,y,z vs. y,z,x Exchange Take Ctx to be a 2D type: Terms Ψ : Ctx Equivalences Ψ ≃ Ctx Ψ ’ bijection between vars α : Ψ ≃ Ctx Ψ ’ map Ψ .Form[ Ψ ] α : Form [ Ψ ] → Form[ Ψ ’] 18

  33. x,y,z vs. y,z,x Exchange Take Ctx to be a 2D type: for de Bruijn form, not merely a relation Terms Ψ : Ctx Equivalences Ψ ≃ Ctx Ψ ’ bijection between vars α : Ψ ≃ Ctx Ψ ’ map Ψ .Form[ Ψ ] α : Form [ Ψ ] → Form[ Ψ ’] 18

  34. x,y,z vs. y,z,x Exchange Take Ctx to be a 2D type: for de Bruijn form, not merely a relation Terms Ψ : Ctx Equivalences Ψ ≃ Ctx Ψ ’ bijection between vars α : Ψ ≃ Ctx Ψ ’ map Ψ .Form[ Ψ ] α : Form [ Ψ ] → Form[ Ψ ’] derived from map for definition of Form 18

  35. x,y vs. x,z,y Weakening Take Ctx to be a 2D type: Terms Ψ : Ctx Equivalences Ψ ≃ Ctx Ψ ’ variable-for-variable substitutions x,z,y ⊢ x/x,y/y : x,y 19

  36. x,y vs. x,z,y Weakening Take Ctx to be a 2D type: Terms Ψ : Ctx Equivalences Ψ ≃ Ctx Ψ ’ variable-for-variable substitutions x,z,y ⊢ x/x,y/y : x,y Problem: not symmetric! 19

  37. Outline 1. 2-Dimensional Type Theory 2. 2-Dimensional Directed Type Theory a. Application to functorial syntax b. Semantics in Cat 3. Higher Dimensions 20

  38. 2-Dimensional Type Theory α : M ≃ A N type theory sym( α ) : N ≃ A M A : type M, N : A α : M ≃ A N category theory homotopy theory A is a groupoid α M,N objects M N α : M → N in A A α -1 : N → M in A 21

  39. 2-Dimensional Directed Type Theory types in directed type theory categories homotopy types in category theory in directed homotopy theory 22

  40. Directed Type Theory What is a type? Elements Γ ⊢ M : A Transformation Γ ⊢ α : M ≲ A N not necessarily symmetric! 23

  41. x,y vs. x,z,y Weakening Take Ctx to be a directed type: Terms Ψ : Ctx Transformations Ψ ≲ Ctx Ψ ’ variable for variable substitutions Ψ ’ ⊢ σ : Ψ α : Ψ ≲ Ctx Ψ ’ map Ψ .Form[ Ψ ] α : Form [ Ψ ] → Form[ Ψ ’] 24

  42. What about map for → ? map x:A.B → C ( α : M 1 ≃ A M 2 )) f ≡ λ x:B[M 2 ]. map x:A.C α (f (map x:A.B (sym α ) x)) 25

  43. Variances Γ ctx Γ op ctx Contravariant Covariant Γ op ⊢ A : type Γ ⊢ B : type Γ ⊢ A → B : type 26

  44. Variances Covariant Contravariant Γ ::= ⋅ | Γ ,x:A + | Γ ,x:A - only + assumptions Γ ,x:A + ⊢ x : A can be used in a term Γ ctx interchanges + and - Γ op ctx 27

  45. Map Covariant: Contravariant: 28

Recommend


More recommend