Cubical Computational Type Carlo Angiuli Evan Cavallo Theory - - PowerPoint PPT Presentation

cubical computational type
SMART_READER_LITE
LIVE PREVIEW

Cubical Computational Type Carlo Angiuli Evan Cavallo Theory - - PowerPoint PPT Presentation

2018.07.07 LFMTP Cubical Computational Type Carlo Angiuli Evan Cavallo Theory (*) Favonia Robert Harper & RedPRL Jonathan Sterling Todd Wilson >> redprl.org >> 1 Cubical features of homotopy type theory univalence,


slide-1
SLIDE 1

1 Carlo Angiuli Evan Cavallo (*) Favonia Robert Harper Jonathan Sterling Todd Wilson

Cubical Computational Type Theory & RedPRL

2018.07.07 LFMTP >> redprl.org >>

slide-2
SLIDE 2

2

Computational

strict equality, strict quotients, predicative subtypes... univalence, higher inductive types

Cubical

+

features of homotopy type theory features of Nuprl and PVS

slide-3
SLIDE 3

3

univalence, higher inductive types

Cartesian Cubical

features of homotopy type theory

Computational

strict equality, strict quotients, predicative subtypes...

+

features of Nuprl and PVS

slide-4
SLIDE 4

4

Computational Types

programs/ realizers computation

slide-5
SLIDE 5

4

Computational Types

programs/ realizers computation computational type theory theory of computation <-----

slide-6
SLIDE 6

4

Computational Types

programs/ realizers computation computational type theory theory of computation meaning explanation Martin-Löf type theory pre-mathematical in M-L's work <----- <----

slide-7
SLIDE 7

5

A Minimum Example

M := a | bool | true | false | if(M,M,M)

slide-8
SLIDE 8

5

A Minimum Example

