10 Everything from the Identity Type

In homotopy type theory the identity is itself a type. For \(a,b:A\) there is a type \(a=b\) whose canonical element is \(\mathsf {refl}_a:a=a\). Everything in Section 9 is rebuilt from this type and its elimination rule.

The engine. The type of paths out of a point, \(\sum _{x:A}(a=x)\), is contractible: the identity is the only element of its kind.

Yoneda. Path induction is the Yoneda lemma.

Univalence. Equivalence is identity, so pairing two collections is identifying them, and numbers are the connected components of the type of finite types.

The natural numbers. \(\mathbb N\) is the initial algebra of \(X\mapsto 1+X\) in a strong sense: the type of such initial algebras is contractible. So "unique up to unique isomorphism" becomes "unique", and Benacerraf’s question dissolves.

Sets. Order, segments, the von Neumann successor, Zermelo numerals, Foundation and anti-foundation follow, with the cumulative hierarchy as a higher inductive type.

10.1 Level 0: the identity type

Formation and introduction.

\begin{equation} a,b:A\ \vdash \ (a=b):\mathcal U, \qquad \mathsf {refl}_a:a=a . \tag{152}\end{equation}

Path induction (J). To define or prove something for all \(x:A\) and \(p:a=x\), it suffices to do so for \(x\equiv a\) and \(p\equiv \mathsf {refl}_a\):

\begin{equation} \mathsf J:\ C(a,\mathsf {refl}_a)\ \to \ \prod _{x:A}\prod _{p:a=x}C(x,p). \tag{153}\end{equation}

Consequences. From \(\mathsf J\) alone:

Every type is an \(\infty \)-groupoid generated by \(\mathsf {refl}\).

10.2 Level 1: the engine

Contractibility.

\begin{equation} \mathsf {isContr}(A):=\sum _{c:A}\prod _{x:A}(c=x), \tag{154}\end{equation}
a centre with a path to every point.

Lemma (paths out of a point). For \(a:A\), the type \(\sum _{x:A}(a=x)\) is contractible, with centre \((a,\mathsf {refl}_a)\).

Proof. By \(\mathsf J\), it suffices to give a path \((a,\mathsf {refl}_a)=(x,p)\) when \(x\equiv a\) and \(p\equiv \mathsf {refl}_a\), and that path is \(\mathsf {refl}\). \(\square \)

This is the type-theoretic form of "the identity is the only arrow of its kind". Every universal property below is the contractibility of some type of maps.

10.3 Level 2: Yoneda is path induction

Yoneda. For a type family \(P:A\to \mathcal U\) and \(a:A\),

\begin{equation} \Bigl (\prod _{x:A}(a=x)\to P(x)\Bigr )\ \simeq \ P(a), \qquad \eta \mapsto \eta (a,\mathsf {refl}_a). \tag{155}\end{equation}
The inverse sends \(u:P(a)\) to \(\lambda x\,p.\,p_{*}u\), and the two round trips are the identity by \(\mathsf J\).

Reading. The representable functor is \(x\mapsto (a=x)\). A family of maps out of it is determined by its value on \(\mathsf {refl}_a\), which is what \(\mathsf J\) says. The Yoneda lemma is not a theorem added to the identity type: it is the rule for using that type.

10.4 Level 3: levels, truncation, logic

Truncation levels.

Level Condition
contractible \(\mathsf {isContr}(A)\)
proposition \(\prod _{x,y:A}(x=y)\), any two elements equal
set each \(x=y\) is a proposition
\(n\)-type each \(x=y\) is an \((n-1)\)-type

Truncation as idempotent closure. Propositional truncation \(A\mapsto \|A\|\) reflects types into propositions. It is idempotent, \(\|\,\|A\|\,\|\simeq \|A\|\), and monotone. More generally, a modality is an idempotent reflection onto a subclass of types: the idempotent closure of Section 26.

Logic. The propositions of \(\mathcal U\) form a Heyting algebra:

Connective Type
\(P\wedge Q\) \(P\times Q\)
\(P\Rightarrow Q\) \(P\to Q\)
\(P\vee Q\) \(\|P+Q\|\)
\(\bot \) \(\mathbf 0\)
\(\neg P\) \(P\to \mathbf 0\)

Excluded middle \(\prod _P(P\vee \neg P)\) is not provable. Double negation \(\neg \neg \) is a modality on propositions whose fixed points form a Boolean algebra: the Boolean core.

10.5 Level 4: the basic types by universal properties

Each type is characterised by an equivalence of mapping types.

Type Universal property
\(\mathbf 0\) \((\mathbf 0\to C)\) is contractible
\(\mathbf 1\) \((C\to \mathbf 1)\) is contractible; \(\mathbf 1\simeq \sum _x(a=x)\)
\(A+B\) \((A+B\to C)\simeq (A\to C)\times (B\to C)\)
\(A\times B\) \((C\to A\times B)\simeq (C\to A)\times (C\to B)\)

