08.09.2015 Views

Homotopy Type Theory For Dummies

1ER2Xug

1ER2Xug

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Homotopy</strong> <strong>Type</strong> <strong>Theory</strong><br />

<strong>For</strong> <strong>Dummies</strong><br />

Thorsten Altenkirch<br />

Functional Programming Laboratory<br />

School of Computer Science<br />

University of Nottingham<br />

October 30, 2013<br />

Thorsten Altenkirch (Nottingham) Edinburgh 13 October 30, 2013 1 / 29


Intro<br />

The HoTT book<br />

Outcome of the Special<br />

Year on <strong>Homotopy</strong> <strong>Type</strong><br />

<strong>Theory</strong> at Princeton.<br />

Proposes an extension of<br />

Martin-Löf <strong>Type</strong> <strong>Theory</strong><br />

as a new foundation of<br />

Mathematics.<br />

Informal use of <strong>Type</strong><br />

<strong>Theory</strong> to appeal to<br />

Mathematicians (but not<br />

only).<br />

Additional principles<br />

inspired by <strong>Homotopy</strong><br />

<strong>Theory</strong>.<br />

Thorsten Altenkirch (Nottingham) Edinburgh 13 October 30, 2013 2 / 29


Basic <strong>Type</strong> <strong>Theory</strong><br />

<strong>Type</strong> <strong>Theory</strong> 101<br />

Martin-Löf <strong>Type</strong> <strong>Theory</strong>: foundational system for<br />

constructive Mathematics<br />

Based on Curry-Howard equivalence<br />

proofs : proposition = programs : type<br />

E.g. as we recursively define the function (+) : N → N → N:<br />

0 + n :≡ n<br />

S(m) + n :≡ S(m + n)<br />

we recursively define the proof:<br />

assoc : Π i,j,k:N (i + j) + k = i + (j + k)<br />

assoc(0, j, k) :≡ refl(j + k)<br />

assoc(S(i), j, k) :≡ ap(S, assoc(i, j, k))<br />

Theorem proving becomes functional programming!<br />

Basis of a number of proofs assistants / programming languages :<br />

NuPRL, LEGO, Coq, Agda, Idris, . . .<br />

Thorsten Altenkirch (Nottingham) Edinburgh 13 October 30, 2013 3 / 29


Basic <strong>Type</strong> <strong>Theory</strong><br />

Proof-relevant mathematics<br />

The axiom of choice (AC ∞ ) in <strong>Type</strong> <strong>Theory</strong><br />

(given A, B : <strong>Type</strong>, R : A → B → <strong>Type</strong>):<br />

(Πa : A.Σb : B.R(a, b)) → (Σf : A → B.Πa : A.R(a, f (a)))<br />

AC ∞ is provable, the proof is given by<br />

