Yet Another Cartesian Cubical Type Theory Anders M ortberg - - PowerPoint PPT Presentation

yet another cartesian cubical type theory
SMART_READER_LITE
LIVE PREVIEW

Yet Another Cartesian Cubical Type Theory Anders M ortberg - - PowerPoint PPT Presentation

Yet Another Cartesian Cubical Type Theory Anders M ortberg Carnegie Mellon University and University of Gothenburg Types, Homotopy Type theory, and Verification HIM Bonn June 6, 2018 June 6, 2018 1 / 40 Anders M ortberg Cubes, cubes,


slide-1
SLIDE 1

Yet Another Cartesian Cubical Type Theory

Anders M¨

  • rtberg

Carnegie Mellon University and University of Gothenburg

Types, Homotopy Type theory, and Verification HIM Bonn June 6, 2018

Anders M¨

  • rtberg

June 6, 2018 1 / 40

slide-2
SLIDE 2

Cubes, cubes, cubes...

I will talk about my attempts to understand the new and exciting developments on Cartesian cubical type theories:

Computational Higher Type Theory III: Univalent Universes and Exact Equality

(Angiuli, Favonia, Harper - AFH)

Cartesian Cubical Type Theory

(Angiuli, Brunerie, Coquand, Favonia, Harper, Licata - ABCFHL) These provide us with new constructive models of Univalent Foundations and higher inductive types

Anders M¨

  • rtberg

Introduction June 6, 2018 2 / 40

slide-3
SLIDE 3

yacctt

Slogan: the best way to understand type theory is to implement it! Together with Carlo Angiuli I have adapted the code-base of cubicaltt to implement a Cartesian cubical type theory: yacctt: yet another cartesian cubical type theory1 https://github.com/mortberg/yacctt/ Inspired by Cubical Type Theory: a constructive interpretation of the univalence axiom (Cohen, Coquand, Huber, M. - CCHM)

1https://en.wikipedia.org/wiki/Yacc Anders M¨

  • rtberg

Introduction June 6, 2018 3 / 40

slide-4
SLIDE 4

yacctt

In this talk I will present this syntactically, however everything I say can be done internally in a topos extended with suitable axioms following: Axioms for Modelling Cubical Type Theory in a Topos (Orton, Pitts) Internal Universes in Models of Homotopy Type Theory (Licata, Orton, Pitts, Spitters) This is the approach taken in ABCFHL

Anders M¨

  • rtberg

Introduction June 6, 2018 4 / 40

slide-5
SLIDE 5

yacctt

My main motivation for implementing another cubical type theory is to explore the following:

1 How convenient is it to formalize mathematics in this new system

with its new primitives?

2 Does this compute more efficiently than cubicaltt? (Can we compute

the Brunerie number?)

Anders M¨

  • rtberg

Introduction June 6, 2018 5 / 40

slide-6
SLIDE 6

yacctt

yacctt extends dependent type theory (with eta for Π and Σ) with: Path types based on a Cartesian interval Diagonal context restrictions (generating cofibrations) Generalized Kan operations (transport of structures2) V-types (special case of Glue-types that suffices for univalence) Fibrant universes Some higher inductive types

  • 2cf. Bourbaki: Theory of sets, 1968

Anders M¨

  • rtberg

Introduction June 6, 2018 6 / 40

slide-7
SLIDE 7

Cartesian interval

Formal representation of the interval, I: r, s ::= 0 | 1 | i i, j, k... formal symbols/names representing directions/dimensions Contexts can contain variables in the interval: Γ ⊢ Γ, i : I ⊢

Anders M¨

  • rtberg

Cartesian interval June 6, 2018 7 / 40

slide-8
SLIDE 8

Cartesian interval

i : I ⊢ A corresponds to a line: A(0/i) A(1/i)

A

i : I, j : I ⊢ A corresponds to a square: A(0/i)(1/j) A(1/i)(1/j) A(0/i)(0/j) A(1/i)(0/j)