The unit type is, up to equivalence, the based path space: the identity with nothing else. Products and coproducts are the right and left adjoints of the diagonal \(x\mapsto (x,x)\).

10.6 Level 5: univalence, pairing is identity

Univalence. For types \(A,B\) in a universe,

\begin{equation} \mathsf {idtoeqv}:(A=_{\mathcal U}B)\xrightarrow {\ \simeq \ }(A\simeq B). \tag{156}\end{equation}

Pairing. Two collections are paired when there is an equivalence between them. By univalence, a pairing is a path in the universe: to pair is to identify.

Finite types.

\begin{equation} \mathrm {Fin}(0)=\mathbf 0, \qquad \mathrm {Fin}(n+1)=\mathrm {Fin}(n)+\mathbf 1, \tag{157}\end{equation}
rows of \(n\) marks, each step adjoining one point.

Numbers as components.

\begin{equation} \mathrm {FinSet}:=\sum _{X:\mathcal U}\Bigl \|\sum _{n:\mathbb N}X\simeq \mathrm {Fin}(n)\Bigr \|, \qquad \|\mathrm {FinSet}\|_0\simeq \mathbb N . \tag{158}\end{equation}
A number is a connected component of the type of finite types: all types that can be paired with a row of \(n\) marks are identified, by univalence.

Pigeonhole.

\begin{equation} \mathrm {Fin}(m)\simeq \mathrm {Fin}(n)\ \to \ m=n, \tag{159}\end{equation}
by induction, removing one point from each side of an equivalence. So the size of a finite type is well defined.

Dedekind infinity. \(\mathbb N\simeq \mathbb N+\mathbf 1\), by \(n\mapsto n+1\) with the new point sent to \(0\), while \(\mathrm {Fin}(n)\not \simeq \mathrm {Fin}(n)+\mathbf 1\) by pigeonhole. This is the Hilbert hotel.

10.7 Level 6: \(\mathbb N\) as the initial algebra

Algebras. For \(F(X)=\mathbf 1+X\), an algebra is a type \(X\) with a point \(x_0:X\) and a map \(f:X\to X\). Morphisms are maps \(h\) with paths \(h(x_0)=y_0\) and \(h\circ f=g\circ h\).

The inductive type. \(\mathbb N\) has constructors \(0:\mathbb N\) and \(\mathsf {succ}:\mathbb N\to \mathbb N\), with dependent elimination: induction.

Homotopy initiality. For every algebra \((X,x_0,f)\), the type of algebra morphisms \(\mathbb N\to X\) is contractible (Awodey–Gambino–Sojakova). This is recursion, with uniqueness given by a path rather than by a separate axiom.

Lambek. \([0,\mathsf {succ}]:\mathbf 1+\mathbb N\to \mathbb N\) is an equivalence. The proof is that of Section 9, Level 7, with "only endomorphism" replaced by "contractible type of endomorphisms".

Peano’s conditions by encode–decode. Define \(\mathsf {code}:\mathbb N\to \mathbb N\to \mathcal U\) by recursion:

\begin{equation} \mathsf {code}(0,0)=\mathbf 1, \quad \mathsf {code}(0,\mathsf {succ}\,n)=\mathbf 0, \quad \mathsf {code}(\mathsf {succ}\,m,0)=\mathbf 0, \quad \mathsf {code}(\mathsf {succ}\,m,\mathsf {succ}\,n)=\mathsf {code}(m,n). \tag{160}\end{equation}
Then \((m=n)\simeq \mathsf {code}(m,n)\). In particular:

Uniqueness, not up to isomorphism. The type of homotopy-initial \((\mathbf 1+X)\)-algebras is a proposition, and it is inhabited by \(\mathbb N\), hence contractible. By univalence, two initial algebras are not merely isomorphic: they are equal, by a unique path. There is exactly one natural numbers type.

The declaration. The formation rule for \(\mathbb N\) is where the completed infinite is declared (Subsection 458). The finite stages \(\mathrm {Fin}(n)\) are the Adámek chain \(\mathbf 0\to \mathbf 1\to \mathbf 1+\mathbf 1\to \cdots \), and \(\mathbb N\) is its colimit taken as one type.

10.8 Level 7: order, segments and the successor

Order.

\begin{equation} m\le n:=\sum _{k:\mathbb N}(m+k=n), \qquad m<n:=(\mathsf {succ}\,m\le n). \tag{161}\end{equation}
Both are propositions, by injectivity of addition. Then:

Segments.

\begin{equation} \mathrm {seg}(n):=\sum _{m:\mathbb N}(m<n)\ \simeq \ \mathrm {Fin}(n). \tag{162}\end{equation}

