These systems differ from cubicaltt in that they are proper proof assistants for cubical type theory in the sense that they support unification, interactive proof development via holes, etc… Cubical Agda inherits Agda’s powerful dependent pattern matching functionality, and redtt has a succinct notation for defining functions by eliminators. Our goal with cubicaltt was never to develop yet another proof assistant, but rather to explore how it could be to program and work in a core system based on cubical type theory. This meant that many things were quite tedious to do in cubicaltt, so it is great that we now have these more advanced systems that are much more pleasant to work in.

This post is about Cubical Agda, but more or less everything in it can also be done (with slight modifications) in redtt. This extension of Agda has actually been around for a few years now, however it is just this year that the theory of HITs has been properly worked out for cubical type theory:

On Higher Inductive Types in Cubical Type Theory

Inspired by this paper (which I will refer as “CHM”) Andrea has extended Cubical Agda with user definable HITs with definitional computation rules for all constructors. Working with these is a lot of fun and I have been doing many of the proofs in synthetic homotopy theory from the HoTT book cubically. Having a system with native support for HITs makes many things a lot easier and most of the proofs I have done are significantly shorter. However, this post will not focus on HITs, but rather on a core library for Cubical Agda that we have been developing over the last few months:

https://github.com/agda/cubical

The core part of this library has been designed with the aim to:

1. Expose and document the cubical primitives of Agda.

2. Provide an interface to HoTT as presented in the book (i.e. “Book HoTT”), but where everything is implemented with the cubical primitives under the hood.

The idea behind the second of these was suggested to me by Martín Escardó who wanted a file which exposes an identity type with the standard introduction principle and eliminator (satisfying the computation rule definitionally), together with function extensionality, univalence and propositional truncation. All of these notions should be represented using cubical primitives under the hood which means that they all compute and that there are no axioms involved. In particular this means that one can import this file in an Agda developments relying on Book HoTT and no axioms should then be needed; more about this later.

Our cubical library compiles with the latest development version of Agda and it is currently divided into 3 main parts:

Cubical.Basics Cubical.Core Cubical.HITs

The first of these contain various basic results from HoTT/UF, like isomorphisms are equivalences (i.e. have contractible fibers), Hedberg’s theorem (types with decidable equality are sets), various proofs of different formulations of univalence, etc. This part of the library is currently in flux as I’m adding a lot of results to it all the time.

The second one is the one I will focus on in this post and it is supposed to be quite stable by now. The files in this folder expose the cubical primitives and the cubical interface to HoTT/UF. Ideally a regular user should not have to look too closely at these files and instead just import `Cubical.Core.Everything`

or `Cubical.Core.HoTT-UF`

.

The third folder contains various HITs (S¹, S², S³, torus, suspension, pushouts, interval, join, smash products…) with some basic theory about these. I plan to write another post about this soon, so stay tuned.

As I said above a regular user should only really need to know about the `Cubical.Core.Everything`

and `Cubical.Core.HoTT-UF`

files in the core library. The `Cubical.Core.Everything`

file exports the following things:

-- Basic primitives (some are from Agda.Primitive) open import Cubical.Core.Primitives public -- Basic cubical prelude open import Cubical.Core.Prelude public -- Definition of equivalences, Glue types and -- the univalence theorem open import Cubical.Core.Glue public -- Propositional truncation defined as a -- higher inductive type open import Cubical.Core.PropositionalTruncation public -- Definition of Identity types and definitions of J, -- funExt, univalence and propositional truncation -- using Id instead of Path open import Cubical.Core.Id public

I will explain the contents of the `Cubical.Core.HoTT-UF`

file in detail later in this post, but I would first like to clarify that it is absolutely not necessary to use that file as a new user. The point of it is mainly to provide a way to make already existing HoTT/UF developments in Agda compute, but I personally only use the cubical primitives provided by the `Cubical.Core.Everything`

file when developing something new in Cubical Agda as I find these much more natural to work with (especially when reasoning about HITs).

It is not my intention to write another detailed explanation of cubical type theory in this post; for that see my previous post and the paper (which is commonly referred to as “CCHM”, after the authors of CCHM):

Cubical Type Theory: a constructive interpretation of the univalence axiom

The main things that the CCHM cubical type theory extends dependent type theory with are:

- An interval pretype
- Kan operations
- Glue types
- Cubical identity types

The first of these is what lets us work directly with higher dimensional cubes in type theory and incorporating this into the judgmental structure is really what makes the system tick. The `Cubical.Core.Primitives`

and `Cubical.Core.Prelude`

files provide 1 and 2, together with some extra stuff that are needed to get 3 and 4 up and running.

Let’s first look at the cubical interval `I`

. It has endpoints `i0 : I`

and `i1 : I`

together with connections and reversals:

_∧_ : I → I → I _∨_ : I → I → I ~_ : I → I

satisfying the structure of a De Morgan algebra (as in CCHM). As Agda doesn’t have a notion of non-fibrant types (yet?) the interval `I`

lives in `Setω`

.

There are also (dependent) cubical Path types:

PathP : ∀ {ℓ} (A : I → Set ℓ) → A i0 → A i1 → Set ℓ

from which we can define non-dependent Paths:

Path : ∀ {ℓ} (A : Set ℓ) → A → A → Set ℓ Path A a b = PathP (λ _ → A) a b

A non-dependent path `Path A a b`

gets printed as `a ≡ b`

. I would like to generalize this at some point and have cubical extension types (inspired by A type theory for synthetic ∞-categories). These extension types are already in redtt and has proved to be very natural and useful, especially for working with HITs as shown by this snippet of redtt code coming from the proof that the loop space of the circle is the integers:

def decode-square : (n : int) → [i j] s1 [ | i=0 → loopn (pred n) j | i=1 → loopn n j | j=0 → base | j=1 → loop i ] = ...

Just like in cubicaltt we get short proofs of the basic primitives from HoTT/UF:

refl : ∀ {ℓ} {A : Set ℓ} (x : A) → x ≡ x refl x = λ _ → x sym : ∀ {ℓ} {A : Set ℓ} {x y : A} → x ≡ y → y ≡ x sym p = λ i → p (~ i) cong : ∀ {ℓ ℓ'} {A : Set ℓ} {B : A → Set ℓ'} {x y : A} (f : (a : A) → B a) (p : x ≡ y) → PathP (λ i → B (p i)) (f x) (f y) cong f p = λ i → f (p i) funExt : ∀ {ℓ ℓ'} {A : Set ℓ} {B : A → Set ℓ'} {f g : (x : A) → B x} (p : (x : A) → f x ≡ g x) → f ≡ g funExt p i x = p x i

Note that the proof of functional extensionality is just swapping the arguments to p!

[*In order for me to be able to explain the other features of Cubical Agda in some detail I have to spend some time on partial elements and cubical subtypes, but as these notions are quite technical I would recommend readers who are not already familiar with them to just skim over this section and read it more carefully later.*]

One of the key operations in the cubical set model is to map an element of the interval to an element of the face lattice (i.e. the type of cofibrant propositions `F ⊂ Ω`

). This map is written `(_ = 1) : I → F`

