# 2. Homotopy Type Theory

We begin with a brief summary of the connection between homotopy theory and higher-dimensional category theory. In classical homotopy theory, a space $X$ is a set of points equipped with a topology  , and a path between points $x$ and $y$ is represented by a continuous map $p:[0,1]\to X$, where $p(0)=x$ and $p(1)=y$. This function can be thought of as giving a point in $X$ at each “moment in time”. For many purposes, strict equality of paths (meaning, pointwise equal functions) is too fine a notion. For example, one can define operations  of path concatenation (if $p$ is a path from $x$ to $y$ and $q$ is a path from $y$ to $z$, then the concatenation $p\mathchoice{\mathbin{\raisebox{2.15pt}{\displaystyle\centerdot}}}{\mathbin{% \raisebox{2.15pt}{\centerdot}}}{\mathbin{\raisebox{1.075pt}{\scriptstyle\,% \centerdot\,}}}{\mathbin{\raisebox{0.43pt}{\scriptscriptstyle\,\centerdot\,% }}}q$ is a path from $x$ to $z$) and inverses        ($\mathord{{p}^{-1}}$ is a path from $y$ to $x$). However, there are natural equations between these operations that do not hold for strict equality: for example, the path $p\mathchoice{\mathbin{\raisebox{2.15pt}{\displaystyle\centerdot}}}{\mathbin{% \raisebox{2.15pt}{\centerdot}}}{\mathbin{\raisebox{1.075pt}{\scriptstyle\,% \centerdot\,}}}{\mathbin{\raisebox{0.43pt}{\scriptscriptstyle\,\centerdot\,% }}}\mathord{{p}^{-1}}$ (which walks from $x$ to $y$, and then back along the same route, as time goes from $0$ to $1$) is not strictly equal to the identity path (which stays still at $x$ at all times).

The remedy is to consider a coarser  notion of equality of paths called homotopy   . A homotopy between a pair of continuous maps $f:X_{1}\to X_{2}$ and $g:X_{1}\to X_{2}$ is a continuous map $H:X_{1}\times[0,1]\to X_{2}$ satisfying $H(x,0)=f(x)$ and $H(x,1)=g(x)$. In the specific case of paths $p$ and $q$ from $x$ to $y$, a homotopy is a continuous map $H:[0,1]\times[0,1]\rightarrow X$ such that $H(s,0)=p(s)$ and $H(s,1)=q(s)$ for all $s\in[0,1]$. In this case we require also that $H(0,t)=x$ and $H(1,t)=y$ for all $t\in[0,1]$, so that for each $t$ the function $H(\mathord{\hskip 1.0pt\text{--}\hskip 1.0pt},t)$ is again a path from $x$ to $y$; a homotopy of this sort is said to be endpoint-preserving or rel endpoints. Such a homotopy is the image in $X$ of a square that fills in the space between $p$ and $q$, which can be thought of as a “continuous deformation” between $p$ and $q$, or a 2-dimensional path between paths.

For example, because $p\mathchoice{\mathbin{\raisebox{2.15pt}{\displaystyle\centerdot}}}{\mathbin{% \raisebox{2.15pt}{\centerdot}}}{\mathbin{\raisebox{1.075pt}{\scriptstyle\,% \centerdot\,}}}{\mathbin{\raisebox{0.43pt}{\scriptscriptstyle\,\centerdot\,% }}}\mathord{{p}^{-1}}$ walks out and back along the same route, you know that you can continuously shrink $p\mathchoice{\mathbin{\raisebox{2.15pt}{\displaystyle\centerdot}}}{\mathbin{% \raisebox{2.15pt}{\centerdot}}}{\mathbin{\raisebox{1.075pt}{\scriptstyle\,% \centerdot\,}}}{\mathbin{\raisebox{0.43pt}{\scriptscriptstyle\,\centerdot\,% }}}\mathord{{p}^{-1}}$ down to the identity path—it won’t, for example, get snagged around a hole in the space. Homotopy is an equivalence relation  , and operations such as concatenation, inverses, etc., respect it. Moreover, the homotopy equivalence   classes of loops at some point $x_{0}$ (where two loops $p$ and $q$ are equated when there is a based homotopy between them, which is a homotopy $H$ as above that additionally satisfies $H(0,t)=H(1,t)=x_{0}$ for all $t$) form a group called the fundamental group   . This group is an algebraic invariant of a space, which can be used to investigate whether two spaces are homotopy equivalent (there are continuous maps back and forth whose composites are homotopic  to the identity), because equivalent     spaces have isomorphic   fundamental groups.