A(1/j) A(j/i) A(0/j) A(0/i) A(1/i)

j i Diagonal substitutions are allowed (no linearity constraint as in BCH)

Anders M¨

  • rtberg

Cartesian interval June 6, 2018 8 / 40

slide-9
SLIDE 9

Path types

The Path types are modelled as: Path(A) := AI PathA(a, b) := {p ∈ Path(A) | p 0 = a ∧ p 1 = b} In the syntax we write Path A a b for the Path types and i u for Path abstraction These types are defined by the same rules as in CCHM and provide a convenient syntax for directly reasoning about (higher) equality types We can directly prove that these satisfy function extensionality (CCHM)

Anders M¨

  • rtberg

Cartesian interval June 6, 2018 9 / 40

slide-10
SLIDE 10

Composition operations

We want to be able to compose paths: a b

p

b c

q

We do this by computing the dashed line in: a c a b

p a q

In general this corresponds to computing the missing sides of n-dimensional cubes

Anders M¨

  • rtberg

Context restrictions June 6, 2018 10 / 40

slide-11
SLIDE 11

Composition operations

Box principle: any open box has a lid Cubical version of the Kan condition for simplicial sets: “Any horn can be filled” First formulated by Daniel Kan in “Abstract Homotopy I” (1955) for cubical complexes

Anders M¨

  • rtberg

Context restrictions June 6, 2018 11 / 40

slide-12
SLIDE 12

Context restrictions

To formulate this we need syntax for representing partially specified n-dimensional cubes We add context restrictions Γ, ϕ where ϕ is a “face formula” representing a subset of the faces of a cube ϕ, ψ ::= 0F | 1F | (i = 0) | (i = 1) | (i = j) | ϕ ∧ ψ | ϕ ∨ ψ Key new idea is to allow (i = j) as context restrictions! (AFH)

Anders M¨

  • rtberg

Context restrictions June 6, 2018 12 / 40

slide-13
SLIDE 13

Partial elements

Any judgment valid in a context Γ is also valid in a restriction Γ, ϕ Γ ⊢ A Γ, ϕ ⊢ A If Γ ⊢ A and Γ, ϕ ⊢ a : A then a is a partial element of A of extent ϕ We write Γ ⊢ b : A[ϕ → a] for Γ ⊢ b : A Γ, ϕ ⊢ a : A Γ, ϕ ⊢ a = b : A

Anders M¨

  • rtberg

Context restrictions June 6, 2018 13 / 40

slide-14
SLIDE 14

Box principle in CCHM

In CCHM we formulated the box principle as: Γ, i : I ⊢ A Γ, ϕ, i : I ⊢ u : A Γ ⊢ u0 : A(0/i)[ϕ → u(0/i)] Γ ⊢ compi A [ϕ → u] u0 : A(1/i)[ϕ → u(1/i)] u0 is the bottom u is the sides compi A [ϕ → u] u0 is the lid Semantically this is a structure (and not a property) of a type. A type is called fibrant if it can be equipped with this structure

Anders M¨

  • rtberg

Kan operations June 6, 2018 14 / 40

slide-15
SLIDE 15

Composition operations: example

With composition we can justify transitivity of path types: Γ ⊢ p : Path A a b Γ ⊢ q : Path A b c Γ ⊢ i compj A [(i = 0) → a, (i = 1) → q j] (p i) : Path A a c a c a b

p i a q j

j i

Anders M¨

  • rtberg

Kan operations June 6, 2018 15 / 40

slide-16
SLIDE 16

Transport as composition in CCHM

Composition for ϕ = 0F corresponds to transport: Γ, i : I ⊢ A Γ ⊢ u0 : A(i/0) Γ ⊢ transporti A u0 = compi A [] u0 : A(i/1) u0 •

  • transporti A u0

A(0/i) A(1/i)

A

i Anders M¨

  • rtberg

Kan operations June 6, 2018 16 / 40