ac f = (λa.fst(f (a)), λa.snd(f (a))<br />

where fst,snd are the projections associated with Σ.<br />

Proofs in <strong>Type</strong> <strong>Theory</strong> can contain information.<br />

We call a type A propositional (A : Prop), if it contains no<br />

information.<br />

A propositional version of the axiom AC −1 is not provable and<br />

implies excluded middle.<br />

Thorsten Altenkirch (Nottingham) Edinburgh 13 October 30, 2013 4 / 29


Identity types<br />

Identity types<br />

Given A : <strong>Type</strong> and a, b : A we can form<br />

a = A b : <strong>Type</strong><br />

the type of proofs that a is equal to b.<br />

The canonical inhabitant is<br />

refl(a) : a = A a<br />

given a : A.<br />

The eliminator for equality types is<br />

J(a) : Π P:Πb:A.a=b→<strong>Type</strong> P(a, refl(a)) → Π x:A,α:a=x P(x, α)<br />

for a : A, with the definitional equality J(P, p, refl(a)) ≡ p.<br />

Thorsten Altenkirch (Nottingham) Edinburgh 13 October 30, 2013 5 / 29


Identity types<br />

Groupoid structure<br />

Using the non-dependent version of J<br />

transport : Π a,b:A Π P:A→<strong>Type</strong> a = b → P(a) → P(b)<br />

we can show that = is an equivalence relation:<br />

α −1 : b = a<br />

for α : a = b<br />

α; β : a = c for α : a = b, β : b = c<br />

Using J we can also show:<br />

α, refl = α<br />

refl; α = α<br />

(α; β); γ = α; (β; γ)<br />

α; α −1 = refl<br />

α −1 ; α = refl<br />

That is = forms a groupoid.<br />

Thorsten Altenkirch (Nottingham) Edinburgh 13 October 30, 2013 6 / 29


Identity types<br />

Should equality be propositional?<br />

Should equality be propositional ? I.e. can we prove Uniqueness of<br />

equality proofs (UIP):<br />

Using J this is can be reduced to:<br />

Π a,b:A Π p,q:a=b q = p<br />

Π a:A Π p:a=a p = refl<br />

Hofmann and Streicher showed that UIP cannot be derrived from J<br />

using a groupoid model of <strong>Type</strong> <strong>Theory</strong>.<br />

More recently, Voevodsky observed that UIP is also refuted by a<br />

homotopy model of <strong>Type</strong> <strong>Theory</strong>.<br />

Basic idea:<br />

<strong>Type</strong>s topological spaces<br />

a : A points in the space<br />

a = A b paths between the points<br />

Thorsten Altenkirch (Nottingham) Edinburgh 13 October 30, 2013 7 / 29


Homotopic interpretation<br />

Homotopic Model<br />

A : <strong>Type</strong><br />

a, b : A<br />

p, q : a = b<br />

H : p = q<br />

Thorsten Altenkirch (Nottingham) Edinburgh 13 October 30, 2013 8 / 29


Homotopic interpretation<br />

Uniqueness of Identity proofs ?<br />

Π p:a=a p = refl ?<br />

Thorsten Altenkirch (Nottingham) Edinburgh 13 October 30, 2013 9 / 29


Homotopic interpretation<br />

Uniqueness of Identity proofs ?<br />

Okay, but what now?<br />

Thorsten Altenkirch (Nottingham) Edinburgh 13 October 30, 2013 10 / 29


Homotopic interpretation<br />

While we cannot show UIP<br />

We can show:<br />

Π p:a=a p = refl(a)<br />

Π p:a=a (a, p) = Σx:A x=a (a, refl(a))<br />

This follows from SCTR (singletons are contractible):<br />

assuming a : A.<br />

On the other hand<br />

Π (b,p):Σb:A,a=b (a, refl(a)) = (b, p)<br />

J(a) : Π P:Πb:A.a=b→<strong>Type</strong> P(a, refl(a)) → Π x:A,α:a=x P(x, α)<br />

can be derived from transport<br />

and SCTR.<br />

transport : Π a,b:A Π P:A→<strong>Type</strong> a = b → P(a) → P(b)<br />

Thorsten Altenkirch (Nottingham) Edinburgh 13 October 30, 2013 11 / 29


Homotopic interpretation<br />

J in the <strong>Homotopy</strong> interpretation<br />

To show<br />

Π p:a=a (a, p) = Σx:A x=a (a, refl(a))<br />

we use<br />

Π (b,p):Σb:A,a=b (a, refl(a)) = (b, p)<br />

Thorsten Altenkirch (Nottingham) Edinburgh 13 October 30, 2013 12 / 29


The univalence axiom<br />

Univalence<br />

Rejection of UIP is not the only thing the <strong>Homotopy</strong> interpretation is<br />

good for.<br />

It also suggests an additional principle: the univalence axiom.<br />

This axiom can also be justified from a purely logical perspective.<br />

And it is inconsistent with UIP!<br />

Thorsten Altenkirch (Nottingham) Edinburgh 13 October 30, 2013 13 / 29


The univalence axiom<br />

What is equality of functions ?<br />

Given f , g : A → B we define extensional equality :<br />

f ∼ g :≡ Π a:A f (a) = g(a)<br />

We can show<br />

app : f = g → f ∼ g<br />

Extensionality corresponds to requiring app to be an isomorphism.<br />

It’s inverse is functional extensionality.<br />

This can be justified by the black box view of functions.<br />

Thorsten Altenkirch (Nottingham) Edinburgh 13 October 30, 2013 14 / 29


The univalence axiom<br />

What is the equality of types?<br />

Given A, B : <strong>Type</strong> we define isomorphism A ∼ B as<br />

f : A → B<br />

g : B → A<br />

η : Π a:A a = g(f (a))<br />

ɛ : Π b:B b = f (g(b))<br />

In the absence of UIP we can require coherence properties which<br />

correspond to the triangle equalities of an adjunction:<br />

δ : Π a:A ap(f , η(a)) = ɛ(f (b))<br />

δ ′ : Π b:B η(g(b)) = ap(g, ɛ(n))<br />

where ap(f ) : Π a,a ′ :Aa = a ′ → f (a) = f (a ′ )<br />

We can derive δ from δ ′ and vice versa, because equality is a groupoid.<br />

We define equivalence A ≈ B as given by isomorphism and δ.<br />

Thorsten Altenkirch (Nottingham) Edinburgh 13 October 30, 2013 15 / 29


The univalence axiom<br />

What is the equality of types?<br />

We can show:<br />

coe : A = B → A ≈ B<br />

The univalence axiom sates that coe is an equivalence.<br />

This is justified by a black box view of types.<br />

Note that the univalence axiom implies functional extensionality.<br />

Thorsten Altenkirch (Nottingham) Edinburgh 13 October 30, 2013 16 / 29


Truncation levels<br />

Truncation levels<br />

In the absence of UIP we classify types according to the complexity of<br />

their equality types.<br />

We say a type A : <strong>Type</strong> is contractible or a -2-type, if<br />

is inhabited.<br />

Σ a:A Π x:A x = a<br />

A type A : <strong>Type</strong> is a n + 1-type, if all its equality types a = A a ′ for<br />

a, a ′ : A an n-types.<br />

To show that any n-<strong>Type</strong> is also a n + 1-type we need to show that if<br />

a type is contractible, then its equalities are contractible too.<br />

Thorsten Altenkirch (Nottingham) Edinburgh 13 October 30, 2013 17 / 29


Truncation levels<br />

A contractible → a = A a ′ contractible<br />

Assume that A is contractible, that means we have<br />

a 0 : A<br />

h : Π x:A x = a 0<br />

Now for any a, a ′ : A we have<br />

α 0 (a, a ′ ) : a = a ′<br />

α 0 (a, a ′ ) :≡ h(a); h(a ′ ) −1<br />

We need to show that<br />

Π a,a ′ :AΠ p:a=a ′p = α 0 (a, a ′ )<br />

Using J it is sufficient to show<br />

Π a:A refl(a) = α(a, a) ≡ h(a); h(a) −1<br />

Which is just one of the groupoid laws.<br />

Thorsten Altenkirch (Nottingham) Edinburgh 13 October 30, 2013 18 / 29


Truncation levels<br />

The Truncation Hierarchy<br />

level<br />

-2 contractible types<br />

-1 propositions The theorem we just proved<br />

implies that it is enough that<br />

Π a,a ′ :Aa = a ′ .<br />

0 sets UIP corresponds to the assumption<br />

that every type is a<br />

set.<br />

1 groupoids<br />

.<br />

.<br />

Thorsten Altenkirch (Nottingham) Edinburgh 13 October 30, 2013 19 / 29


Truncation levels<br />

Higher types<br />

How do we get types at higher levels?<br />

The 1st universe <strong>Type</strong> 0 cannot be a set.<br />

Consider Bool = Bool, using univalence there are two equivalences:<br />

id, and negation.<br />

However, id and negation cannot be equal.<br />

My student Nicolai Kraus proved that the nth universe is an cannot<br />

be an n-type.<br />

Thorsten Altenkirch (Nottingham) Edinburgh 13 October 30, 2013 20 / 29


HITs<br />

Higher inductive types<br />

There are other ways to obtain higher types in HoTT.<br />

A higher inductive type has not only constructors for elements but<br />

also for equalities.<br />

A simple example is S 1 : <strong>Type</strong><br />

base : S 1<br />

loop : base = base<br />

S 1 homotopically behaves like the circle.<br />

Indeed we can embedd i : Z into φ(i) : base = base:<br />

i<br />

↦→loop n<br />

0 ↦→refl<br />

− n<br />

↦→(loop −1 ) n<br />

Thorsten Altenkirch (Nottingham) Edinburgh 13 October 30, 2013 21 / 29


HITs<br />

Higher inductive types<br />

S 1 also comes with eliminators: just consider the non-dependent<br />

eliminator:<br />

satisfying the equalities<br />

Elim S1 : Π M:<strong>Type</strong> Π b:M (b = b) → S 1 → M<br />

Elim S1 (M, b, q, base) ≡ b<br />

ap(Elim S1 (M, b, q), loop) ≡ q<br />

Using univalence we can prove α : Z = Z using the equivalence<br />

(λn.n + 1, λn.n − 1, . . . ).<br />

We define a family:<br />

F : S 1 → <strong>Type</strong><br />

F = Elim S1 (<strong>Type</strong>, Z, α)<br />

Thorsten Altenkirch (Nottingham) Edinburgh 13 October 30, 2013 22 / 29


HITs<br />

Higher inductive types<br />

This allows us to define an inverse to φ: Given p : base = base we<br />

can construct<br />

transport(F , p)<br />

: F (base) → F (base)<br />

Note that F (base) ≡ Z. Hence we define:<br />

φ −1 (p) :≡ transport(F , p, 0) : Z<br />

Dan Licata showed how we can use the dependent eliminator to<br />

derive that φ, φ −1 are inverse and hence:<br />

(base = base) = Z<br />

Thorsten Altenkirch (Nottingham) Edinburgh 13 October 30, 2013 23 / 29


HITs<br />

The sphere<br />

The circle S 1 is 1-type (groupoid), all higher equalities are<br />

propositional.<br />

However, the situation is different for the sphere S 2 : <strong>Type</strong> which can<br />

be defined as a HIT:<br />

base : S 2<br />

loop : refl(base) = refl(base)<br />

None of the higher equalities of S 2 are propositional.<br />

Hence S 2 has no finite truncation level.<br />

Thorsten Altenkirch (Nottingham) Edinburgh 13 October 30, 2013 24 / 29


HITs<br />

Truncations<br />

We can use HITs to define truncations, which is the adjoint to the<br />

embedding.<br />

E.g. given A : <strong>Type</strong> the -1-truncation ||A|| −1 : <strong>Type</strong> (also called<br />

bracket types, squash types) is given by<br />

Clearly, ||A|| −1 : Prop and<br />

for P : Prop.<br />

We can use this to define AC −1 :<br />

η : A → ||A|| −1<br />

uip : Π a,a ′ :||A|| −1<br />

a = a ′<br />

A → P = ||A|| −1 → P<br />

(Πa : A.||Σb : B.R(a, b)|| −1 ) → (||Σf : A → B.Πa : A.R(a, f (a))|| −1 )<br />

AC −1 implies excluded middle for Prop, i.e. P + ¬P for P : Prop<br />

(Diaconescu’s construction).<br />

We can generalize this to arbitrary levels ||A|| n is an n-type.<br />

Thorsten Altenkirch (Nottingham) Edinburgh 13 October 30, 2013 25 / 29


Metatheory<br />

Canonicity<br />

We have introduced additional constants proving equalities:<br />

◮ functional extensionality<br />

◮ univalence<br />

◮ equality constructors for HITs<br />

While we have introduced some definitional equality, they are<br />

insufficient to guarantuee canonicity:<br />

All closed terms of type N are definitionally equal (indeed reducible)<br />

to a numeral.<br />

While we (with Conor McBride and Wouter Swierstra) have developed<br />

an approach to solve the problem for functional extensionality<br />

(Observational <strong>Type</strong> <strong>Theory</strong>), this relies on a strong form of UIP.<br />

Thorsten Altenkirch (Nottingham) Edinburgh 13 October 30, 2013 26 / 29


Metatheory<br />

Constructive models<br />

The homotopy interpretation of type theory uses Kan Fibrations in<br />

simplicial sets (the simplicial set model).<br />

This construction relies essentially on classical principles.<br />

Thierry Coquand has suggested a modification of this construction<br />

using semi-simplicial sets.<br />

This models only weak <strong>Type</strong> <strong>Theory</strong> (i.e. no conversion under λ).<br />

An alternative would be to directly use weak ω-groupoids.<br />

It seems likely that an answer to this question would also provide a<br />

solution to the canonicity problem.<br />

Thorsten Altenkirch (Nottingham) Edinburgh 13 October 30, 2013 27 / 29


Computer Science ?<br />

Why should we care?<br />

Structures can be 1st class citizens.<br />

(equality is isomorphism)<br />

HITs provide better ways to define the Cauchy Reals and the<br />

constructible hierarchy (avoiding choice).<br />

Quotient containers (like multisets) become ordinary containers.<br />

Thorsten Altenkirch (Nottingham) Edinburgh 13 October 30, 2013 28 / 29


Computer Science ?<br />

The HoTT people<br />

Thorsten Altenkirch (Nottingham) Edinburgh 13 October 30, 2013 29 / 29

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!