in CCHM and in Cubical Agda it is written `IsOne r`

. The constant `1=1`

is a proof that `(i1 = 1)`

, i.e. of `IsOne i1`

.

This lets us then work with partial types and elements directly (which was not possible in cubicaltt). The type `Partial φ A`

is a special version of the function space `IsOne φ → A`

with a more extensional judgmental equality. There is also a dependent version `PartialP φ A`

which allows `A`

to be defined only on `φ`

. As these types are not necessarily fibrant they also live in `Setω`

. These types are easiest to understand by seeing how one can introduce them:

sys : ∀ i → Partial (i ∨ ~ i) Set₁ sys i (i = i1) = Set → Set sys i (i = i0) = Set

This defines a partial type in `Set₁`

which is defined when `(i = i1) ∨ (i = i0)`

. We define it by pattern matching so that it is `Set → Set`

when `(i = i1)`

and `Set`

when `(i = i0)`

. Note that we are writing `(i ∨ ~ i)`

and that the `IsOne`

map is implicit. If one instead puts a hole as right hand side:

sys : ∀ i → Partial (i ∨ ~ i) Set₁ sys i x = {! x !}

and ask Agda what the type of `x`

is (by putting the cursor in the hole and typing `C-c C-,`

) then Agda answers:

Goal: Set₁ ————————————————————————————————————————————— x : IsOne (i ∨ ~ i) i : I

I usually introduce these using pattern matching lambdas so that I can write:

sys' : ∀ i → Partial (i ∨ ~ i) Set₁ sys' i = \ { (i = i0) → Set ; (i = i1) → Set → Set }

This is very convenient when using the Kan operations. Furthermore, when the cases overlap they must of course agree:

sys2 : ∀ i j → Partial (i ∨ (i ∧ j)) Set₁ sys2 i j = \ { (i = i1) → Set ; (i = i1) (j = i1) → Set }

In order to get this to work Andrea had to adapt the pattern-matching of Agda to allow us to pattern-match on the faces like this. It is however not yet possible to use `C-c C-c`

to automatically generate the cases for a partial element, but hopefully this will be added at some point.

Using the partial elements there are also cubical subtypes as in CCHM:

_[_↦_] : ∀ {ℓ} (A : Set ℓ) (φ : I) (u : Partial φ A) → Agda.Primitive.Setω A [ φ ↦ u ] = Sub A φ u

So that `a : A [ φ ↦ u ]`

is a partial element `a : A`

that agrees with `u`

on `φ`

. We have maps in and out of the subtypes:

inc : ∀ {ℓ} {A : Set ℓ} {φ} (u : A) → A [ φ ↦ (λ _ → u) ] ouc : ∀ {ℓ} {A : Set ℓ} {φ : I} {u : Partial φ A} → A [ φ ↦ u ] → A

It would be very nice to have subtyping for these, but at the moment the user has to write `inc/ouc`

explicitly. With this infrastructure we can now consider the Kan operations of cubical type theory.

In order to support HITs we use the Kan operations from CHM. The first of these is a generalized transport operation:

transp : ∀ {ℓ} (A : I → Set ℓ) (φ : I) (a : A i0) → A i1

When calling `transp A φ a`

Agda makes sure that `A`

is constant on `φ`

and when calling this with `i0`

for `φ`

we recover the regular transport function, furthermore when `φ`

is `i1`

this is the identity function. Being able to control when transport is the identity function is really what makes this operation so useful (see the definition of comp below) and why we got HITs to work so nicely in CHM compared to CCHM.

We also have homogeneous composition operations:

hcomp : ∀ {ℓ} {A : Set ℓ} {φ : I} (u : I → Partial A φ) (a : A) → A

When calling `hcomp A φ u a`

Agda makes sure that `a`

agrees with `u i0`

on `φ`

. This is like the composition operations in CCHM, but the type `A`

is constant. Note that this operation is actually different from the one in CHM as `φ`

is in the interval and not the face lattice. By the way the partial elements are set up the faces will then be compared under the image of `IsOne`

. This subtle detail is actually very useful and gives a very neat trick for eliminating empty systems from Cubical Agda (this has not yet been implemented, but it is discussed here).

Using these two operations we can derive the heterogeneous composition

operation:

comp : ∀ {ℓ : I → Level} (A : ∀ i → Set (ℓ i)) {φ : I} (u : ∀ i → Partial φ (A i)) (u0 : A i0 [ φ ↦ u i0 ]) → A i1 comp A {φ = φ} u u0 = hcomp (λ i → λ { (φ = i1) → transp (λ j → A (i ∨ j)) i (u _ 1=1) }) (transp A i0 (ouc u0))

This decomposition of the Kan operations into transport and homogeneous composition seems crucial to get HITs to work properly in cubical type theory and in fact redtt is also using a similar decomposition of their Kan operations.

We can also derive both homogeneous and heterogeneous Kan filling using `hcomp`

and `comp`

with connections:

hfill : ∀ {ℓ} {A : Set ℓ} {φ : I} (u : ∀ i → Partial φ A) (u0 : A [ φ ↦ u i0 ]) (i : I) → A hfill {φ = φ} u u0 i = hcomp (λ j → λ { (φ = i1) → u (i ∧ j) 1=1 ; (i = i0) → ouc u0 }) (ouc u0) fill : ∀ {ℓ : I → Level} (A : ∀ i → Set (ℓ i)) {φ : I} (u : ∀ i → Partial φ (A i)) (u0 : A i0 [ φ ↦ u i0 ]) (i : I) → A i fill A {φ = φ} u u0 i = comp (λ j → A (i ∧ j)) (λ j → λ { (φ = i1) → u (i ∧ j) 1=1 ; (i = i0) → ouc u0 }) (inc {φ = φ ∨ (~ i)} (ouc {φ = φ} u0))

For historical reasons we are also exposing the Kan composition operation of CCHM:

compCCHM : ∀ {ℓ} (A : (i : I) → Set ℓ) (φ : I) (u : ∀ i → Partial (A i) φ) (u0 : A i0 [ φ ↦ u i0 ]) → A i1

However this is **not** recommended to use for various reasons. First of all it doesn’t work with HITs and second it produces a lot of empty systems (which anyone who tried cubicaltt can confirm). So using the `hcomp`

and `transp`

primitives has proved a lot better for practical formalization.

Using these operations we can do all of the standard cubical stuff, like composing paths and defining `J`

with its computation rule (up to a Path):

compPath : ∀ {ℓ} {A : Set ℓ} {x y z : A} → x ≡ y → y ≡ z → x ≡ z compPath {x = x} p q i = hcomp (λ j → \ { (i = i0) → x ; (i = i1) → q j }) (p i) module _ {ℓ ℓ'} {A : Set ℓ} {x : A} (P : ∀ y → x ≡ y → Set ℓ') (d : P x refl) where J : {y : A} → (p : x ≡ y) → P y p J p = transp (λ i → P (p i) (λ j → p (i ∧ j))) i0 d JRefl : J refl ≡ d JRefl i = transp (λ _ → P x refl) i d