slide-17
SLIDE 17

Kan filling from composition

A key observation in CCHM is that we can compute the filler of a cube using composition and connections In yacctt we don’t have any connections... What can we do?

Anders M¨

  • rtberg

Kan operations June 6, 2018 17 / 40

slide-18
SLIDE 18

Kan filling from composition

A key observation in CCHM is that we can compute the filler of a cube using composition and connections In yacctt we don’t have any connections... What can we do? Solution: strengthen the composition operation!

Anders M¨

  • rtberg

Kan operations June 6, 2018 17 / 40

slide-19
SLIDE 19

Strengthened composition

Compose from r to s: Γ, i : I ⊢ A Γ ⊢ r : I Γ ⊢ s : I Γ ⊢ ϕ : F Γ, ϕ, i : I ⊢ u : A Γ ⊢ u0 : A(r/i)[ϕ → u(r/i)] Γ ⊢ comr→s

i

A [ϕ → u] u0 : A(s/i)[ϕ → u(s/i), r = s → u0] We recover comp when r = 0 and s = 1 We get the filler when r = 0 and s is a dimension variable j : I

Anders M¨

  • rtberg

Kan operations June 6, 2018 18 / 40

slide-20
SLIDE 20

Strengthened composition

We can now define com by cases on the type A just like in CCHM, however in order to also be able to support HITs we first decompose the

  • peration into homogeneous composition and coercion:

Γ ⊢ A Γ ⊢ r : I Γ ⊢ s : I Γ ⊢ ϕ : F Γ, ϕ, i : I ⊢ u : A Γ ⊢ u0 : A[ϕ → u(r/i)] Γ ⊢ hcomr→s

i

A [ϕ → u] u0 : A[ϕ → u(s/i), r = s → u0] Γ, i : I ⊢ A Γ ⊢ r : I Γ ⊢ s : I Γ ⊢ u : A(r/i) Γ ⊢ coer→s

i

A u : A(s/i)[r = s → u]

Anders M¨

  • rtberg

Kan operations June 6, 2018 19 / 40

slide-21
SLIDE 21

Coercion examples

Given i : I ⊢ u : A we get: A(0/i) A(1/i) u(1/i) u(0/i)

A u

Anders M¨

  • rtberg

Kan operations June 6, 2018 20 / 40

slide-22
SLIDE 22

Coercion examples

Given i : I ⊢ u : A we get: A(0/i) A(1/i) u(1/i) u(0/i) coe0→1

i

A u(0/i)

A u

Anders M¨

  • rtberg

Kan operations June 6, 2018 20 / 40

slide-23
SLIDE 23

Coercion examples

Given i : I ⊢ u : A we get: A(0/i) A(1/i) u(1/i) u(0/i) coe0→1

i

A u(0/i)

A u coe0→i

i

A u(0/i)

Anders M¨

  • rtberg

Kan operations June 6, 2018 20 / 40

slide-24
SLIDE 24

Coercion examples

Given i : I ⊢ u : A we get: A(0/i) A(1/i) u(1/i) u(0/i) coe0→1

i

A u(0/i)

A u coei→1

i

A u coe0→i

i

A u(0/i)

Anders M¨

  • rtberg

Kan operations June 6, 2018 20 / 40

slide-25
SLIDE 25

Reversals

Given p : Path A a b we can define p−1 : Path A b a as p−1 := ihcom0→1

j

A [(i = 0) → p j, (i = 1) → a] a This corresponds to the dashed line in: b a a a

p p−1 a a

Anders M¨

  • rtberg

Kan operations June 6, 2018 21 / 40

slide-26
SLIDE 26

Connections

Given p : Path A a b we can define: i jhcom0→1

k

A [(i = 0) → hcom1→0

l

A [(k = 0) → a, (k = 1) → p l] (p k) ,(i = 1) → hcom1→j

l

A [(k = 0) → a, (k = 1) → p l] (p k) ,(j = 0) → hcom1→0

l

A [(k = 0) → a, (k = 1) → p l] (p k) ,(j = 1) → hcom1→i

l

A [(k = 0) → a, (k = 1) → p l] (p k)] a This has boundary: a a a b

