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

2 dimensional directed type theory
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

2-Dimensional Directed Type Theory

Dan Licata with Robert Harper Carnegie Mellon University

slide-2
SLIDE 2

2

Elements Γ ⊢ M : A Equality Γ ⊢ M ≡ N : A A type is specified by Families of types respect equality: x:A ⊢ C : type M ≡ N : A P : C[M/x] P : C[N/x]

Martin-Löf Type Theory

slide-3
SLIDE 3

2

Elements Γ ⊢ M : A Equality Γ ⊢ M ≡ N : A A type is specified by Families of types respect equality: x:A ⊢ C : type M ≡ N : A P : C[M/x] P : C[N/x]

Martin-Löf Type Theory

slide-4
SLIDE 4

2

Elements Γ ⊢ M : A Equality Γ ⊢ M ≡ N : A A type is specified by Families of types respect equality: x:A ⊢ C : type M ≡ N : A P : C[M/x] P : C[N/x]

Martin-Löf Type Theory

universe : elements of type are classifiers

slide-5
SLIDE 5

3

Type Isomorphisms

list A ≅ Σ n:nat. vec A n

slide-6
SLIDE 6

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)

slide-7
SLIDE 7

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) Monoid(list A) ≅ Monoid(Σ n:nat. vec A n) Want type families to respect iso, so

slide-8
SLIDE 8

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) Monoid(list A) ≅ Monoid(Σ n:nat. vec A n) Want type families to respect iso, so [cf. Voevodsky’s univalence axiom]

slide-9
SLIDE 9

4

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

slide-10
SLIDE 10

5

2-Dimensional Type Theory

Elements Γ ⊢ M : A Equivalence Γ ⊢ α : M ≃A N

+ equality of M’s and α’s

x:A ⊢ C : type α : M ≃A N P : C[M/x] mapx.C α P : C[N/x] All families of types respect equivalence, but this has computational content:

a generic proof/program defined for each family C (e.g. Monoid)

slide-11
SLIDE 11

5

2-Dimensional Type Theory

Elements Γ ⊢ M : A Equivalence Γ ⊢ α : M ≃A N

+ equality of M’s and α’s

x:A ⊢ C : type α : M ≃A N P : C[M/x] mapx.C α P : C[N/x] All families of types respect equivalence, but this has computational content:

a generic proof/program defined for each family C (e.g. Monoid) essentially C[α/x]

slide-12
SLIDE 12

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
slide-13
SLIDE 13

7

Outline

  • 1. 2-Dimensional Type Theory
  • 2. 2-Dimensional Directed Type Theory
  • a. Application to functorial syntax
  • b. Semantics in Cat
  • 3. Higher Dimensions
slide-14
SLIDE 14

8

2-Dimensional Type Theory

Define equivalence for each A Γ ⊢ α : M ≃A N x:A ⊢ C : type α : M ≃A N P : C[M/x] mapx.C α P : C[N/x] Define map for each C

slide-15
SLIDE 15

9

Equivalence for types

f : A → B g : B → A α : g o f ≃ id β : f o g ≃ id iso(f,g,α,β) : A ≃type B

slide-16
SLIDE 16

10

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

slide-17
SLIDE 17

map for Functions

11

mapx:A.B → C (α : M1 ≃A M2)) f ≡ λ x:B[M2]. mapx:A.C α (f (mapx:A.B (sym α) x))

slide-18
SLIDE 18

map for Functions

11

mapx:A.B → C (α : M1 ≃A M2)) f ≡ λ x:B[M2]. mapx:A.C α (f (mapx:A.B (sym α) x))

B[M1] →C[M1]

slide-19
SLIDE 19

map for Functions

11

mapx:A.B → C (α : M1 ≃A M2)) f ≡ λ x:B[M2]. mapx:A.C α (f (mapx:A.B (sym α) x))

B[M1] →C[M1] Goal: B[M2] → C[M2]

slide-20
SLIDE 20

map for Functions

11

mapx:A.B → C (α : M1 ≃A M2)) f ≡ λ x:B[M2]. mapx:A.C α (f (mapx:A.B (sym α) x))

B[M1] →C[M1] Goal: B[M2] → C[M2] Needs to be contravariant: B[M2] → B[M1]

slide-21
SLIDE 21

map for Functions

11

mapx:A.B → C (α : M1 ≃A M2)) f ≡ λ x:B[M2]. mapx:A.C α (f (mapx:A.B (sym α) x))