The use of a `module`

here is not crucial in any way, it’s just an Agda trick to make `J`

and `JRefl`

share some arguments.

The file `Cubical.Core.Glue`

defines fibers and equivalences (as they were originally defined by Voevodsky in his Foundations library, i.e. as maps with contractible fibers). Using this we export the Glue types of Cubical Agda which lets us extend a total type by a partial family of equivalent types:

Glue : ∀ {ℓ ℓ'} (A : Set ℓ) {φ : I} → (Te : Partial φ (Σ[ T ∈ Set ℓ' ] T ≃ A)) → Set ℓ'

This comes with introduction and elimination forms (`glue`

and `unglue`

). With this we formalize the proof of a variation of univalence following the proof in Section 7.2 of CCHM. The key observation is that `unglue`

is an equivalence:

unglueIsEquiv : ∀ {ℓ} (A : Set ℓ) (φ : I) (f : PartialP φ (λ o → Σ[ T ∈ Set ℓ ] T ≃ A)) → isEquiv {A = Glue A f} (unglue {φ = φ}) equiv-proof (unglueIsEquiv A φ f) = λ (b : A) → let u : I → Partial φ A u i = λ{ (φ = i1) → equivCtr (f 1=1 .snd) b .snd (~ i) } ctr : fiber (unglue {φ = φ}) b ctr = ( glue (λ { (φ = i1) → equivCtr (f 1=1 .snd) b .fst }) (hcomp u b) , λ j → hfill u (inc b) (~ j)) in ( ctr , λ (v : fiber (unglue {φ = φ}) b) i → let u' : I → Partial (φ ∨ ~ i ∨ i) A u' j = λ { (φ = i1) → equivCtrPath (f 1=1 .snd) b v i .snd (~ j) ; (i = i0) → hfill u (inc b) j ; (i = i1) → v .snd (~ j) } in ( glue (λ { (φ = i1) → equivCtrPath (f 1=1 .snd) b v i .fst }) (hcomp u' b) , λ j → hfill u' (inc b) (~ j)))

The details of this proof is best studied interactively in Agda and by first understanding the proof in CCHM. The reason this is a crucial observation is that it says that any partial family of equivalences can be extended to a total one from `Glue [ φ ↦ (T,f) ] A`

to `A`

:

unglueEquiv : ∀ {ℓ} (A : Set ℓ) (φ : I) (f : PartialP φ (λ o → Σ[ T ∈ Set ℓ ] T ≃ A)) → (Glue A f) ≃ A unglueEquiv A φ f = ( unglue {φ = φ} , unglueIsEquiv A φ f )

and this is exactly what we need to prove the following formulation of the univalence theorem:

EquivContr : ∀ {ℓ} (A : Set ℓ) → isContr (Σ[ T ∈ Set ℓ ] T ≃ A) EquivContr {ℓ} A = ( ( A , idEquiv A) , λ w i → let f : PartialP (~ i ∨ i) (λ x → Σ[ T ∈ Set ℓ ] T ≃ A) f = λ { (i = i0) → ( A , idEquiv A ) ; (i = i1) → w } in ( Glue A f , unglueEquiv A (~ i ∨ i) f) )

This formulation of univalence was proposed by Martín Escardó in (see also Theorem 5.8.4 of the HoTT Book):

https://groups.google.com/forum/#!msg/homotopytypetheory/HfCB_b-PNEU/Ibb48LvUMeUJ

We have also formalized a quite slick proof of the standard formulation of univalence from `EquivContr`

(see `Cubical.Basics.Univalence`

). This proof uses that `EquivContr`

is contractibility of singletons for equivalences, which combined with `subst`

can be used to prove equivalence induction:

contrSinglEquiv : ∀ {ℓ} {A B : Set ℓ} (e : A ≃ B) → (B , idEquiv B) ≡ (A , e) contrSinglEquiv {A = A} {B = B} e = isContr→isProp (EquivContr B) (B , idEquiv B) (A , e) EquivJ : ∀ {ℓ ℓ′} (P : (A B : Set ℓ) → (e : B ≃ A) → Set ℓ′) (r : (A : Set ℓ) → P A A (idEquiv A)) (A B : Set ℓ) (e : B ≃ A) → P A B e EquivJ P r A B e = subst (λ x → P A (x .fst) (x .snd)) (contrSinglEquiv e) (r A)

We then use that the `Glue`

types also gives a map `ua`

which maps the identity equivalence to `refl`

:

ua : ∀ {ℓ} {A B : Set ℓ} → A ≃ B → A ≡ B ua {A = A} {B = B} e i = Glue B (λ { (i = i0) → (A , e) ; (i = i1) → (B , idEquiv B) }) uaIdEquiv : ∀ {ℓ} {A : Set ℓ} → ua (idEquiv A) ≡ refl uaIdEquiv {A = A} i j = Glue A {φ = i ∨ ~ j ∨ j} (λ _ → A , idEquiv A)

Now, given any function `au : ∀ {ℓ} {A B : Set ℓ} → A ≡ B → A ≃ B`

satisfying `auid : ∀ {ℓ} {A B : Set ℓ} → au refl ≡ idEquiv A`

we directly get that this is an equivalence using the fact that any isomorphism is an equivalence:

module Univalence (au : ∀ {ℓ} {A B : Set ℓ} → A ≡ B → A ≃ B) (auid : ∀ {ℓ} {A B : Set ℓ} → au refl ≡ idEquiv A) where thm : ∀ {ℓ} {A B : Set ℓ} → isEquiv au thm {A = A} {B = B} = isoToIsEquiv {B = A ≃ B} au ua (EquivJ (λ _ _ e → au (ua e) ≡ e) (λ X → compPath (cong au uaIdEquiv) (auid {B = B})) _ _) (J (λ X p → ua (au p) ≡ p) (compPath (cong ua (auid {B = B})) uaIdEquiv))

We can then instantiate this with for example the `au`

map defined using `J`

(which is how Vladimir originally stated the univalence axiom):

eqweqmap : ∀ {ℓ} {A B : Set ℓ} → A ≡ B → A ≃ B eqweqmap {A = A} e = J (λ X _ → A ≃ X) (idEquiv A) e eqweqmapid : ∀ {ℓ} {A : Set ℓ} → eqweqmap refl ≡ idEquiv A eqweqmapid {A = A} = JRefl (λ X _ → A ≃ X) (idEquiv A) univalenceStatement : ∀ {ℓ} {A B : Set ℓ} → isEquiv (eqweqmap {ℓ} {A} {B}) univalenceStatement = Univalence.thm eqweqmap eqweqmapid

Note that `eqweqmapid`

is not proved by `refl`

, instead we need to use the fact that the computation rule for `J`

holds up to a Path. Furthermore, I would like to emphasize that there is no problem with using `J`

for Path’s and that the fact that the computation rule doesn’t hold definitionally is almost never a problem for practical formalization as one rarely use it as it is often more natural to just use the cubical primitives. However, in Section 9.1 of CCHM we solve this by defining cubical identity types satisfying the computation rule definitionally (following a trick of Andrew Swan).

The idea behind the cubical identity types is that an element of an identity type is a pair of a path and a formula which tells us where this path is constant, so for example reflexivity is just the constant path together with the fact that it is constant everywhere (note that the interval variable comes before the path as the path depends on it):

refl : ∀ {ℓ} {A : Set ℓ} {x : A} → Id x x refl {x = x} = ⟨ i1 , (λ _ → x) ⟩

These types also come with an eliminator from which we can prove `J`

such that it is the identity function on refl, i.e. where the computation rule holds definitionally (for details see the Agda code in `Cubical.Core.Id`

). We then prove that `Path`

and `Id`

are equivalent types and develop the theory that we have for `Path`

for `Id`

as well, in particular we prove the univalence theorem expressed with `Id`

everywhere (the usual formulation can be found in `Cubical.Basics.UnivalenceId`

).

Note that the cubical identity types are not an inductive family like in HoTT which means that we cannot use Agda’s pattern-matching to match on them. Furthermore Cubical Agda doesn’t support inductive families yet, but it should be possible to adapt the techniques of Cavallo/Harper presented in

Higher Inductive Types in Cubical Computational Type Theory

in order to extend it with inductive families. The traditional identity types could then be defined as in HoTT and pattern-matching should work as expected.

The core library only contains one HIT: propositional truncation (`Cubical.Core.PropositionalTruncation`

). As Cubical Agda has native support for user defined HITs this is very convenient to define:

data ∥_∥ {ℓ} (A : Set ℓ) : Set ℓ where ∣_∣ : A → ∥ A ∥ squash : ∀ (x y : ∥ A ∥) → x ≡ y

We can then prove the recursor (and eliminator) using pattern-matching:

recPropTrunc : ∀ {ℓ} {A : Set ℓ} {P : Set ℓ} → isProp P → (A → P) → ∥ A ∥ → P recPropTrunc Pprop f ∣ x ∣ = f x recPropTrunc Pprop f (squash x y i) = Pprop (recPropTrunc Pprop f x) (recPropTrunc Pprop f y) i

However I would not only use `recPropTrunc`

explicitly as we can just use pattern-matching to define functions out of HITs. Note that the cubical machinery makes it possible for us to define these pattern-matching equations in a very nice way without any `ap`

‘s. This is one of the main reasons why I find it a lot more natural to work with HITs in cubical type theory than in Book HoTT: the higher constructors of HITs construct actual elements of the HIT, not of its identity type!

This is just a short example of what can be done with HITs in Cubical Agda, I plan to write more about this in a future post, but for now one can look at the folder `Cubical/HITs`

for many more examples (S¹, S², S³, torus, suspension, pushouts, interval, join, smash products…).

By combining everything I have said so far we have written the file `Cubical.Core.HoTT-UF`

which exports the primitives of HoTT/UF defined using cubical machinery under the hood:

open import Cubical.Core.Id public using ( _≡_ -- The identity type. ; refl -- Unfortunately, pattern matching on refl is not available. ; J -- Until it is, you have to use the induction principle J. ; transport -- As in the HoTT Book. ; ap ; _∙_ ; _⁻¹ ; _≡⟨_⟩_ -- Standard equational reasoning. ; _∎ ; funExt -- Function extensionality -- (can also be derived from univalence). ; Σ -- Sum type. Needed to define contractible types, equivalences ; _,_ -- and univalence. ; pr₁ -- The eta rule is available. ; pr₂ ; isProp -- The usual notions of proposition, contractible type, set. ; isContr ; isSet ; isEquiv -- A map with contractible fibers -- (Voevodsky's version of the notion). ; _≃_ -- The type of equivalences between two given types. ; EquivContr -- A formulation of univalence. ; ∥_∥ -- Propositional truncation. ; ∣_∣ -- Map into the propositional truncation. ; ∥∥-isProp -- A truncated type is a proposition. ; ∥∥-recursion -- Non-dependent elimination. ; ∥∥-induction -- Dependent elimination. )

The idea is that if someone has some code written using HoTT/UF axioms in Agda they can just import this file and everything should compute properly. The only downside is that one has to rewrite all pattern-matches on `Id`

to explicit uses of `J`

, but if someone is willing to do this and have some cool examples that now compute please let me know!

That’s all I had to say about the library for now. Pull-requests and feedback on how to improve it are very welcome! Please use the Github page for the library for comments and issues:

https://github.com/agda/cubical/issues

If you find some bugs in Cubical Agda you can use the Github page of Agda to report them (just check that no-one has already reported the bug):

]]>

Categorically, a (higher) inductive type is an initial object in some category. For instance, the coproduct of and is the initial object of the category of types equipped with maps and ; and the circle is the initial object of the category of types equipped with a point and an equality . A (H)IT is therefore a kind of “colimity” thing, while an “impredicative encoding” of it is a way to construct it (or an approximation thereof) using *limits* instead — specifically, *large* limits, which requires a universe closed under impredicative quantification (i.e. -types whose domain is not necessarily an element of the universe).

The most basic such encodings (usually associated with System F) approximate the initial object of a category by *the product of all objects of that category*. For instance, the System F coproduct is the product of all types equipped with maps and , which in type-theoretic syntax becomes

Such impredicative encodings of ordinary inductive types are well-known in type theory, and back when we were first discovering HITs I blogged here about the fact that they can also be encoded impredicatively. However, these basic encodings have the problem that they don’t satisfy the “uniqueness principle” or -conversion, and (equivalently) they don’t support a “dependent eliminator” or “induction principle”, only the non-dependent “recursion principle”. In categorical language, the *product* of all objects of a category, even if it exists, is only a weak initial object.

Last year, Sam Speight blogged here about a way to fix this problem (paper here with Awodey and Frey), by defining a (higher) inductive type to be the *limit of the identity functor* of the category in question, and appealing to this theorem. Such a limit, if constructed out of products and equalizers, appears as a subobject of the product of all objects; and if we “compile out” this definition in type theory, it adds additional assertions that System F encoding data is *natural*. For instance, the coproduct becomes

This approach is very nice, but unfortunately it only works for h-sets, i.e. 0-types. That is, given two sets , it produces a coproduct set , which has a dependent induction principle that can only eliminate into other sets. Categorically, the point is that the construction of limits out of products and equalizers works in a 1-category, but not in a higher category. We can boost up the dimension one at a time by adding additional coherence conditions — the paper ends with an example of constructed as a 1-type with a dependent induction principle that can eliminate into other 1-types (but not higher types) — but this approach offers no hope of an induction principle into types that are not -truncated for any . If we could solve the “problem of infinite objects” (perhaps by working in a context like two-level type theory) maybe we could add “all the coherence conditions at once”, although the path algebra would probably get quite hairy.

Surprisingly (to me), it turns out that there is a different solution, which works in (impredicative) Book HoTT without any bells or whistles. Recall that theorem about initial objects as limits of identity functors, and note that it’s proven using this lemma, which says that if is an object of a category equipped with a natural transformation from the constant functor to the identity functor, i.e. a cone consisting of maps for all objects such that for all morphisms , and moreover is the identity morphism, then is initial. Can we use this lemma directly?

You might think this is no better, since even obtaining a fully-coherent -natural transformation already involves infinitely many coherence conditions. However, inspecting the *proof* of this lemma, we see that it will work in HoTT even for an “incoherent” natural transformation, essentially because the definition of contractibility is a propositions-as-types translation of being a singleton set. That is, to show that is initial in , we want to show that is contractible. We take its center to be , and then we must show that any is equal to . But by incoherent naturality, we have , which is equal to since .

This is great, because the 0-type version of the Awodey-Frey-Speight construction, if written down with the full universe in place of , already comes with an incoherent cone over the identity functor. So “all” we need to do is ensure . (Note that this is a version of for an inductive type.)

Here’s the trick. Note that the proof of the lemma shows is initial by applying the naturality property in a case where one of the objects is itself. Let’s try to prove is the identity by applying that same naturality property in the case where the *morphism* is itself. This gives us . In other words, although may not (yet) be the identity, it’s already the next best thing: an *idempotent*. And in the words of Robinson and Rosolini,

No category theorist can see an idempotent without feeling the urge to split it.

This is especially true when we were hoping that that idempotent would turn out to be an identity, since splitting it is a way to “make” it an identity. And in fact it’s not hard to show with categorical algebra that if and are a splitting of (so that and ), where is a cone over the identity functor, then is initial. For we have another cone , whose -component is . And we have , using naturality and the splitting equations, so , so the lemma applies. Note that this argument also uses no higher coherence, and so should work just fine for an incoherent natural transformation.

What’s left is to split the idempotent in type theory. Fortunately, I wrote a paper a few years ago (original blog posts here and here) about precisely this problem, inspired by analogous results of Lurie in higher category theory. It turns out that an arbitrary “incoherent idempotent” (a map equipped with an equality ) may not be splittable, but as soon as the “witness of idempotency” satisfies *one* additional coherence condition (not the infinite tower of such one might expect), the map can be split. And in our situation, we can obtain this one additional coherence condition for the naturality triangle by using the 1-type version of the Awodey-Frey-Speight construction. (Actually, we can even omit their unit condition; all we need is the composition coherence for pseudonaturality.)

I’ve verified in Coq that this works for coproducts, using `type-in-type` for impredicativity. (I don’t think Coq’s built-in `impredicative-set` option is compatible with the HoTT library, which has tried to excise Coq’s built-in smallest universe `Set` as much as possible.) Most of the proof is quite easy; the longest part (40 lines of path algebra) is deducing the idempotence coherence condition from the naturality coherence condition. As expected, we only get typal computation rules for the induction principle — although we do have definitional computation rules for the *recursion* principle (i.e. the non-dependent eliminator). More precisely, there is *a* non-dependent eliminator (a special one, not just the dependent eliminator specialized to a non-dependent motive) that satisfies a definitional computation rule.

I’m working on coding it up for higher inductive types as well, but the path algebra gets quite annoying. Further bulletins as events warrant.

To conclude, let me point out that I find this a very satisfying answer to the question with which I ended my second idempotents post:

… [For equivalences] we also have a “fully coherent” notion … that is a retract of a type of “partially coherent” objects…. Are there any other structures that behave like this? Are there any other “fully coherent” gadgets that we can obtain by splitting an idempotent on a type of partially-coherent ones?

The answer is yes: a fully-coherent impredicative encoding can be obtained by splitting an idempotent on a partially-coherent one.

]]>Urs Schreiber’s problems were all about formalizing results in higher differential geometry, that make also sense in the quite abstract setting of differential cohesive toposes and cohesive toposes.