Because homotopies are themselves a kind of 2-dimensional path, there is a natural notion of 3-dimensional homotopy between homotopies, and then homotopy between homotopies between homotopies, and so on. This infinite   tower of points, path, homotopies, homotopies between homotopies, …, equipped with algebraic operations such as the fundamental group, is an instance of an algebraic structure  called a (weak) $\infty$-groupoid. An $\infty$-groupoid consists of a collection  of objects, and then a collection of morphisms  between objects, and then morphisms between morphisms, and so on, equipped with some complex algebraic structure; a morphism at level $k$ is called a $k$-morphism. Morphisms at each level have identity, composition, and inverse operations, which are weak in the sense that they satisfy the groupoid laws (associativity of composition, identity is a unit for composition, inverses cancel) only up to morphisms at the next level, and this weakness gives rise to further structure  . For example, because associativity of composition of morphisms $p\mathchoice{\mathbin{\raisebox{2.15pt}{\displaystyle\centerdot}}}{\mathbin{% \raisebox{2.15pt}{\centerdot}}}{\mathbin{\raisebox{1.075pt}{\scriptstyle\,% \centerdot\,}}}{\mathbin{\raisebox{0.43pt}{\scriptscriptstyle\,\centerdot\,% }}}(q\mathchoice{\mathbin{\raisebox{2.15pt}{\displaystyle\centerdot}}}{% \mathbin{\raisebox{2.15pt}{\centerdot}}}{\mathbin{\raisebox{1.075pt}{% \scriptstyle\,\centerdot\,}}}{\mathbin{\raisebox{0.43pt}{\scriptscriptstyle% \,\centerdot\,}}}r)=(p\mathchoice{\mathbin{\raisebox{2.15pt}{\displaystyle% \centerdot}}}{\mathbin{\raisebox{2.15pt}{\centerdot}}}{\mathbin{\raisebox{1% .075pt}{\scriptstyle\,\centerdot\,}}}{\mathbin{\raisebox{0.43pt}{% \scriptscriptstyle\,\centerdot\,}}}q)\mathchoice{\mathbin{\raisebox{2.15pt}{% \displaystyle\centerdot}}}{\mathbin{\raisebox{2.15pt}{\centerdot}}}{% \mathbin{\raisebox{1.075pt}{\scriptstyle\,\centerdot\,}}}{\mathbin{\raisebox% {0.43pt}{\scriptscriptstyle\,\centerdot\,}}}r$ is itself a higher-dimensional morphism, one needs an additional operation relating various proofs of associativity: the various ways to reassociate $p\mathchoice{\mathbin{\raisebox{2.15pt}{\displaystyle\centerdot}}}{\mathbin{% \raisebox{2.15pt}{\centerdot}}}{\mathbin{\raisebox{1.075pt}{\scriptstyle\,% \centerdot\,}}}{\mathbin{\raisebox{0.43pt}{\scriptscriptstyle\,\centerdot\,% }}}(q\mathchoice{\mathbin{\raisebox{2.15pt}{\displaystyle\centerdot}}}{% \mathbin{\raisebox{2.15pt}{\centerdot}}}{\mathbin{\raisebox{1.075pt}{% \scriptstyle\,\centerdot\,}}}{\mathbin{\raisebox{0.43pt}{\scriptscriptstyle% \,\centerdot\,}}}(r\mathchoice{\mathbin{\raisebox{2.15pt}{\displaystyle% \centerdot}}}{\mathbin{\raisebox{2.15pt}{\centerdot}}}{\mathbin{\raisebox{1% .075pt}{\scriptstyle\,\centerdot\,}}}{\mathbin{\raisebox{0.43pt}{% \scriptscriptstyle\,\centerdot\,}}}s))$ into $((p\mathchoice{\mathbin{\raisebox{2.15pt}{\displaystyle\centerdot}}}{% \mathbin{\raisebox{2.15pt}{\centerdot}}}{\mathbin{\raisebox{1.075pt}{% \scriptstyle\,\centerdot\,}}}{\mathbin{\raisebox{0.43pt}{\scriptscriptstyle% \,\centerdot\,}}}q)\mathchoice{\mathbin{\raisebox{2.15pt}{\displaystyle% \centerdot}}}{\mathbin{\raisebox{2.15pt}{\centerdot}}}{\mathbin{\raisebox{1% .075pt}{\scriptstyle\,\centerdot\,}}}{\mathbin{\raisebox{0.43pt}{% \scriptscriptstyle\,\centerdot\,}}}r)\mathchoice{\mathbin{\raisebox{2.15pt}{% \displaystyle\centerdot}}}{\mathbin{\raisebox{2.15pt}{\centerdot}}}{% \mathbin{\raisebox{1.075pt}{\scriptstyle\,\centerdot\,}}}{\mathbin{\raisebox% {0.43pt}{\scriptscriptstyle\,\centerdot\,}}}s$ give rise to Mac Lane’s pentagon  . Weakness also creates non-trivial interactions between levels.