B[M1] →C[M1] Goal: B[M2] → C[M2] Needs to be contravariant: B[M2] → B[M1] Needs to be covariant: C[M1] → C[M2]

slide-22
SLIDE 22

map for Functions

11

mapx:A.B → C (α : M1 ≃A M2)) f ≡ λ x:B[M2]. mapx:A.C α (f (mapx:A.B (sym α) x))

B[M1] →C[M1] Goal: B[M2] → C[M2] Needs to be contravariant: B[M2] → B[M1] Needs to be covariant: C[M1] → C[M2]

α : M1 ≃ M2 sym α : M2 ≃ M1

Requires

slide-23
SLIDE 23

12

Symmetry for ≃type

f : A → B g : B → A α : g o f ≃ id β : f o g ≃ id iso(f,g,α,β) : A ≃type B sym (iso(f,g,α,β)) ≡ iso(g,f,β,α)

symmetry requires backwards map!

slide-24
SLIDE 24

13

Semantics

A : type M, N : A α : M ≃A N A is a groupoid M,N objects α : M → N in A

M N α

type theory category theory homotopy theory

A

[Hofmann&Streicher,Awodey, Warren,Lumsdaine,Garner, Voevodsky]

slide-25
SLIDE 25

14

Semantics

A : type M, N : A α : M ≃A N A is a groupoid M,N objects α : M → N in A

M N α

type theory category theory homotopy theory

A

[Hofmann&Streicher,Awodey, Warren,Lumsdaine,Garner, Voevodsky] α : M ≃A N sym(α) : N ≃A M α-1 : N → M in A

slide-26
SLIDE 26

15

Summary

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

slide-27
SLIDE 27

Functorial Abstract Syntax

16

A family of types Form[Ψ:Ctx] for formulas in Ψ Extends to a functor: [FPT’99,AR’99,H’99]

Ψ’ ⊢ σ : Ψ

Form[Ψ] → Form[Ψ’] that implements the structural properties:

slide-28
SLIDE 28

Functorial Abstract Syntax

16

A family of types Form[Ψ:Ctx] for formulas in Ψ Extends to a functor: [FPT’99,AR’99,H’99]

Ψ’ ⊢ σ : Ψ

Form[Ψ] → Form[Ψ’] σ is bijections: exchange that implements the structural properties:

slide-29
SLIDE 29

Functorial Abstract Syntax

16

A family of types Form[Ψ:Ctx] for formulas in Ψ Extends to a functor: [FPT’99,AR’99,H’99]

Ψ’ ⊢ σ : Ψ

Form[Ψ] → Form[Ψ’] σ is bijections: exchange σ is var-for-var: weakening, exchange, contraction that implements the structural properties:

slide-30
SLIDE 30

Functorial Abstract Syntax

16

A family of types Form[Ψ:Ctx] for formulas in Ψ Extends to a functor: [FPT’99,AR’99,H’99]

Ψ’ ⊢ σ : Ψ

Form[Ψ] → Form[Ψ’] σ is bijections: exchange σ is var-for-var: weakening, exchange, contraction σ is term-for-var: substitution, too that implements the structural properties:

slide-31
SLIDE 31

Idea

17

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

slide-32
SLIDE 32

Exchange

18

Take Ctx to be a 2D type: Terms Ψ : Ctx Equivalences Ψ ≃Ctx Ψ’ bijection between vars α : Ψ ≃Ctx Ψ’ mapΨ.Form[Ψ] α : Form[Ψ] → Form[Ψ’]

x,y,z vs. y,z,x

slide-33
SLIDE 33

Exchange

18

Take Ctx to be a 2D type: Terms Ψ : Ctx Equivalences Ψ ≃Ctx Ψ’ bijection between vars α : Ψ ≃Ctx Ψ’ mapΨ.Form[Ψ] α : Form[Ψ] → Form[Ψ’]

for de Bruijn form, not merely a relation

x,y,z vs. y,z,x

slide-34
SLIDE 34

Exchange

18

Take Ctx to be a 2D type: Terms Ψ : Ctx Equivalences Ψ ≃Ctx Ψ’ bijection between vars α : Ψ ≃Ctx Ψ’ mapΨ.Form[Ψ] α : Form[Ψ] → Form[Ψ’]

for de Bruijn form, not merely a relation

x,y,z vs. y,z,x

derived from map for definition of Form

slide-35
SLIDE 35

Weakening

19

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