A differential cohesive topos is a topos with some extra structure given by three monads and three comonads with some nice properties and adjunctions between them. There is some work concerned with having this structure in homotopy type theory. A specialized cohesive homotopy type theory concerned with three of the six (co-)monads, called real-cohesive homotopy type theory was introduced by Mike Shulman.

What I want to sketch here today is concerned only with one of the monads of differential cohesion. I will call this monad coreduction and denote it with . By the axioms of differential cohesion, it has a left and a right adjoint and is idempotent. These properties are more than enough to model a monadic modality in homotopy type theory. Monadic modalities were already defined at the end of section 7 in the HoTT-Book and named just “modalities” and it is possible to have a homotopy type theory with a monadic modality just by adding some axioms — which is known not to work for non-trivial *comonadic* modalities.

So let us assume that is a monadic modality in HoTT. That means that we have a map and a *unit*

such that a property holds, that I won’t really go into in this post — but here it is for completeness: For any dependent type on some type , such that the unit maps are equivalences for all , the map

is an equivalence. So the inverse to this map is an induction principle, that only holds for dependent types subject to the condition above.

The n-truncations and double negation are examples of monadic modalities.

At this point (or earlier), one might ask: “Where is the differential geometry”? The answer is that in this setting, all types carry differential geometric structure that is accessible via and . This makes sense if we think of some very special interpretations of and (and HoTT), where the unit is given as the quotient map from a space to its quotient by a relation that identifies *infinitesimally close* points in .