The successor.

\begin{equation} \mathrm {seg}(n+1)\simeq \mathrm {seg}(n)+\mathbf 1 . \tag{163}\end{equation}
\(m<n+1\) splits as \(m<n\) or \(m=n\), and the second summand is the contractible type \(\sum _m(m=n)\), whose centre is \((n,\mathsf {refl}_n)\). The point adjoined by the successor is \(\mathsf {refl}_n\): the identity, as in Section 9, Level 9, now as an element of an identity type.

10.9 Level 8: the cumulative hierarchy

Definition. \(V\) is the higher inductive type with

The path constructor is extensionality, built into identity on \(V\).

Membership.

\begin{equation} x\in \mathsf {set}(A,f):=\Bigl \|\sum _{a:A}f(a)=x\Bigr \| . \tag{164}\end{equation}
\((V,\in )\) satisfies the axioms of a constructive set theory, and of ZFC under excluded middle and choice.

Numerals. By recursion on \(\mathbb N\):

\begin{align} v(0)&=\mathsf {set}(\mathbf 0,!), & v(n+1)&=v(n)\cup \{v(n)\}, \tag{165}\\ z(0)&=\mathsf {set}(\mathbf 0,!), & z(n+1)&=\{z(n)\}. \tag{166}\end{align}

Equivalently,

\begin{equation} v(n)=\mathsf {set}\bigl (\mathrm {seg}(n),\ m\mapsto v(m)\bigr ), \tag{167}\end{equation}
so \(v(m)\in v(n)\iff m<n\), and the elements of \(v(n)\) correspond to \(\mathrm {Fin}(n)\). The Zermelo numerals satisfy \(z(m)\in z(n)\iff n=m+1\).

Benacerraf. There is one \(\mathbb N\), unique by contractibility, and two algebra morphisms \(v,z:\mathbb N\to V\) for the two algebra structures on \(V\), \(x\mapsto x\cup \{x\}\) and \(x\mapsto \{x\}\). "\(1\in 3\)" is a question about the morphism and its target, not about \(\mathbb N\), which has no membership relation at all.

10.10 Level 9: Foundation and anti-foundation

Foundation. The induction principle of \(V\) proves

\begin{equation} \prod _{x:V}\Bigl (\prod _{y\in x}P(y)\Bigr )\to P(x) \ \Longrightarrow \ \prod _{x:V}P(x) \tag{168}\end{equation}
for any family of propositions \(P\): \(\in \)-induction. Foundation is the induction principle of \(V\), the type-theoretic form of initiality, and in particular \(x\notin x\).

Anti-foundation. Coinductive types (M-types), the final coalgebras, are constructed from limits of the dual chain. A final coalgebra for the power-set functor contains a unique \(\Omega \) with \(\Omega =\{\Omega \}\). Foundation and anti-foundation are induction and coinduction, initial and final.

Collapse. For a well-founded extensional relation on a set \(X\), recursion along it defines \(f:X\to V\) with \(f(x)=\mathsf {set}\bigl (\sum _yyRx,\ f\bigr )\), injective by extensionality: the Mostowski collapse. For the order on \(\mathbb N\), \(f=v\).

10.11 Summary

Section 9 Identity type Rule
identity arrow \(\mathsf {refl}_a:a=a\) introduction
universality forces identity \(\sum _x(a=x)\) contractible \(\mathsf J\)
Yoneda \(\bigl (\prod _x(a=x)\to Px\bigr )\simeq P(a)\) \(\mathsf J\)
idempotent closure truncation, modalities reflection
Heyting logic, Boolean core \(\mathrm {Prop}\), \(\neg \neg \) —
\(\mathbf 0,\mathbf 1,+,\times \) mapping-type equivalences universal properties
pairing \(A\simeq B\), which is \(A=B\) univalence
numbers \(\|\mathrm {FinSet}\|_0\simeq \mathbb N\) univalence, truncation
Dedekind infinity \(\mathbb N\simeq \mathbb N+\mathbf 1\) —
\(\mathbb N\) inductive type, h-initial induction
Peano encode–decode \(\mathsf {code}\)
categoricity initial algebras contractible univalence
order, irreflexivity \(\sum _k(m+k=n)\) \(\mathsf {code}\)
successor \(\mathrm {seg}(n+1)\simeq \mathrm {seg}(n)+\mathbf 1\), new point \(\mathsf {refl}_n\) —
\(V\), von Neumann, Zermelo HIT, two algebra maps recursion
Foundation induction principle of \(V\) initiality
anti-foundation M-types finality

Every entry is a statement about the identity type: its introduction \(\mathsf {refl}\), its elimination \(\mathsf J\), the contractibility of paths out of a point, and univalence, which makes identity of types the same as equivalence.