x,y vs. x,z,y

slide-36
SLIDE 36

Weakening

19

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

x,y vs. x,z,y

Problem: not symmetric!

slide-37
SLIDE 37

20

Outline

  • 1. 2-Dimensional Type Theory
  • 2. 2-Dimensional Directed Type Theory
  • a. Application to functorial syntax
  • b. Semantics in Cat
  • 3. Higher Dimensions
slide-38
SLIDE 38

21

A : type M, N : A α : M ≃A N A is a groupoid M,N objects α : M → N in A

M N α

type theory category theory homotopy theory

A

α : M ≃A N sym(α) : N ≃A M α-1 : N → M in A

2-Dimensional Type Theory

slide-39
SLIDE 39

22

types in directed type theory categories in category theory homotopy types in directed homotopy theory

2-Dimensional Directed Type Theory

slide-40
SLIDE 40

23

Directed Type Theory

Elements Γ ⊢ M : A Transformation Γ ⊢ α : M ≲A N What is a type? not necessarily symmetric!

slide-41
SLIDE 41

Weakening

24

Take Ctx to be a directed type: Terms Ψ : Ctx Transformations Ψ ≲Ctx Ψ’ variable for variable substitutions Ψ’ ⊢ σ : Ψ

x,y vs. x,z,y

α : Ψ ≲Ctx Ψ’ mapΨ.Form[Ψ] α : Form[Ψ] → Form[Ψ’]

slide-42
SLIDE 42

What about map for →?

25

mapx:A.B → C (α : M1 ≃A M2)) f ≡ λ x:B[M2]. mapx:A.C α (f (mapx:A.B (sym α) x))

slide-43
SLIDE 43

Variances

26

Γop ⊢ A : type Γ ⊢ B : type Γ ⊢ A → B : type

Covariant Contravariant

Γ ctx Γop ctx

slide-44
SLIDE 44

Variances

27

Γ ::= ⋅ | Γ,x:A+ | Γ,x:A-

Covariant interchanges + and -

Γ ctx Γop ctx

Contravariant

Γ,x:A+ ⊢ x : A

  • nly + assumptions

can be used in a term

slide-45
SLIDE 45

Map

28

Covariant: Contravariant:

slide-46
SLIDE 46

Functions

29

Γ,x:A- ⊢ M : B Γ ⊢ λx.M : A → B Γ ⊢ M : A → B Γop ⊢ N : A Γ ⊢ M N : B Γop ⊢ A : type Γ ⊢ B : type Γ ⊢ A → B : type

slide-47
SLIDE 47

map (→)

30

mapx:A+.B → C (α : M1 ≲A M2) f ≡ λ x:B[M2]-. mapx:A+.C α (f (mapx:A-.B α x))

B[M1] →C[M1] Goal: B[M2] → C[M2] Contravariant: B[M2] → B[M1] Covariant: C[M1] → C[M2]

x:A- ⊢ B : type x:A+ ⊢ C : type x:A+ ⊢ B → C : type

slide-48
SLIDE 48

map (→)

30

mapx:A+.B → C (α : M1 ≲A M2) f ≡ λ x:B[M2]-. mapx:A+.C α (f (mapx:A-.B α x))

B[M1] →C[M1] Goal: B[M2] → C[M2] Contravariant: B[M2] → B[M1] Covariant: C[M1] → C[M2]

x:A- ⊢ B : type x:A+ ⊢ C : type x:A+ ⊢ B → C : type Γ, x:B[M2]- ⊢ f (mapx:A-.B α x) : C[M1] if Γop, x:B[M2]+ ⊢ (mapx:A-.B α x) : B[M1] if (Γop)op ⊢ α : M1 ≲A M2

slide-49
SLIDE 49

map (→)

30

mapx:A+.B → C (α : M1 ≲A M2) f ≡ λ x:B[M2]-. mapx:A+.C α (f (mapx:A-.B α x))

B[M1] →C[M1] Goal: B[M2] → C[M2] Contravariant: B[M2] → B[M1] Covariant: C[M1] → C[M2]

x:A- ⊢ B : type x:A+ ⊢ C : type x:A+ ⊢ B → C : type Γ, x:B[M2]- ⊢ f (mapx:A-.B α x) : C[M1] if Γop, x:B[M2]+ ⊢ (mapx:A-.B α x) : B[M1] if (Γop)op ⊢ α : M1 ≲A M2

involution

slide-50
SLIDE 50