Since we have this abstract monadic modality, we can turn this around and define the notion of two points being *infinitesimally close*, denoted “” in terms of the units:

where “” denotes the identity type (of in this case). The collection of all points y in a type X that are infinitesimally close to a fixed x in X, is called the *formal disk* at x. Let us denote it with :

Using some basic properties of monadic modalities, one can show, that any map preserves inifinitesimal closeness, i.e.

is inhabited. For any x in A, we can use this to get a map

which behaves a lot like the differential of a smooth function. For example, the chain rule holds

and if f is an equivalence, all induced are also equivalences. The latter corresponds to the fact that the differential of a diffeomorphism is invertible.

If we have a 0-group G with unit e, the left tranlations are a family of equivalences that consistently identify with all other formal disks in G given by the differentials .

This is essentially a generalization of the fact, that the tangent bundle of a Lie-group is trivialized by left translations and a solution to the first part of the first of Urs Schreiber’s problems I mentioned in the beginning.

With the exception of the chain rule, all of this was in my dissertation, which I defended in 2017. A couple of month ago, I wrote an article about this and put it on the arxiv and since monday, there is an improved version with an introduction that explains what *monads* you can think of and relates the setup to Synthetic Differential Geometry.

There is also a recording on youtube of a talk I gave about this in Bonn.

**International Conference on Homotopy Type Theory
(HoTT 2019)**

Carnegie Mellon University

12 – 17 August 2019

There will also be an associated:

**HoTT Summer School**

7 – 10 August 2019

More details to follow soon!

]]>Unfortunately, Wikispaces is closing, so the UF-IAS-2012 wiki will no longer be accessible there. With the help of Richard Williamson, we have migrated all of its content to a new archival copy hosted on the nLab server:

