6.6 Cell complexes
In classical topology^{}, a cell complex is a space obtained by successively attaching discs along their boundaries. It is called a CW complex if the boundary of an $n$dimensional disc is constrained to lie in the discs of dimension^{} strictly less than $n$ (the $(n1)$skeleton).
Any finite CW complex can be presented as a higher inductive type, by turning $n$dimensional discs into $n$dimensional paths and partitioning the image of the attaching map into a source and a target, with each written as a composite of lower dimensional paths. Our explicit definitions of ${\mathrm{\pi \x9d\x95\x8a}}^{1}$ and ${\mathrm{\pi \x9d\x95\x8a}}^{2}$ in Β§6.4 (http://planetmath.org/64circlesandspheres) had this form.
Another example is the torus ${T}^{2}$, which is generated by:

β’
a point $b:{T}^{2}$,

β’
a path $p:b=b$,

β’
another path $q:b=b$, and

β’
a 2path $t:p\beta \x81\u2019\text{centerdot}\beta \x81\u2019q=q\beta \x81\u2019\text{centerdot}\beta \x81\u2019p$.
Perhaps the easiest way to see that this is a torus is to start with a rectangle, having four corners $a,b,c,d$, four edges $p,q,r,s$, and an interior which is manifestly a 2path $t$ from $p\beta \x81\u2019\text{centerdot}\beta \x81\u2019q$ to $r\beta \x81\u2019\text{centerdot}\beta \x81\u2019s$:
Now identify the edge $r$ with $q$ and the edge $s$ with $p$, resulting in also identifying all four corners. Topologically, this identification can be seen to produce a torus.
The induction^{} principle for the torus is the trickiest of any weβve written out so far. Given $P:{T}^{2}\beta \x86\x92\mathrm{\pi \x9d\x92\xb0}$, for a section^{} ${\beta \x88\x8f}_{(x:{T}^{2})}P\beta \x81\u2019(x)$ we require

β’
a point ${b}^{\beta \x80\xb2}:P\beta \x81\u2019(b)$,

β’
a path ${p}^{\beta \x80\xb2}:{b}^{\beta \x80\xb2}{=}_{p}^{P}{b}^{\beta \x80\xb2}$,

β’
a path ${q}^{\beta \x80\xb2}:{b}^{\beta \x80\xb2}{=}_{q}^{P}{b}^{\beta \x80\xb2}$, and

β’
a 2path ${t}^{\beta \x80\xb2}$ between the βcompositesβ ${p}^{\beta \x80\xb2}\beta \x81\u2019\text{centerdot}\beta \x81\u2019{q}^{\beta \x80\xb2}$ and ${q}^{\beta \x80\xb2}\beta \x81\u2019\text{centerdot}\beta \x81\u2019{p}^{\beta \x80\xb2}$, lying over $t$.
In order to make sense of this last datum, we need a composition operation for dependent paths, but this is not hard to define. Then the induction principle gives a function $f:{\beta \x88\x8f}_{(x:{T}^{2})}P\beta \x81\u2019(x)$ such that $f\beta \x81\u2019(b)\beta \x89\u2018{b}^{\beta \x80\xb2}$ and ${\mathrm{\pi \x9d\x96\u038a\pi \x9d\x97\x89\pi \x9d\x96\xbd}}_{f}\left(p\right)={p}^{\beta \x80\xb2}$ and ${\mathrm{\pi \x9d\x96\u038a\pi \x9d\x97\x89\pi \x9d\x96\xbd}}_{f}\left(q\right)={q}^{\beta \x80\xb2}$ and something like β${\mathrm{\pi \x9d\x96\u038a\pi \x9d\x97\x89\pi \x9d\x96\xbd}}_{f}^{2}\left(t\right)={t}^{\beta \x80\xb2}$β. However, this is not welltyped as it stands, firstly because the equalities ${\mathrm{\pi \x9d\x96\u038a\pi \x9d\x97\x89\pi \x9d\x96\xbd}}_{f}\left(p\right)={p}^{\beta \x80\xb2}$ and ${\mathrm{\pi \x9d\x96\u038a\pi \x9d\x97\x89\pi \x9d\x96\xbd}}_{f}\left(q\right)={q}^{\beta \x80\xb2}$ are not judgmental, and secondly because ${\mathrm{\pi \x9d\x96\u038a\pi \x9d\x97\x89\pi \x9d\x96\xbd}}_{f}$ only preserves path concatenation up to homotopy. We leave the details to the reader (see http://planetmath.org/node/87797Exercise 6.1).
Of course, another definition of the torus is ${T}^{2}:\beta \x89\u2018{\mathrm{\pi \x9d\x95\x8a}}^{1}\Gamma \x97{\mathrm{\pi \x9d\x95\x8a}}^{1}$ (in http://planetmath.org/node/87800Exercise 6.3 we ask the reader to verify the equivalence of the two). The cellcomplex definition, however, generalizes easily to other spaces without such descriptions, such as the Klein bottle, the projective plane^{}, etc. But it does get increasingly difficult to write down the induction principles, requiring us to define notions of dependent $n$paths and of $\mathrm{\pi \x9d\x96\u038a\pi \x9d\x97\x89\pi \x9d\x96\xbd}$ acting on $n$paths. Fortunately, once we have the spheres in hand, there is a way around this.
Title  6.6 Cell complexes 

\metatable 