31

Semantics in Cat

Context Γ ctx category Substitution Γ ⊢ θ : Δ functor Transformation Γ ⊢ δ : θ ≲Δ θ’ natural transform. Type Γ ⊢ A type functor Γ → Cat Term Γ ⊢ M : A “dependent functor” Term Trans. Γ ⊢ α : M ≲A N “dependent n.t.”

slide-51
SLIDE 51

32

Identity and Composition

Transformation: Γ ⊢ δ : θ ≲Δ θ’ Γ ⊢ refl : θ ≲Δ θ Γ ⊢ δ1 : θ1 ≲Δ θ2 Γ ⊢ δ2 : θ2 ≲Δ θ3 Γ ⊢ δ2 o δ1 : θ1 ≲Δ θ3

also horizontal composition: transformation respects transformation

slide-52
SLIDE 52

32

Identity and Composition

Transformation: Γ ⊢ δ : θ ≲Δ θ’ Γ ⊢ refl : θ ≲Δ θ Γ ⊢ δ1 : θ1 ≲Δ θ2 Γ ⊢ δ2 : θ2 ≲Δ θ3 Γ ⊢ δ2 o δ1 : θ1 ≲Δ θ3

also horizontal composition: transformation respects transformation

δ3 o (δ2 o δ1) ≡ (δ3 o δ2) o δ1 Equations hold strictly: mapC (δ2 o δ1) M ≡ mapC δ3 (mapC δ2 M)

slide-53
SLIDE 53

Application

33

judgements/dependent types, via map for Σ and Π admissibility premises Generalizes functorial syntax to (see paper/thesis for details)

slide-54
SLIDE 54

34

Outline

  • 1. 2-Dimensional Type Theory
  • 2. 2-Dimensional Directed Type Theory
  • a. Application to functorial syntax
  • b. Semantics in Cat
  • 3. Higher Dimensions
slide-55
SLIDE 55

Higher Dimensions

35

δ3 o (δ2 o δ1) ≃ (δ3 o δ2) o δ1 : θ1 ≲ θ4 : Γ ⊢ Δ More generally, equations may hold weakly: Example: type1 where type : type1 equivalence should be “iso up to iso”

slide-56
SLIDE 56

Higher Dimensions

35

δ3 o (δ2 o δ1) ≃ (δ3 o δ2) o δ1 : θ1 ≲ θ4 : Γ ⊢ Δ More generally, equations may hold weakly: Example: type1 where type : type1 equivalence should be “iso up to iso” Elements Γ ⊢ M : A Equivalence Γ ⊢ α : M ≃ N Equivalence2 Γ ⊢ φ : α ≃ α’ ...

slide-57
SLIDE 57

Higher Dimensions

36

In symmetric type theory, can exploit the identity type Elements M : A Equivalence α : M ≃ N Equivalence2 φ : α ≃ α’ α : IdA(M,N) φ : IdId(M,N)(α,α’) Standard rules for Id are sound for higher-dimensions, but miss computation rules for map Interpret IdA as hom-functor A x A → [type]

slide-58
SLIDE 58

37

types in intensional type theory higher-dimensional groupoids in category theory higher homotopy types in homotopy theory

Homotopy Type Theory

[homotopytypetheory.org] [Hofmann&Streicher,Awodey, Warren,Lumsdaine,Garner,Voevodsky]

slide-59
SLIDE 59

Higher Dimensions

38

In symmetric type theory, can exploit the identity type Elements M : A Equivalence α : M ≃ N Equivalence2 φ : α ≃ α’ α : IdA(M,N) φ : IdId(M,N)(α,α’) But in directed type theory, a Hom type is harder: Mixed variance of Hom : Cop x C → [type]

slide-60
SLIDE 60

39

Outline

  • 1. 2-Dimensional Type Theory
  • 2. 2-Dimensional Directed Type Theory
  • a. Application to functorial syntax
  • b. Semantics in Cat
  • 3. Higher Dimensions
slide-61
SLIDE 61

Future Work

Hom type, paralleling identity type Id Inductive, co-inductive types Quotients by internal descriptions of categories Integration with symmetric type theory Semantics in more general 2-categories Higher dimensions and their semantics Computational interpretation: N-canonicity, decidable definitional equality

40

slide-62
SLIDE 62

41

types in directed type theory higher-dimensional categories in category theory higher homotopy types in directed homotopy theory

Directed Type Theory

Blog: homotopytypetheory.org