a p a p

Anders M¨

  • rtberg

Kan operations June 6, 2018 22 / 40

slide-27
SLIDE 27

Connections

Given p : Path A a b we can define: i jhcom0→1

k

A [(i = 0) → hcom1→0

l

A [(k = 0) → a, (k = 1) → p l] (p k) ,(i = 1) → hcom1→j

l

A [(k = 0) → a, (k = 1) → p l] (p k) ,(j = 0) → hcom1→0

l

A [(k = 0) → a, (k = 1) → p l] (p k) ,(j = 1) → hcom1→i

l

A [(k = 0) → a, (k = 1) → p l] (p k) ,(i = j) → hcom1→i

l

A [(k = 0) → a, (k = 1) → p l] (p k)] a This has boundary: a a a b

a p a p p

Anders M¨

  • rtberg

Kan operations June 6, 2018 22 / 40

slide-28
SLIDE 28

Reversals and connections

These definitions of reversals and connections does not satisfy as many judgmental equalities as the corresponding ones in CCHM How does this affect practical formalization?

Anders M¨

  • rtberg

Kan operations June 6, 2018 23 / 40

slide-29
SLIDE 29

Reversals and connections

These definitions of reversals and connections does not satisfy as many judgmental equalities as the corresponding ones in CCHM How does this affect practical formalization? For example in CCHM we directly get that (C op)op = C using reversals However, many examples that use reversals and connections in CCHM can be done directly with the generalized Kan operations

Anders M¨

  • rtberg

Kan operations June 6, 2018 23 / 40

slide-30
SLIDE 30

Coercion back and forth

Given i : I ⊢ A and a : A(0/i) we have: A(0/i) A(1/i) a

A

Anders M¨

  • rtberg

Kan operations June 6, 2018 24 / 40

slide-31
SLIDE 31

Coercion back and forth

Given i : I ⊢ A and a : A(0/i) we have: A(0/i) A(1/i) a coe0→1

i

A a

A

Anders M¨

  • rtberg

Kan operations June 6, 2018 24 / 40

slide-32
SLIDE 32

Coercion back and forth

Given i : I ⊢ A and a : A(0/i) we have: A(0/i) A(1/i) coe1→0

i

A (coe0→1

i

A a) a coe0→1

i

A a

A

Anders M¨

  • rtberg

Kan operations June 6, 2018 24 / 40

slide-33
SLIDE 33

Coercion back and forth

Given i : I ⊢ A and a : A(0/i) we have: A(0/i) A(1/i) coe1→0

i

A (coe0→1

i

A a) a coe0→1

i

A a

A p?

Anders M¨

  • rtberg

Kan operations June 6, 2018 24 / 40

slide-34
SLIDE 34

Coercion back and forth

Given i : I ⊢ A and a : A(0/i) we have: A(0/i) A(1/i) coe1→0

i

A (coe0→1

i

A a) a coe0→1

i

A a

A p?

We take p := j coej→0

i

A (coe0→j

i

A a)

Anders M¨

  • rtberg

Kan operations June 6, 2018 24 / 40

slide-35
SLIDE 35

Coercion back and forth

Given i : I ⊢ A and a : A(0/i) we have: A(0/i) A(1/i) coe1→0

i

A (coe0→1

i

A a) a coe0→1

i

A a

A p?

We take p := j coej→0

i

A (coe0→j

i

A a) The corresponding result in CCHM is quite a bit more involved (it uses 3 non-homogeneous compositions)

Anders M¨

  • rtberg

Kan operations June 6, 2018 24 / 40

slide-36
SLIDE 36

hcom and coe

We define the judgmental computation rules for hcom and coe by cases of the type A There are no surprises for Π, Σ, Path and basic datatypes like N