Let us know if you find any formatting or other problems.

]]>For some time I was a bit upset about this. But maybe this is our fault, by often trying to explain univalence only imprecisely, mixing the explanation of the models with the explanation of the underlying Martin-Löf type theory, with none of the two explained sufficiently precisely.

There are long, precise explanations such as the HoTT book, for example, or the various formalizations in Coq, Agda and Lean.

But perhaps we don’t have publicly available material with a self-contained, brief and complete formulation of univalence, so that interested mathematicians and logicians can try to contemplate the axiom in a fully defined form.

So here is an attempt of a self-contained, brief and complete formulation of Voevodsky’s Univalence Axiom in the arxiv.

This has an Agda file with univalence defined from scratch as an ancillary file, without the use of any library at all, to try to show what the length of a self-contained definition of the univalence type is. Perhaps somebody should add a Coq “version from scratch” of this.

There is also a web version UnivalenceFromScratch to try to make this as accessible as possible, with the text and the Agda code together.

The above notes explain the univalence axiom only. Regarding its role, we recommend Dan Grayson’s introduction to univalent foundations for mathematicians.

]]>]]>We are pleased to announce the AMS Special Session on Homotopy Type Theory, to be held on January 11, 2018 in San Diego, California, as part of the Joint Mathematics Meetings (to be held January 10 – 13).

Homotopy Type Theory (HoTT) is a new field of study that relates constructive type theory to abstract homotopy theory. Types are regarded as synthetic spaces of arbitrary dimension and type equality as homotopy equivalence. Experience has shown that HoTT is able to represent many mathematical objects of independent interest in a direct and natural way. Its foundations in constructive type theory permit the statement and proof of theorems about these objects within HoTT itself, enabling formalization in proof assistants and providing a constructive foundation for other branches of mathematics.

This Special Session is affiliated with the AMS Mathematics Research Communities (MRC) workshop for early-career researchers in Homotopy Type Theory organized by Dan Christensen, Chris Kapulkin, Dan Licata, Emily Riehl and Mike Shulman, which took place last June.

The Special Session will include talks by MRC participants, as well as by senior researchers in the field, on various aspects of higher-dimensional type theory including categorical semantics, computation, and the formalization of mathematical theories. There will also be a panel discussion featuring distinguished experts from the field.

Further information about the Special Session, including a schedule and abstracts, can be found at: http://jointmathematicsmeetings.org/meetings/national/jmm2018/2197_program_ss14.html.

Please note that the early registration deadline is December 20, 2017.If you have any questions about about the Special Session, please feel free to contact one of the organizers. We look forward to seeing you in San Diego.

Simon Cho (University of Michigan)

Liron Cohen (Cornell University)

Ed Morehouse (Wesleyan University)

Known impredicative encodings of various inductive types in System F, such as the type

of natural numbers do not satisfy the relevant -computation rules. The aim of this work is to refine the System F encodings by moving to a system of HoTT with an impredicative universe, so that the relevant -rules are satisfied (along with all the other rules). As a result, the so-determined types have their expected universal properties. The main result is the construction of a type of natural numbers which is the initial algebra for the expected endofunctor .

For the inductive types treated in the thesis, we do not use the full power of HoTT; we need only postulate -types, identity types, “large” -types over an impredicative universe and function extensionality. Having large -types over an impredicative universe means that given a type and a type family , we may form the dependent function type

Note that this type is in even if is not.

We obtain a translation of System F types into type theory by replacing second order quantification by dependent products over (or alternatively over the subtype of given by some h-level).

For brevity, we will focus on the construction of the natural numbers (though in the thesis, the coproduct of sets and the unit type is first treated with special cases of this method). We consider categories of algebras for endofunctors:

where the type of objects of is given by

(the type of sets (in )) and morphisms are simply functions between sets.

We can write down the type of -algebras:

and homomorphisms between algebras and :

which together form the category .

We seek the initial object in . Denote this by and moreover let be the forgetful functor to and be the covariant Yoneda embedding. We reason as follows:

using the fact that the diagonal functor is left adjoint to the limit functor for the last step. With this, we have a proposal for the definition of the underlying set of the initial -algebra as the limit of the forgetful functor. Using the fact that is defined as a limit, we obtain an algebra structure . As creates limits, is guaranteed to be initial in .

But we want to define in type theory. We do this using products and equalizers as is well known from category theory. Explicitly, we take the equalizer of the following two maps between products:

given by:

The equalizer is, of course:

which inhabits . Impredicativity is crucial for this: it guarantees that the product over lands in .

This method can be used to construct an initial algebra, and therefore a fixed-point, for *any* endofunctor ! We won’t pursue this remarkable fact here, but only consider the case at hand, where the functor is . Then the equalizer becomes our definition of the type of natural numbers (so let us rename to for the remainder). Observe that this encoding can be seen as a subtype of (a translation of) the System F encoding given at the start. Indeed, the indexing object of is equivalent to , by

With this, we can define a successor function and zero element, for instance:

(the successor function takes a little more work). We can also define a recursor , given any and . In other words, the introduction rules hold, and we can eliminate *into other sets*. Further, the -rules hold definitionally – as expected, since they hold for the System F encodings.

Finally we come to the desired result, the -rule for :

**Theorem. **Let and . Moreover, let such that:

for any . Then

Note that the -rule holds *propositionally. *By Awodey, Gambino, and Sojakova we therefore also have, equivalently, the induction principle for , aka the dependent elimination rule. As a corollary, we can prove the universal property that any -algebra homomorphism is propositionally equal to the appropriate recursor (as a -algebra homomorphism). Again we emphasise the need for impredicativity: in the proof of , we have to be able to plug into quantifiers over .

A semantic rendering of the above is that we have built a type that always determines a natural numbers object—whereas the System F encoding need not always do so (see Rummelhoff). In an appendix, we discuss a realizability semantics for the system we work in. Building more exotic types (that need not be sets) becomes more complicated; we leave this to future work.

]]>https://github.com/mortberg/cubicaltt/tree/master/lectures

The lectures cover the main features of the system and don’t assume any prior knowledge of Homotopy Type Theory or Univalent Foundations. Only basic familiarity with type theory and proof assistants based on type theory is assumed. The lectures are in the form of cubicaltt files and can be loaded in the cubicaltt proof assistant.

cubicaltt is based on a novel type theory called Cubical Type Theory that provides new ways to reason about equality. Most notably it makes various extensionality principles, like function extensionality and Voevodsky’s univalence axiom, into theorems instead of axioms. This is done such that these principles have computational content and in particular that we can transport structures between equivalent types and that these transports compute. This is different from when one postulates the univalence axiom in a proof assistant like Coq or Agda. If one just adds an axiom there is no way for Coq or Agda to know how it should compute and one looses the good computational properties of type theory. In particular canonicity no longer holds and one can produce terms that are stuck (e.g. booleans that are neither true nor false but don’t reduce further). In other words this is like having a programming language in which one doesn’t know how to run the programs. So cubicaltt provides an operational semantics for Homotopy Type Theory and Univalent Foundations by giving a computational justification for the univalence axiom and (some) higher inductive types.