M := a | bool | true | false | if(M,M,M) true val false val if(true,M,_) ↦ M if(false,_,M) ↦ M bool val if(M,Mt,Mf) ↦ if(M',Mt,Mf)

slide-9
SLIDE 9

5

A Minimum Example

M := a | bool | true | false | if(M,M,M) true val false val if(true,M,_) ↦ M if(false,_,M) ↦ M bool val

The Language

if(M,Mt,Mf) ↦ if(M',Mt,Mf)

slide-10
SLIDE 10

5

A Minimum Example

M := a | bool | true | false | if(M,M,M) true val false val if(true,M,_) ↦ M if(false,_,M) ↦ M bool val

The Language What are the types in canonical forms? {bool}

if(M,Mt,Mf) ↦ if(M',Mt,Mf)

slide-11
SLIDE 11

5

A Minimum Example

M := a | bool | true | false | if(M,M,M) true val false val if(true,M,_) ↦ M if(false,_,M) ↦ M bool val

The Language What are the types in canonical forms? What are the canonical forms of the types? bool: {true, false} {bool}

if(M,Mt,Mf) ↦ if(M',Mt,Mf)

slide-12
SLIDE 12

5

A Minimum Example

M := a | bool | true | false | if(M,M,M) true val false val if(true,M,_) ↦ M if(false,_,M) ↦ M bool val

The Language What are the types in canonical forms? What are the canonical forms of the types? bool: {true, false} {bool} How they are equal? syntactic equality

if(M,Mt,Mf) ↦ if(M',Mt,Mf)

slide-13
SLIDE 13

5

A Minimum Example

M := a | bool | true | false | if(M,M,M) true val false val if(true,M,_) ↦ M if(false,_,M) ↦ M bool val

The Language What are the types in canonical forms? What are the canonical forms of the types? bool: {true, false} {bool} How they are equal? syntactic equality One Theory

if(M,Mt,Mf) ↦ if(M',Mt,Mf)

slide-14
SLIDE 14

6

A Minimum Example

M := a | bool | true | false | if(M,M,M) bool: {true, false} with syntactic equality ≈bool types: {bool} with syntactic equality ≈

slide-15
SLIDE 15

6

A Minimum Example

A ≐ B type

A⇓A' B⇓B' and A'≈B'

M := a | bool | true | false | if(M,M,M) bool: {true, false} with syntactic equality ≈bool types: {bool} with syntactic equality ≈

slide-16
SLIDE 16

6

A Minimum Example

bool ≐ bool type

A ≐ B type

A⇓A' B⇓B' and A'≈B'

M := a | bool | true | false | if(M,M,M) bool: {true, false} with syntactic equality ≈bool types: {bool} with syntactic equality ≈

slide-17
SLIDE 17

6

A Minimum Example

bool ≐ bool type

A ≐ B type

A⇓A' B⇓B' and A'≈B'

if(true,bool,bool) ≐ bool type ⇓bool M := a | bool | true | false | if(M,M,M) bool: {true, false} with syntactic equality ≈bool types: {bool} with syntactic equality ≈

slide-18
SLIDE 18

6

A Minimum Example

bool ≐ bool type

A ≐ B type

A⇓A' B⇓B' and A'≈B'

if(true,bool,bool) ≐ bool type ⇓bool if(true,bool,any closed term) ≐ bool type M := a | bool | true | false | if(M,M,M) bool: {true, false} with syntactic equality ≈bool types: {bool} with syntactic equality ≈

slide-19
SLIDE 19

7

A Minimum Example

M := a | bool | true | false | if(M,M,M) bool: {true, false} with syntactic equality ≈bool types: {bool} with syntactic equality ≈

M ≐ N ∈ A

A≐A type, M⇓M', N⇓N', A⇓A' and M'≈A'N'

slide-20
SLIDE 20

7

A Minimum Example

M := a | bool | true | false | if(M,M,M) bool: {true, false} with syntactic equality ≈bool types: {bool} with syntactic equality ≈ false ≐ false ∈ bool

M ≐ N ∈ A

A≐A type, M⇓M', N⇓N', A⇓A' and M'≈A'N'

slide-21
SLIDE 21

7

A Minimum Example

M := a | bool | true | false | if(M,M,M) bool: {true, false} with syntactic equality ≈bool types: {bool} with syntactic equality ≈ if(true,true,bool) ≐ true ∈ if(true,bool,bool) false ≐ false ∈ bool

M ≐ N ∈ A

A≐A type, M⇓M', N⇓N', A⇓A' and M'≈A'N'

⇓true ⇓bool

slide-22
SLIDE 22

8

A Minimum Example

a:A >> M ≐ N ∈ B

P ≐ Q ∈ A implies M[P/a] ≐ N[Q/a] ∈ B[P/a]

M := a | bool | true | false | if(M,M,M) bool: {true, false} with syntactic equality ≈bool types: {bool} with syntactic equality ≈

slide-23
SLIDE 23

8

A Minimum Example

b:bool >> b ≐ if(b,true,false) ∈ bool?

a:A >> M ≐ N ∈ B

P ≐ Q ∈ A implies M[P/a] ≐ N[Q/a] ∈ B[P/a]

M := a | bool | true | false | if(M,M,M) bool: {true, false} with syntactic equality ≈bool types: {bool} with syntactic equality ≈

slide-24
SLIDE 24

9

A Functional Example

M := a | M1⟶M2 | \a.M | M1 M2 | ... \a.M val (\a.M1)M2 ↦ M1[M2/a] (M1⟶M2) val

Another Language

slide-25
SLIDE 25

9

A Functional Example

M := a | M1⟶M2 | \a.M | M1 M2 | ... \a.M val (\a.M1)M2 ↦ M1[M2/a] (M1⟶M2) val

Another Language What are the types in canonical forms? What are the canonical forms of the types? A⟶B: {\a.M} the least fixed point of S ↦ {M⟶N | M⇓, N⇓ in S} union ... How they are equal? A1⟶B1 ≈ A2⟶B2 if A1 ≐ A2 and B1 ≐ B2 \a.M1 ≈A⟶B \a.M2 if a:A >> M1 ≐ M2 ∈ B

slide-26
SLIDE 26

10

Nuprl/... Coq/Agda/...

Vars range over closed terms Vars are indet. Defined by conversion b/w

  • pen terms

Defined by transition b/w closed terms

Variables

slide-27
SLIDE 27

11

Programming language Computational type theory Proof theory/tactics/editors

Open-endedness

slide-28
SLIDE 28

11 Canonicity always holds

Programming language Computational type theory Proof theory/tactics/editors

Open-endedness

slide-29
SLIDE 29

12

Homotopy Type Theory

a b

points

slide-30
SLIDE 30

12

Homotopy Type Theory

a b q:a=b

paths points

p:a=b

slide-31
SLIDE 31

12

Homotopy Type Theory

a b q:a=b

paths

paths between paths

points

p:a=b h:p=q

slide-32
SLIDE 32

12

Homotopy Type Theory

a b q:a=b

paths

paths between paths

points

p:a=b h:p=q

slide-33
SLIDE 33

13

Equality and Paths

Equality (≡)

Silent in theory 2 + 3 ≡ 5 fst ⟨M,N⟩ ≡ M

slide-34
SLIDE 34

13

Equality and Paths

Equality (≡)

Silent in theory If A ≡ B and M : A then M : B 2 + 3 ≡ 5 fst ⟨M,N⟩ ≡ M

slide-35
SLIDE 35

13

Equality and Paths

Equality (≡)

Visible in theory Silent in theory

Paths (=)

If P : A=B and M : A then transport(M,P) : B If A ≡ B and M : A then M : B 2 + 3 ≡ 5 fst ⟨M,N⟩ ≡ M

slide-36
SLIDE 36

14

Type Space Function Continuous Mapping Element Point Dependent Type Fibration Identification Path A a : A f : A → B C : A → Type a =A b

[Awodey and Warren] [Voevodsky et al] [van den Berg and Garner]

Homotopy Type Theory

slide-37
SLIDE 37

15

Features of HoTT

Univalence

If E is an equivalence between types A and B, then ua(E):A=B

Higher Inductive Types

circle sphere torus

slide-38
SLIDE 38

16

Canonicity?

Canonicity broken by new features stated as axioms!

slide-39
SLIDE 39

16

Canonicity?

For any M : bool, either M ≡ true : bool or M ≡ false : bool

Canonicity

Canonicity broken by new features stated as axioms!

slide-40
SLIDE 40

16

Canonicity?

For any M : bool, either M ≡ true : bool or M ≡ false : bool

Canonicity

Canonicity broken by new features stated as axioms!

transport(ua(not),true) ≢ false

ua(not) : bool = bool

slide-41
SLIDE 41

17

Canonicity for All

Canonicity for bool means canonicity for everyone

slide-42
SLIDE 42

17

Canonicity for All

Canonicity for bool means canonicity for everyone

M : bool × A fst(M) ≡ ??? : bool

slide-43
SLIDE 43

17

Canonicity for All

Canonicity for bool means canonicity for everyone

M : bool × A fst(M) ≡ ??? : bool

Wants M ≡ ⟨P,Q⟩ and then fst(M) ≡ fst⟨P,Q⟩ ≡ P ≡ true or false

slide-44
SLIDE 44

18

Canonicity for Paths?

refl(M) : M =A M M : A

slide-45
SLIDE 45

18

Canonicity for Paths?

path-ind[C](a.R,P) : C(M,N,P) refl(M) : M =A M M : A a:A ⊦ R : C(a,a,refl(a)) P : M = N

slide-46
SLIDE 46

18

Canonicity for Paths?

path-ind[C](a.R,P) : C(M,N,P) refl(M) : M =A M M : A a:A ⊦ R : C(a,a,refl(a)) P : M = N path-ind[C](a.R,refl(M)) ≡ R[M/a] : C(M,M,refl(M)) M : A a:A ⊦ R : C(a,a,refl(a))

slide-47
SLIDE 47

18

Canonicity for Paths?

path-ind[C](a.R,P) : C(M,N,P) refl(M) : M =A M M : A a:A ⊦ R : C(a,a,refl(a)) P : M = N path-ind[C](a.R,refl(M)) ≡ R[M/a] : C(M,M,refl(M)) M : A a:A ⊦ R : C(a,a,refl(a)) path-ind[C](a.R,ua(E)) ≡ ???

slide-48
SLIDE 48

19

Can we have a new TT with canonicity + univalence?

Yes with De Morgan cubes [CCHM 2016] Yes with Cartesian cubes [AFH 2017]

... and higher inductive types?

Examples with De Morgan cubes [CHM 2018] Yes with Cartesian cubes [CH 2018]

Restore Canonicity

slide-49
SLIDE 49

20

Restore Canonicity

Idea: each type manages its own paths

slide-50
SLIDE 50

20

Restore Canonicity

Idea: each type manages its own paths

base loop

base : S1

slide-51
SLIDE 51

20

Restore Canonicity

Idea: each type manages its own paths

loop : base = base

base loop

base : S1

slide-52
SLIDE 52

20

Restore Canonicity

Idea: each type manages its own paths

loop : base = base

base loop

base : S1

slide-53
SLIDE 53

20

Restore Canonicity

Idea: each type manages its own paths

loop : base = base

base loop

x:𝕁 ⊦ loop{x} : S1 loop{0} ≡ base : S1 base : S1 loop{1} ≡ base : S1

slide-54
SLIDE 54

20

Restore Canonicity

Idea: each type manages its own paths

loop : base = base

base loop

x:𝕁 ⊦ loop{x} : S1 loop{0} ≡ base : S1 base : S1 loop{1} ≡ base : S1

Kan structure: sufficient to implement path-ind Kan types: types with Kan structure

slide-55
SLIDE 55

21

Introducing 𝕁 the formal interval

Cartesian Cubes

slide-56
SLIDE 56

21

Γ, x:𝕁, Γ' ⊦ x:𝕁 Γ ⊦ 0:𝕁 Γ ⊦ 1:𝕁 Introducing 𝕁 the formal interval

Cartesian Cubes

slide-57
SLIDE 57

21

Γ, x:𝕁, Γ' ⊦ x:𝕁

⬄ M is an n-cube in A

Γ ⊦ 0:𝕁 Γ ⊦ 1:𝕁 Introducing 𝕁 the formal interval x1:𝕁, x2:𝕁, ..., xn:𝕁 ⊦ M : A

Cartesian Cubes

slide-58
SLIDE 58

22

Γ, x:𝕁, Γ' ⊦ x:𝕁 Γ ⊦ 0:𝕁 Γ ⊦ 1:𝕁 Introducing 𝕁 the formal interval

Cartesian Cubes

Cartesian: works as normal contexts M⟨0/x⟩ M⟨1/x⟩ M⟨y/x⟩ x y

slide-59
SLIDE 59

23

Cubical Programming

dim expr r := 0 | 1 | x

1 x

indeterminate

slide-60
SLIDE 60

24

Circle

base loop{x}

slide-61
SLIDE 61

24

Circle

dim expr

base loop{x}

M := S1 | base | loop{r} | S1elim(a.M, M, M, x.M) | ...

slide-62
SLIDE 62

24

Circle

dim expr

base loop{x} S1 val

M := S1 | base | loop{r} | S1elim(a.M, M, M, x.M) | ...

slide-63
SLIDE 63

24

Circle

dim expr

base loop{x} base val S1 val

M := S1 | base | loop{r} | S1elim(a.M, M, M, x.M) | ...

slide-64
SLIDE 64

24

Circle

dim expr

loop{x} val loop{0} ↦ base loop{1} ↦ base base loop{x} base val S1 val

M := S1 | base | loop{r} | S1elim(a.M, M, M, x.M) | ...

slide-65
SLIDE 65

25

Circle

base loop{x} M ↦ M'  S1elim(a.A, M, B, x.L) ↦ S1elim(a.A, M', B, x.L) S1 val

slide-66
SLIDE 66

25

Circle

S1elim(a.A, base, B, x._) ↦ B base loop{x} M ↦ M'  S1elim(a.A, M, B, x.L) ↦ S1elim(a.A, M', B, x.L) S1 val

slide-67
SLIDE 67

25

Circle

S1elim(a.A, base, B, x._) ↦ B base loop{x} S1elim(a.A, loop{x}, _, y.L) ↦ L<x/y> M ↦ M'  S1elim(a.A, M, B, x.L) ↦ S1elim(a.A, M', B, x.L) S1 val

slide-68
SLIDE 68

26

Kan 1/2: Coercion

M x x.A ∈

slide-69
SLIDE 69

26

Kan 1/2: Coercion

coe[0↝1] {x.A}(M) M x x.A ∈ ∈

slide-70
SLIDE 70

26 coe[r↝r']{x.A}(M) ∈ A<r'/x>

Kan 1/2: Coercion

coe[0↝1] {x.A}(M) M

A<r/x>

∈ x x.A ∈ ∈

slide-71
SLIDE 71

26 coe[r↝r']{x.A}(M) ∈ A<r'/x>

Kan 1/2: Coercion

coe[0↝1] {x.A}(M) M

A<r/x>

∈ x x.A ∈ ∈

coe[r↝r]{x.A}(M) ≐ M ∈ A<r/x>

slide-72
SLIDE 72

26 coe[r↝r']{x.A}(M) ∈ A<r'/x>

Kan 1/2: Coercion

coe[0↝1] {x.A}(M) M

A<r/x>

∈ x x.A ∈ ∈ coe[0↝x] {x.A}(M)

coe[r↝r]{x.A}(M) ≐ M ∈ A<r/x>

slide-73
SLIDE 73

27

Kan 2/2: Homogeneous Comp.

M x y N0 N1

slide-74
SLIDE 74

27

Kan 2/2: Homogeneous Comp.

M x y N0 N1 hcom[0↝1]{A}(M) [x=0⟶y.N0, x=1⟶y.N1]

slide-75
SLIDE 75

27

hcom[r↝r']{A}(M) […, ri=r'i⟶y.Ni, …] ∈ A

Kan 2/2: Homogeneous Comp.

M x y N0 N1 hcom[0↝1]{A}(M) [x=0⟶y.N0, x=1⟶y.N1]

slide-76
SLIDE 76

27

hcom[r↝r']{A}(M) […, ri=r'i⟶y.Ni, …] ∈ A

Kan 2/2: Homogeneous Comp.

M x y N0 N1 hcom[0↝1]{A}(M) [x=0⟶y.N0, x=1⟶y.N1]

hcom[r↝r]{A}(M) ≐ M ∈ A hcom[r↝r']{A}(M)[…, ri=ri⟶y.Ni, …] ≐ Ni<r'/y> ∈ A

slide-77
SLIDE 77

28

Kan 2/2: Homogeneous Comp.

slide-78
SLIDE 78

29

Kan Circle

coe[r↝r']{_.S1}(M) ↦ M

slide-79
SLIDE 79

29

Kan Circle

hcom[r↝r']{S1}(M)[…] ↦ fhcom[r↝r'](M)[…] coe[r↝r']{_.S1}(M) ↦ M formal homo. composition

slide-80
SLIDE 80

29

Kan Circle

hcom[r↝r']{S1}(M)[…] ↦ fhcom[r↝r'](M)[…] coe[r↝r']{_.S1}(M) ↦ M formal homo. composition fhcom[r↝r](M)[…] ↦ M

slide-81
SLIDE 81

29

Kan Circle

hcom[r↝r']{S1}(M)[…] ↦ fhcom[r↝r'](M)[…]

r!=r' ri=r'i (the first i)  fhcom[r↝r'](M)[…, ri=r'i⟶y.Ni, …] ↦ Ni<r'/y>

coe[r↝r']{_.S1}(M) ↦ M formal homo. composition fhcom[r↝r](M)[…] ↦ M

slide-82
SLIDE 82

29

Kan Circle

hcom[r↝r']{S1}(M)[…] ↦ fhcom[r↝r'](M)[…]

r!=r' ri=r'i (the first i)  fhcom[r↝r'](M)[…, ri=r'i⟶y.Ni, …] ↦ Ni<r'/y> r!=r' ri!=r'i for all i  fhcom[r↝r'](M)[…] val

coe[r↝r']{_.S1}(M) ↦ M formal homo. composition fhcom[r↝r](M)[…] ↦ M

slide-83
SLIDE 83

30

Kan Circle

S1elim needs to handle fcom

slide-84
SLIDE 84

30

Kan Circle

r!=r' ri!=r'i  S1elim(a.A, fhcom[r↝r'](M)[…], B, x.L) ↦ com[r↝r']{y.A[fhcom[r↝y](M)[…]/a} (S1elim(M, B, x.L))[…] S1elim(composition) ↦ composition(S1elim)

S1elim needs to handle fcom

slide-85
SLIDE 85

31

Cubical Stability

Dimension substs. do not commute with evaluation!

slide-86
SLIDE 86

31

Cubical Stability

S1elim(a.A, loop{x}, B, y.L) |⟶ L<x/y> ⟶ <0/x> L<0/y>

Dimension substs. do not commute with evaluation!

slide-87
SLIDE 87

31

Cubical Stability

S1elim(a.A, loop{x}, B, y.L) S1elim(a.A, base, B, y.L) |⟶ L<x/y> |> B ⟶ <0/x> ⟶ <0/x> L<0/y>

Dimension substs. do not commute with evaluation!

<=??=>

slide-88
SLIDE 88

31

Cubical Stability

S1elim(a.A, loop{x}, B, y.L) S1elim(a.A, base, B, y.L) |⟶ L<x/y> |> B ⟶ <0/x> ⟶ <0/x> L<0/y>

Dimension substs. do not commute with evaluation!

<=??=> Restrict our theory to

  • nly cubically stable parts
slide-89
SLIDE 89

32 stability: consider every substitution

Cubical Type Theory

slide-90
SLIDE 90

32 stability: consider every substitution

A and B stably recognize the same stable values and have stably equal Kan structures

Cubical Type Theory

(see our arXiv papers)

A ≐ B type [Ψ]

dim context

slide-91
SLIDE 91

32 stability: consider every substitution

A and B stably recognize the same stable values and have stably equal Kan structures A ≐ A type [Ψ], M and N stably eval to M' and N', A stably treats M' and N' as the same

Cubical Type Theory

(see our arXiv papers)

A ≐ B type [Ψ] M ≐ N ∈ A [Ψ]

dim context

slide-92
SLIDE 92

33

Nuprl/... Coq/Agda/...

Vars range over closed terms Vars are indet. Defined by conversion b/w

  • pen terms

Defined by transition b/w closed terms

Variables

dim vars exp vars

cubical computational TT

slide-93
SLIDE 93

34 CHTT Part I [AHW 2016] CHTT Part II [AH 2017] CHTT Part III [AFH 2017] CHTT Part IV [AFH 2017]

Cartesian cubical + computational Dependent types Univalent Kan universes Strict equality Higher inductive types

arXiv papers

slide-94
SLIDE 94

35

RedPRL

In Nuprl style

yacctt redtt

redprl.org Proof of concept modified from cubicaltt (Work in progress)

Proof Assistants

github.com/mortberg/yacctt github.com/RedPRL/redtt

slide-95
SLIDE 95

36

Conclusion

We extended Nuprl semantics by cubical structure which justifies key features of HoTT

slide-96
SLIDE 96

36

Conclusion

We extended Nuprl semantics by cubical structure which justifies key features of HoTT

Best of the two worlds!

slide-97
SLIDE 97

36

Conclusion

We extended Nuprl semantics by cubical structure which justifies key features of HoTT We also built proof assistants

Best of the two worlds!

redprl.org github.com/mortberg/yacctt github.com/RedPRL/redtt