Anders M¨

  • rtberg

Kan operations June 6, 2018 25 / 40

slide-37
SLIDE 37

hcom and coe

We define the judgmental computation rules for hcom and coe by cases of the type A There are no surprises for Π, Σ, Path and basic datatypes like N The algorithms for hcom and coe are often simpler than the corresponding

  • nes for com, so I would conjecture that this decomposition is also good

for efficiency The decomposition is also very natural for formalization: we often want to compose in a constant type or just coerce without any constraints

Anders M¨

  • rtberg

Kan operations June 6, 2018 25 / 40

slide-38
SLIDE 38

Univalence and V-types

In order to be able to prove univalence we need a way to turn equivalences into paths in the universe We could use CCHM Glue-types (as in ABCFHL), but instead we follow AFH and introduce a special case of Glue-types called “V-types”3 These allow us to “glue” an equivalence to one side of a line between types (i.e. to extend an equivalence along an endpoint inclusion)

3“V” in honour of Voevodsky Anders M¨

  • rtberg

V-types June 6, 2018 26 / 40

slide-39
SLIDE 39

V-types

In the case when r is a dimension variable i : I the V-type Vi(A, B, e) can be drawn as the dashed line in: A B(0/i) B(1/i)

e ∼ B Vi(A, B, e)

Anders M¨

  • rtberg

V-types June 6, 2018 27 / 40

slide-40
SLIDE 40

V-types typing rules (slide of death)

Γ ⊢ r : I Γ, r = 0 ⊢ A Γ ⊢ B Γ, r = 0 ⊢ e : Equiv A B Γ ⊢ Vr(A, B, e)[r = 0 → A, r = 1 → B] Γ ⊢ r : I Γ, r = 0 ⊢ u : A Γ ⊢ v : B[r = 0 → e u] Γ, r = 0 ⊢ e : Equiv A B Γ ⊢ Vinr u v : Vr(A, B, e)[r = 0 → u, r = 1 → v] Γ ⊢ r : I Γ ⊢ u : Vr(A, B, e) Γ ⊢ Vprojr u e : B[r = 0 → e u, r = 1 → u]

Anders M¨

  • rtberg

V-types June 6, 2018 28 / 40

slide-41
SLIDE 41

V-types

Semantically V-types correspond to the following special case of Glue-types: Γ, (i = 0) Γ A B

∼ e

B

Anders M¨

  • rtberg

V-types June 6, 2018 29 / 40

slide-42
SLIDE 42

V-types

Semantically V-types correspond to the following special case of Glue-types: Γ, (i = 0) Γ A B

∼ e

B Vi(A, B, e)

Vproji

Anders M¨

  • rtberg

V-types June 6, 2018 29 / 40

slide-43
SLIDE 43

V-types: fibrancy

To prove that these types are fibrant we have to define: hcomr→s

i

(Vj(A, B, e)) [ϕ → u] u0 coer→s

i

(Vj(A, B, e)) u Both hcom, and coe when i = j, are straightforward Only coe when i = j requires e to be an equivalence, furthermore this case crucially uses the diagonal constraints/cofibrations None of the cases uses the ∀i operation of CCHM

Anders M¨

  • rtberg

V-types June 6, 2018 30 / 40

slide-44
SLIDE 44

V-types: coer→s

i

(Vi(A, B, e)) u : Vs[r = s → u]

For this let: u′ := Vprojr u e(r/i) P := coer→s

i

B u′ (C1, C2) := e(s/i).2 P R := hcom1→0

k

(Fiber e(s/i) P) [r = 0 → C2 (u, P) k , r = 1 → C1] C1 S := hcom1→0

k

B(s/i) [s = 0 → R.2 k , r = s → Vprojs u e(s/i)] P and we define coer→s

i

(Vi(A, B, e)) u := Vins R.1 S

Anders M¨

  • rtberg

V-types June 6, 2018 31 / 40

slide-45
SLIDE 45

Fibrant universes

