2-Dimensional Directed Type Theory Dan Licata with Robert Harper Carnegie Mellon University
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
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
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
Type Isomorphisms list A ≅ Σ n:nat. vec A n 3
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
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
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
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
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
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
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
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
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
Equivalence for types f : A → B g : B → A α : g o f ≃ id β : f o g ≃ id iso(f,g, α , β ) : A ≃ type B 9
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
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
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
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
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
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
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
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
[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
[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
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
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
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
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
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
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
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
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
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
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
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
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
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
2-Dimensional Directed Type Theory types in directed type theory categories homotopy types in category theory in directed homotopy theory 22
Directed Type Theory What is a type? Elements Γ ⊢ M : A Transformation Γ ⊢ α : M ≲ A N not necessarily symmetric! 23
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
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
Variances Γ ctx Γ op ctx Contravariant Covariant Γ op ⊢ A : type Γ ⊢ B : type Γ ⊢ A → B : type 26
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
Map Covariant: Contravariant: 28
Recommend
More recommend