Every topological space $X$ has a fundamental $\infty$-groupoid whose $k$-morphisms are the $k$-dimensional paths in $X$. The weakness of the $\infty$-groupoid corresponds directly to the fact that paths form a group only up to homotopy, with the $(k+1)$-paths serving as the homotopies between the $k$-paths. Moreover, the view of a space as an $\infty$-groupoid preserves enough aspects of the space to do homotopy theory: the fundamental $\infty$-groupoid construction is adjoint to the geometric realization of an $\infty$-groupoid as a space, and this adjunction  preserves homotopy theory (this is called the homotopy hypothesis/theorem, because whether it is a hypothesis  or theorem depends on how you define $\infty$-groupoid). For example, you can easily define the fundamental group of an $\infty$-groupoid, and if you calculate the fundamental group of the fundamental $\infty$-groupoid of a space, it will agree with the classical definition of fundamental group of that space. Because of this correspondence, homotopy theory and higher-dimensional category theory are intimately related.

Now, in homotopy type theory each type can be seen to have the structure of an $\infty$-groupoid. Recall that for any type $A$, and any $x,y:A$, we have a identity type $x=_{A}y$, also written $\mathsf{Id}_{A}(x,y)$ or just $x=y$. Logically, we may think of elements of $x=y$ as evidence that $x$ and $y$ are equal, or as identifications of $x$ with $y$. Furthermore, type theory  (unlike, say, first-order logic) allows us to consider such elements of $x=_{A}y$ also as individuals which may be the subjects of further propositions  . Therefore, we can iterate the identity type: we can form the type $p=_{(x=_{A}y)}q$ of identifications between identifications $p,q$, and the type $r=_{(p=_{(x=_{A}y)}q)}s$, and so on. The structure of this tower of identity types corresponds precisely to that of the continuous paths and (higher) homotopies between them in a space, or an $\infty$-groupoid.