Cubical Type Theory has a model in cubical sets with lots of structure (symmetries, connections, diagonals) and is hence consistent. Furthermore, Simon Huber has proved that Cubical Type Theory satisfies canonicity for natural numbers which gives a syntactic proof of consistency. Many of the features of the type theory are very inspired by the model, but for more syntactically minded people I believe that it is definitely possible to use cubicaltt without knowing anything about the model. The lecture notes are hence written with almost no references to the model.

The cubicaltt system is based on Mini-TT:

"A simple type-theoretic language: Mini-TT" (2009) Thierry Coquand, Yoshiki Kinoshita, Bengt Nordström and Makoto Takeya In "From Semantics to Computer Science; Essays in Honour of Gilles Kahn"

Mini-TT is a variant Martin-Löf type theory with datatypes and cubicaltt extends Mini-TT with:

- Path types
- Compositions
- Glue types
- Id types
- Some higher inductive types

The lectures cover the first 3 of these and hence correspond to sections 2-7 of:

"Cubical Type Theory: a constructive interpretation of the univalence axiom" Cyril Cohen, Thierry Coquand, Simon Huber and Anders Mörtberg To appear in post-proceedings of TYPES 2016 https://arxiv.org/abs/1611.02108

I should say that cubicaltt is mainly meant to be a prototype implementation of Cubical Type Theory in which we can do experiments, however it was never our goal to implement a competitor to any of the more established proof assistants. Because of this there are no implicit arguments, type classes, proper universe management, termination checker, etc… Proofs in cubicaltt hence tend to get quite verbose, but it is definitely possible to do some fun things. See for example:

- binnat.ctt – Binary natural numbers and isomorphism to unary numbers. Example of data and program refinement by doing a proof for unary numbers by computation with binary numbers.
- setquot.ctt – Formalization of impredicative set quotients á la Voevodsky.
- hz.ctt – defined as an (impredicative set) quotient of
`nat * nat`

. - category.ctt – Categories. Structure identity principle. Pullbacks. (Due to Rafaël Bocquet)
- csystem.ctt – Definition of C-systems and universe categories. Construction of a C-system from a universe category. (Due to Rafaël Bocquet)

For a complete list of all the examples see:

https://github.com/mortberg/cubicaltt/tree/master/examples

For those who cannot live without implicit arguments and other features of modern proof assistants there is now an experimental cubical mode shipped with the master branch of Agda. For installation instructions and examples see:

https://agda.readthedocs.io/en/latest/language/cubical.html

https://github.com/Saizan/cubical-demo

In this post I will give some examples of the main features of cubicaltt, but for a more comprehensive introduction see the lecture notes. As cubicaltt is an experimental prototype things can (and probably will) change in the future (e.g. see the paragraph on HITs below).

The basic type theory on which cubicaltt is based has Π and ∑ types (with eta and surjective pairing), a universe `U`

, datatypes, recursive definitions and mutually recursive definitions (in particular inductive-recursive definitions). Note that general datatypes and (mutually recursive) definitions are not part of the version of Cubical Type Theory in the paper.

Below is an example of how natural numbers and addition are defined:

data nat = zero | suc (n : nat) add (m : nat) : nat -> nat = split zero -> m suc n -> suc (add m n)

If one loads this in the cubicaltt read-eval-print-loop one can compute things:

> add (suc zero) (suc zero) EVAL: suc (suc zero)

The homotopical interpretation of equality tells us that we can think of an equality proof between a and b in a type A as a path between a and b in a space A. cubicaltt takes this literally and adds a primitive Path type that should be thought of as a function out of an abstract interval with fixed endpoints.

We call the elements of the interval names/directions/dimensions and typically use i, j, k to denote them. The elements of the interval are generated by the following grammar (where dim is a dimension like i, j, k…):

r,s := 0 | 1 | dim | - r | r /\ s | r \/ s

The endpoints are `0`

and `1`