We also have universes in yacctt, however as we are not using Glue-types we have to do more work to prove that they are fibrant We follow a direct argument from AFH for glueing on lines of types onto a line of types4 The coe operation uses ∀i, and both coe and hcom uses the diagonal constraints/cofibrations in a crucial way

4This is similar to an unfolded version of composition for the universe in CCHM,

which in fact is what we implemented in cubicaltt for efficiency

Anders M¨

  • rtberg

V-types June 6, 2018 32 / 40

slide-46
SLIDE 46

Univalence and V-types

I have formalized two proofs of univalence in yacctt The first proof uses the observation that we can prove the full univalence axiom from an operation ua : Equiv A B → Path U A B satisfying uaβ : Path B (coe0→1

i

(ua e i) a) (e a) for all a : A

Anders M¨

  • rtberg

V-types June 6, 2018 33 / 40

slide-47
SLIDE 47

Univalence and V-types

Given e : Equiv A B we define: ua := i Vi(A, B, e)

Anders M¨

  • rtberg

V-types June 6, 2018 34 / 40

slide-48
SLIDE 48

Univalence and V-types

Given e : Equiv A B we define: ua := i Vi(A, B, e) If we unfold the algorithm for coercion in V-types we see that coe0→1

i

(ua i) a = coe0→1

i

(Vi(A, B, e)) a = coe0→1

i

B (e a)

Anders M¨

  • rtberg

V-types June 6, 2018 34 / 40

slide-49
SLIDE 49

Univalence and V-types

Given e : Equiv A B we define: ua := i Vi(A, B, e) If we unfold the algorithm for coercion in V-types we see that coe0→1

i

(ua i) a = coe0→1

i

(Vi(A, B, e)) a = coe0→1

i

B (e a) We can hence define uaβ := icoei→1

i

B (e a) This is simpler than in cubicaltt where the algorithm for composition for Glue-types gives two trivial compositions

Anders M¨

  • rtberg

V-types June 6, 2018 34 / 40

slide-50
SLIDE 50

V-types and univalence

The second proof of univalence is similar to the one in CCHM where we show that unglue is an equivalence: Γ, (i = 0) Γ A B

∼ e

B Vi(A, B, e)

∼ Vproji

Anders M¨

  • rtberg

V-types June 6, 2018 35 / 40

slide-51
SLIDE 51

V-types and univalence

From this we can directly prove that given any type A : U the type (B : U) × Equiv A B is contractible5

Corollary (Univalence)

For any term t : (A B : U) → Path U A B → Equiv A B the map t A B is an equivalence for all A and B

5I was a bit surprised that this worked out so smoothly Anders M¨

  • rtberg

V-types June 6, 2018 36 / 40

slide-52
SLIDE 52

Higher inductive types

We have so far only added support for a few hardcoded HITs, but it should be possible to add a schema of them following

Computational Higher Type Theory IV: Inductive Types

(Cavallo, Harper) The algorithms for coe in HITs are very similar to those in CCHM:

On Higher Inductive Types in Cubical Type Theory

(Coquand, Huber, M.)

Anders M¨

  • rtberg

HITs June 6, 2018 37 / 40

slide-53
SLIDE 53

Conclusions

We have implemented a simple experimental proof assistant based on Cartesian cubical type theory Some proofs are simpler compared to cubicaltt, while some are a bit harder I’m optimistic that the V-types might be a bit more efficient than Glue-types for computing with univalence

Anders M¨

  • rtberg

Conclusions June 6, 2018 38 / 40

slide-54
SLIDE 54

Open questions

Can we make progress on computing Brunerie’s number using yacctt? Can we design a super cubical type theory with connections, reversals and generalized Kan operations?

Anders M¨

  • rtberg

Conclusions June 6, 2018 39 / 40

slide-55
SLIDE 55

Thank you for your attention!

https://github.com/mortberg/yacctt/

Anders M¨

  • rtberg

June 6, 2018 40 / 40