Thus, we will frequently refer to an element $p:x=_{A}y$ as a path from $x$ to $y$; we call $x$ its start point and $y$ its end point. Two paths $p,q:x=_{A}y$ with the same start and end point are said to be , in which case an element $r:p=_{(x=_{A}y)}q$ can be thought of as a homotopy, or a morphism between morphisms; we will often refer to it as a 2-path or a 2-dimensional path Similarly, $r=_{(p=_{(x=_{A}y)}q)}s$ is the type of 3-dimensional paths between two parallel 2-dimensional paths, and so on. If the type $A$ is “set-like”, such as $\mathbb{N}$, these iterated identity types will be uninteresting (see §3.1 (http://planetmath.org/31setsandntypes)), but in the general case they can model non-trivial homotopy types.

An important difference  between homotopy type theory and classical homotopy theory is that homotopy type theory provides a synthetic description of spaces, in the following sense. Synthetic geometry is geometry  in the style of Euclid : one starts from some basic notions (points and lines), constructions (a line connecting any two points), and axioms (all right angles   are equal), and deduces consequences logically. This is in contrast with analytic geometry  , where notions such as points and lines are represented concretely using cartesian coordinates  in $\mathbb{R}^{n}$—lines are sets of points—and the basic constructions and axioms are derived from this representation. While classical homotopy theory is analytic (spaces and paths are made of points), homotopy type theory is synthetic: points, paths, and paths between paths are basic, indivisible, primitive notions.

Moreover, one of the amazing things about homotopy type theory is that all of the basic constructions and axioms—all of the higher groupoid structure—-arises automatically from the induction  principle for identity types. Recall from §1.12 (http://planetmath.org/112identitytypes) that this says that if

• for every $x,y:A$ and every $p:x=_{A}y$ we have a type $D(x,y,p)$, and

• for every $a:A$ we have an element $d(a):D(a,a,\mathsf{refl}_{a})$,

then

• there exists an element $\mathsf{ind}_{=_{A}}(D,d,x,y,p):D(x,y,p)$ for every two elements $x,y:A$ and $p:x=_{A}y$, such that $\mathsf{ind}_{=_{A}}(D,d,a,a,\mathsf{refl}_{a})\equiv d(a)$.

In other words, given dependent functions

 $\displaystyle D$ $\displaystyle:\mathchoice{\prod_{(x,y:A)}\,}{\mathchoice{{\textstyle\prod_{(x,% y:A)}}}{\prod_{(x,y:A)}}{\prod_{(x,y:A)}}{\prod_{(x,y:A)}}}{\mathchoice{{% \textstyle\prod_{(x,y:A)}}}{\prod_{(x,y:A)}}{\prod_{(x,y:A)}}{\prod_{(x,y:A)}}% }{\mathchoice{{\textstyle\prod_{(x,y:A)}}}{\prod_{(x,y:A)}}{\prod_{(x,y:A)}}{% \prod_{(x,y:A)}}}\mathchoice{\prod_{(p:x=y)}\,}{\mathchoice{{\textstyle\prod_{% (p:x=y)}}}{\prod_{(p:x=y)}}{\prod_{(p:x=y)}}{\prod_{(p:x=y)}}}{\mathchoice{{% \textstyle\prod_{(p:x=y)}}}{\prod_{(p:x=y)}}{\prod_{(p:x=y)}}{\prod_{(p:x=y)}}% }{\mathchoice{{\textstyle\prod_{(p:x=y)}}}{\prod_{(p:x=y)}}{\prod_{(p:x=y)}}{% \prod_{(p:x=y)}}}\mathcal{U}$ $\displaystyle d$ $\displaystyle:\mathchoice{\prod_{a:A}\,}{\mathchoice{{\textstyle\prod_{(a:A)}}% }{\prod_{(a:A)}}{\prod_{(a:A)}}{\prod_{(a:A)}}}{\mathchoice{{\textstyle\prod_{% (a:A)}}}{\prod_{(a:A)}}{\prod_{(a:A)}}{\prod_{(a:A)}}}{\mathchoice{{\textstyle% \prod_{(a:A)}}}{\prod_{(a:A)}}{\prod_{(a:A)}}{\prod_{(a:A)}}}D(a,a,\mathsf{% refl}_{a})$

there is a dependent function

 $\mathsf{ind}_{=_{A}}(D,d):\mathchoice{\prod_{(x,y:A)}\,}{\mathchoice{{% \textstyle\prod_{(x,y:A)}}}{\prod_{(x,y:A)}}{\prod_{(x,y:A)}}{\prod_{(x,y:A)}}% }{\mathchoice{{\textstyle\prod_{(x,y:A)}}}{\prod_{(x,y:A)}}{\prod_{(x,y:A)}}{% \prod_{(x,y:A)}}}{\mathchoice{{\textstyle\prod_{(x,y:A)}}}{\prod_{(x,y:A)}}{% \prod_{(x,y:A)}}{\prod_{(x,y:A)}}}\mathchoice{\prod_{(p:x=y)}\,}{\mathchoice{{% \textstyle\prod_{(p:x=y)}}}{\prod_{(p:x=y)}}{\prod_{(p:x=y)}}{\prod_{(p:x=y)}}% }{\mathchoice{{\textstyle\prod_{(p:x=y)}}}{\prod_{(p:x=y)}}{\prod_{(p:x=y)}}{% \prod_{(p:x=y)}}}{\mathchoice{{\textstyle\prod_{(p:x=y)}}}{\prod_{(p:x=y)}}{% \prod_{(p:x=y)}}{\prod_{(p:x=y)}}}D(x,y,p)$

such that

 $\mathsf{ind}_{=_{A}}(D,d,a,a,\mathsf{refl}_{a})\equiv d(a)$ (2.0.1)

for every $a:A$. Usually, every time we apply this induction rule we will either not care about the specific function being defined, or we will immediately give it a different name.

Informally, the induction principle for identity types says that if we want to construct an object (or prove a statement) which depends on an inhabitant $p:x=_{A}y$ of an identity type, then it suffices to perform the construction (or the proof) in the special case when $x$ and $y$ are the same (judgmentally) and $p$ is the reflexivity  element $\mathsf{refl}_{x}:x=x$ (judgmentally). When writing informally, we may express this with a phrase such as “by induction, it suffices to assume…”. This reduction   to the “reflexivity case” is analogous to the reduction to the “base case” and “inductive step” in an ordinary proof by induction on the natural numbers  , and also to the “left case” and “right case” in a proof by case analysis on a disjoint union   or disjunction  .

The “conversion rule” (2.0.1) is less familiar in the context of proof by induction on natural numbers, but there is an analogous notion in the related concept of definition by recursion. If a sequence   $(a_{n})_{n\in\mathbb{N}}$ is defined by giving $a_{0}$ and specifying $a_{n+1}$ in terms of $a_{n}$, then in fact the $0^{\mathrm{th}}$ term of the resulting sequence is the given one, and the given recurrence relation relating $a_{n+1}$ to $a_{n}$ holds for the resulting sequence. (This may seem so obvious as to not be worth saying, but if we view a definition by recursion as an algorithm for calculating values of a sequence, then it is precisely the process of executing that algorithm.) The rule (2.0.1) is analogous: it says that if we define an object $f(p)$ for all $p:x=y$ by specifying what the value should be when $p$ is $\mathsf{refl}_{x}:x=x$, then the value we specified is in fact the value of $f(\mathsf{refl}_{x})$.

This induction principle endows each type with the structure of an $\infty$-groupoid, and each function between two types the structure of an $\infty$-functor  between two such groupoids. This is interesting from a mathematical point view, because it gives a new way to work with $\infty$-groupoids. It is interesting from a type-theoretic point view, because it reveals new operations that are associated with each type and function. In the remainder of this chapter, we begin to explore this structure.

## References

• 1 Euclid, Elements,Vols. 1–13 Elsevier,300 BC
Title 2. Homotopy Type Theory
\metatable