, – corresponds to symmetry (r in is mapped to `1-r`

), while `/\`

and `\/`

are so called “connections”. The connections can be thought of mapping r and s in to `min(r,s)`

and `max(r,s)`

respectively. As Path types behave like functions out of the interval there is both path abstraction and application (just like for function types). Reflexivity is written:

refl (A : U) (a : A) : Path A a a = <i> a

and corresponds to a constant path:

<i> a a -----------> a

with the intuition is that `<i> a`

is a function `\(i : ) -> a`

. However for deep reasons the interval isn’t a type (as it isn’t fibrant) so we cannot write functions out of it directly and hence we have this special notation for path abstraction.

If we have a path from a to b then we can compute its left end-point by applying it to `0`

:

face0 (A : U) (a b : A) (p : Path A a b) : A = p @ 0

This is of course convertible to `a`

. We can also reverse a path by using symmetry:

sym (A : U) (a b : A) (p : Path A a b) : Path A b a = <i> p @ -i

Assuming that some arguments could be made implicit this satisfies the equality

sym (sym p) == p

judgmentally. This is one of many examples of equalities that hold judgmentally in cubicaltt but not in standard type theory where sym would be defined by induction on p. This is useful for formalizing mathematics, for example we get the judgmental equality `C^op^op == C`

for a category `C`

that cannot be obtained in standard type theory with the usual definition of category without using any tricks (see opposite.ctt for a formal proof of this).

We can also directly define `cong`

(or `ap`

or `mapOnPath`

):

cong (A B : U) (f : A -> B) (a b : A) (p : Path A a b) : Path B (f a) (f b) = <i> f (p @ i)

Once again this satisfies some equations judgmentally that we don’t get in standard type theory where this would have been defined by induction on p:

cong id p == p cong g (cong f p) == cong (g o f) p

Finally the connections can be used to construct higher dimensional cubes from lower dimensional ones (e.g. squares from lines). If `p : Path A a b`

then ` <i j> p @ i /\ j`

is the interior of the square:

p a -----------------> b ^ ^ | | | | <j> a | | p | | | | | | a -----------------> a <i> a

Here i corresponds to the left-to-right dimension and j corresponds to the down-to-up dimension. To compute the left and right sides just plug in `i=0`

and `i=1`

in the term inside the square:

<j> p @ 0 /\ j = <j> p @ 0 = <j> a (p is a path from a to b) <j> p @ 1 /\ j = <j> p @ j = p (using eta for Path types)

These give a short proof of contractibility of singletons (i.e. that the type `(x : A) * Path A a x`

is contractible for all `a : A`

), for details see the lecture notes or the paper. Because connections allow us to build higher dimensional cubes from lower dimensional ones they are extremely useful for reasoning about higher dimensional equality proofs.

Another cool thing with Path types is that they allow us to give a direct proof of function extensionality by just swapping the path and lambda abstractions:

funExt (A B : U) (f g : A -> B) (p : (x : A) -> Path B (f x) (g x)) : Path (A -> B) f g = <i> \(a : A) -> (p a) @ i

To see that this makes sense we can compute the end-points:

`(<i> \(a : A) -> (p a) @ i) @ 0 = \(a : A) -> (p a) @ 0`

`= \(a : A) -> f a`

`= f`

and similarly for the right end-point. Note that the last equality follows from eta for Π types.

We have now seen that Path types allows us to define the constants of HoTT (like `cong`

or `funExt`

), but when doing proofs with Path types one rarely uses these constants explicitly. Instead one can directly prove things with the Path type primitives, for example the proof of function extensionality for dependent functions is exactly the same as the one for non-dependent functions above.

We cannot yet prove the principle of path induction (or `J`

) with what we have seen so far. In order to do this we need to be able to turn any path between types A and B into a function from A to B, in other words we need to be able to define `transport`

(or `cast`

or `coe`

):

transport : Path U A B -> A -> B

The computation rules for the transport operation in cubicaltt is introduced by recursion on the type one is transporting in. This is quite different from traditional type theory where the identity type is introduced as an inductive family with one constructor (`refl`

). A difficulty with this approach is that in order to be able to define transport in a Path type we need to keep track of the end-points of the Path type we are transporting in. To solve this we introduce a more general operation called composition.

Composition can be used to define the composition of paths (hence the name). Given paths `p : Path A a b`

and `q : Path A b c`

the composite is obtained by computing the missing top line of this open square:

a c ^ ^ | | | | <j> a | | q | | | | | | a ----------------> b p @ i

In the drawing I’m assuming that we have a direction `i : `

in context that goes left-to-right and that the j goes down-to-up (but it’s not in context, rather it’s implicitly bound by the comp operation). As we are constructing a Path from a to c we can use the i and put `p @ i`

as bottom. The code for this is as follows:

compPath (A : U) (a b c : A) (p : Path A a b) (q : Path A b c) : Path A a c = <i> comp (<_> A) (p @ i) [ (i = 0) -> <j> a , (i = 1) -> q ]

One way to summarize what compositions gives us is the so called “box principle” that says that “any open box has a lid”. Here “box” means (n+1)-dimensional cube and the lid is an n-dimensional cube. The comp operation takes as second argument the bottom of the box and then a list of sides. Note that the collection of sides doesn’t have to be exhaustive (as opposed to the original cubical set model) and one way to think about the sides is as a collection of constraints that the resulting lid has to satisfy. The first argument of comp is a path between types, in the above example this path is constant but it doesn’t have to be. This is what allows us to define transport:

transport (A B : U) (p : Path U A B) (a : A) : B = comp p a []

Combining this with the contractibility of singletons we can easily prove the elimination principle for Path types. However the computation rule does not hold judgmentally. This is often not too much of a problem in practice as the Path types satisfy various judgmental equalities that normal Id types don’t. Also, having the possibility to reason about higher equalities directly using path types and compositions is often very convenient and leads to very nice and new ways to construct proofs about higher equalities in a geometric way by directly reasoning about higher dimensional cubes.

The composition operations are related to the filling operations (as in Kan simplicial sets) in the sense that the filling operations takes an open box and computes a filler with the composition as one of its faces. One of the great things about cubical sets with connections is that we can reduce the filling of an open box to its composition. This is a difference compared to the original cubical set model and it provides a significant simplification as we only have to explain how to do compositions in open boxes and not also how to fill them.

The final main ingredient of cubicaltt are the Glue types. These are what allows us to have a direct algorithm for composition in the universe and to prove the univalence axiom. These types add the possibility to glue types along equivalences (i.e. maps with contractible fibers) onto another type. In particular this allows us to directly define one of the key ingredients of the univalence axiom:

ua (A B : U) (e : equiv A B) : Path U A B = <i> Glue B [ (i = 0) -> (A,e) , (i = 1) -> (B,idEquiv B) ]

This corresponds to the missing line at the top of:

A B | | e | | idEquiv B | | V V B --------> B B

The sides of this square are equivalences while the bottom and top are lines in direction i (so this produces a path from A to B as desired).

We have formalized three proofs of the univalence axiom in cubicaltt:

- A very direct proof due to Simon Huber and me using higher dimensional glueing.
- The more conceptual proof from section 7.2 of the paper in which we show that the
`unglue`

function is an equivalence (formalized by Fabian Ruch). - A proof from
`ua`

and its computation rule (`uabeta`

). Both of these constants are easy to define and are sufficient for the full univalence axiom as noted in a post by Dan Licata on the HoTT google group.

All of these proofs can be found in the file univalence.ctt and are explained in the paper (proofs 1 and 3 are in Appendix B).

Note that one often doesn’t need full univalence to do interesting things. So just like for Path types it’s often easier to just use the Glue primitives directly instead of invoking the full univalence axiom. For instance if we have proved that negation is an involution for bool we can directly get a non-trivial path from bool to bool using ua (which is just a Glue):

notEq : Path U bool bool = ua boob bool notEquiv

And we can use this non-trivial equality to transport true and compute the result:

> transport notEq true EVAL: false

This is all that the lectures cover, in the rest of this post I will discuss the two extensions of cubicaltt from the paper and their status in cubicaltt.

As pointed out above the computation rule for Path types doesn’t hold judgmentally. Luckily there is a neat trick due to Andrew Swan that allows us to define a new type that is equivalent to `Path A a b`

for which the computation rule holds judgmentally. For details see section 9.1 of the paper. We call this type `Id A a b`

as it corresponds to Martin-Löf’s identity type. We have implemented this in cubicaltt and proved the univalence axiom expressed exclusively using Id types, for details see idtypes.ctt.

For practical formalizations it is probably often more convenient to use the Path types directly as they have the nice primitives discussed above, but the fact that we can define Id types is very important from a theoretical point of view as it shows that cubicaltt with Id is really an extension of Martin-Löf type theory. Furthermore as we can prove univalence expressed using Id types we get that any proof in univalent type theory (MLTT extended with the univalence axiom) can be translated into cubicaltt.

The second extension to cubicaltt are HITs. We have a general syntax for adding these and some of them work fine on the master branch, see for example:

- circle.ctt – The circle as a HIT. Computation of winding numbers.
- helix.ctt – The loop space of the circle is equal to Z.
- susp.ctt – Suspension and n-spheres.
- torsor.ctt – Torsors. Proof that S1 is equal to BZ, the classifying

space of Z. (Due to Rafaël Bocquet) - torus.ctt – Proof that Torus = S1 * S1 in only 100 loc (due to Dan

Licata).

However there are various known issues with how the composition operations compute for recursive HITs (e.g. truncations) and HITs where the end-points contain function applications (e.g. pushouts). We have a very experimental branch that tries to resolve these issues called “hcomptrans”. This branch contains some new (currently undocumented) primitives that we are experimenting with and so far it seems like these are solving the various issues for the above two classes of more complicated HITs that don’t work on the master branch. So hopefully there will soon be a new cubical type theory with support for a large class of HITs.

That’s all I wanted to say about cubicaltt in this post. If someone plays around with the system and proves something cool don’t hesitate to file a pull request or file issues if you find some bugs.

]]>