21 From the Identity Arrow to the Initial Algebra

Only arrows are given.

Every step rests on one fact: the only endomorphism of an initial object is the identity.

21.0.1 Step 0: arrows, with objects as identities

Arrows. There is a collection of arrows and a partial composition \(g\circ f\), associative where defined.

Identities. An arrow \(e\) is an identity if \(e\circ f=f\) and \(g\circ e=g\) whenever these composites are defined.

Objects are identities. Every arrow \(f\) has exactly one identity \(\mathrm {dom}(f)\) with \(f\circ \mathrm {dom}(f)=f\), and exactly one identity \(\mathrm {cod}(f)\) with \(\mathrm {cod}(f)\circ f=f\). Objects are not a second kind of thing: an object \(A\) is the identity arrow \(\mathrm {id}_A\). Write \(f:A\to B\) for \(\mathrm {dom}(f)=\mathrm {id}_A\) and \(\mathrm {cod}(f)=\mathrm {id}_B\).

21.0.2 Step 1: endomorphisms and isomorphisms

Endomorphisms. An endomorphism is an arrow \(f\) with \(\mathrm {dom}(f)=\mathrm {cod}(f)\). The endomorphisms of \(A\) form a monoid \(\mathrm {End}(A)\) with unit \(\mathrm {id}_A\), which is itself an endomorphism and an idempotent: \(\mathrm {id}_A\circ \mathrm {id}_A=\mathrm {id}_A\).

Isomorphisms. \(f:A\to B\) is an isomorphism if there is \(g:B\to A\) with

\begin{equation} g\circ f=\mathrm {id}_A, \qquad f\circ g=\mathrm {id}_B . \tag{376}\end{equation}
Going over and coming back is the identity on each side: an involutive pair.

The engine. If \(\mathrm {End}(A)=\{\mathrm {id}_A\}\) and there are arrows \(f:A\to B\) and \(g:B\to A\) with \(\mathrm {End}(B)=\{\mathrm {id}_B\}\), then \(f\) and \(g\) are mutually inverse: \(g\circ f\in \mathrm {End}(A)\) and \(f\circ g\in \mathrm {End}(B)\).

21.0.3 Step 2: functors

Definition. A functor sends arrows to arrows, identities to identities, and composites to composites:

\begin{equation} F(\mathrm {id}_A)=\mathrm {id}_{FA}, \qquad F(g\circ f)=F(g)\circ F(f). \tag{377}\end{equation}
It acts on objects through their identities.

Consequences. A functor sends endomorphisms to endomorphisms and isomorphisms to isomorphisms.

21.0.4 Step 3: adjunctions from units, counits and triangles

Data. Functors \(F:\mathbf C\to \mathbf D\) and \(G:\mathbf D\to \mathbf C\), with natural families

\begin{equation} \eta _A:A\to GFA, \qquad \varepsilon _B:FGB\to B, \tag{378}\end{equation}
satisfying the triangle identities
\begin{equation} G\varepsilon _B\circ \eta _{GB}=\mathrm {id}_{GB}, \qquad \varepsilon _{FA}\circ F\eta _A=\mathrm {id}_{FA}. \tag{379}\end{equation}

The transposes.

\begin{equation} \varphi (h):=Gh\circ \eta _A\quad \text {for }h:FA\to B, \qquad \psi (k):=\varepsilon _B\circ Fk\quad \text {for }k:A\to GB . \tag{380}\end{equation}

The bijection.

\begin{align} \psi (\varphi (h))&=\varepsilon _B\circ FGh\circ F\eta _A=h\circ \varepsilon _{FA}\circ F\eta _A=h, \tag{381}\\ \varphi (\psi (k))&=G\varepsilon _B\circ GFk\circ \eta _A=G\varepsilon _B\circ \eta _{GB}\circ k=k, \tag{382}\end{align}

using naturality of \(\varepsilon \) and \(\eta \) in the middle step and a triangle identity in the last. So

\begin{equation} \mathbf D(FA,B)\ \underset {\psi }{\overset {\varphi }{\rightleftarrows }}\ \mathbf C(A,GB), \qquad \psi \circ \varphi =\mathrm {id}, \quad \varphi \circ \psi =\mathrm {id}. \tag{383}\end{equation}

Back to the identity.

\begin{equation} \varphi (\mathrm {id}_{FA})=\eta _A, \qquad \psi (\mathrm {id}_{GB})=\varepsilon _B . \tag{384}\end{equation}
The unit and counit are the transposes of identities, and the triangle identities say that transposing twice returns the identity.
21.0.5 Step 4: the diagonal and its adjoints

Product category. Arrows of \(\mathbf C\times \mathbf C\) are pairs \((f,g)\), composed componentwise, with identities \((\mathrm {id}_A,\mathrm {id}_B)\).

The diagonal.

\begin{equation} \Delta (f):=(f,f), \qquad \Delta (\mathrm {id}_A)=(\mathrm {id}_A,\mathrm {id}_A). \tag{385}\end{equation}

Coproduct: \(+\dashv \Delta \). The unit is the pair of injections \((\mathrm {inl},\mathrm {inr}):(A,B)\to (A+B,A+B)\), and the counit is the codiagonal \(\nabla =[\mathrm {id},\mathrm {id}]:A+A\to A\). The bijection of Step 3 reads

\begin{equation} \mathbf C(A+B,X)\cong \mathbf C(A,X)\times \mathbf C(B,X), \qquad h\mapsto (h\circ \mathrm {inl},\ h\circ \mathrm {inr}), \qquad (a,b)\mapsto [a,b]. \tag{386}\end{equation}

Product: \(\Delta \dashv \times \). Dually, \(\mathbf C(X,A\times B)\cong \mathbf C(X,A)\times \mathbf C(X,B)\).

Zero and one. Let \(\mathbf 1\) be the category with a single arrow, an identity. For the unique functor \(!:\mathbf C\to \mathbf 1\),

\begin{equation} 0\dashv \ !\ \dashv 1: \qquad \mathbf C(0,X)\cong \{\mathrm {id}\}\cong \mathbf C(X,1). \tag{387}\end{equation}
In particular \(\mathrm {End}(0)=\{\mathrm {id}_0\}\).

Disjoint, monic injections. In sets, toposes and the universe of types, \(\mathrm {inl}\) and \(\mathrm {inr}\) are monic with disjoint images. In sets this follows from the tags \(0\neq 1\), which is itself a consequence of identity (Section 18).

21.0.6 Step 5: algebras

The functor.

\begin{equation} F(X)=1+X, \qquad F(f)=\mathrm {id}_1+f . \tag{388}\end{equation}

Algebras and morphisms. An algebra is \((A,\alpha )\) with \(\alpha :F(A)\to A\). A morphism \(h:(A,\alpha )\to (X,\beta )\) satisfies

\begin{equation} h\circ \alpha =\beta \circ F(h). \tag{389}\end{equation}

\(\mathbf {Alg}(F)\) is a category. The identity is a morphism because \(\mathrm {id}_A\circ \alpha =\alpha =\alpha \circ F(\mathrm {id}_A)\), by Step 2. Composites of morphisms are morphisms by functoriality. The endomorphisms of \((A,\alpha )\) in \(\mathbf {Alg}(F)\) are the endomorphisms \(h\) of \(A\) with \(h\circ \alpha =\alpha \circ F(h)\).

21.0.7 Step 6: the initial algebra

Definition by adjunction. An initial algebra is the value at the single object of a left adjoint to \(!:\mathbf {Alg}(F)\to \mathbf 1\):

\begin{equation} \mathbf {Alg}(F)\bigl ((A,\alpha ),(X,\beta )\bigr )\cong \{\mathrm {id}\} \quad \text {for every }(X,\beta ). \tag{390}\end{equation}

Its endomorphisms. In particular, \(\mathrm {End}_{\mathbf {Alg}(F)}(A,\alpha )=\{\mathrm {id}_A\}\).

Uniqueness. By the engine of Step 1, two initial algebras are related by a unique isomorphism.

Existence (the declaration). The forgetful functor \(U:\mathbf {Alg}(F)\to \mathbf C\) has a left adjoint \(\mathrm {Free}\). Then, by Steps 3 and 4,

\begin{equation} \mathbf {Alg}(F)\bigl (\mathrm {Free}(0),(X,\beta )\bigr )\cong \mathbf C(0,X)\cong \{\mathrm {id}\}, \tag{391}\end{equation}
so \((A,\alpha ):=\mathrm {Free}(0)\) is initial. This declaration is the axiom of Infinity (Subsection 458).
21.0.8 Step 7: Lambek’s lemma

Statement. \(\alpha :F(A)\to A\) is an isomorphism.

Proof.

1.
\((F(A),F(\alpha ))\) is an algebra, so Step 6 gives a morphism \(u:(A,\alpha )\to (F(A),F(\alpha ))\), that is \(u\circ \alpha =F(\alpha )\circ F(u)\).
2.
\(\alpha \) is a morphism \((F(A),F(\alpha ))\to (A,\alpha )\), since \(\alpha \circ F(\alpha )=\alpha \circ F(\alpha )\).
3.
So \(\alpha \circ u\in \mathrm {End}_{\mathbf {Alg}(F)}(A,\alpha )=\{\mathrm {id}_A\}\), that is \(\alpha \circ u=\mathrm {id}_A\).
4.
And \(u\circ \alpha =F(\alpha )\circ F(u)=F(\alpha \circ u)=F(\mathrm {id}_A)=\mathrm {id}_{F(A)}\).

\(\square \)

\begin{equation} \boxed {A\cong F(A)} \tag{392}\end{equation}
21.0.9 Step 8: the natural numbers

The isomorphism.

\begin{equation} \mathbb N:=A, \qquad \boxed {\mathbb N\cong 1+\mathbb N} \tag{393}\end{equation}

Zero and successor. By the coproduct bijection of Step 4,

\begin{equation} 0:=\alpha \circ \mathrm {inl}:1\to \mathbb N, \qquad S:=\alpha \circ \mathrm {inr}:\mathbb N\to \mathbb N, \qquad \alpha =[0,S], \tag{394}\end{equation}
so \(\alpha (\mathrm {inl}(\ast ))=0\) and \(\alpha (\mathrm {inr}(n))=S(n)\).

Peano facts. \(\alpha \) is an isomorphism (Step 7), and the injections are monic and disjoint (Step 4). Hence

\begin{equation} 0\notin S(\mathbb N), \qquad S\ \text {injective}, \qquad \text {every element is }0\text { or }S(n). \tag{395}\end{equation}
21.0.10 Step 9: fold

A target algebra. By Step 4, an algebra \((X,\beta )\) is a pair

\begin{equation} b:=\beta \circ \mathrm {inl}, \qquad f:=\beta \circ \mathrm {inr}. \tag{396}\end{equation}

Definition.

\begin{equation} \boxed {\mathsf {fold}_\beta :=\psi (!_X):\mathbb N\to X} \tag{397}\end{equation}
the transpose under \(\mathrm {Free}\dashv U\) of the unique arrow \(0\to X\).

Equations. Precompose the square \(\mathsf {fold}_\beta \circ [0,S]=\beta \circ (\mathrm {id}_1+\mathsf {fold}_\beta )\) with each injection:

\begin{align} \mathsf {fold}_\beta (0)&=b, \tag{398}\\ \mathsf {fold}_\beta (S(n))&=f(\mathsf {fold}_\beta (n)). \tag{399}\end{align}

Uniqueness. If \(h\) satisfies both equations, the coproduct bijection gives the square, so \(h\) is a morphism. Then \(\varphi (h)\) is an arrow \(0\to X\), hence \(\varphi (h)=!_X\), and \(h=\psi (\varphi (h))=\psi (!_X)=\mathsf {fold}_\beta \).

21.0.11 Step 10: induction

Subalgebras. If \(m:P\hookrightarrow \mathbb N\) is closed under \(0\) and \(S\), then \(m\) is a morphism. Step 9 gives \(u:\mathbb N\to P\), and \(m\circ u\in \mathrm {End}(\mathbb N,\alpha )=\{\mathrm {id}\}\). So \(m\) is surjective, and \(P=\mathbb N\).

Dependent form. For \(Q(n)\) with \(q_0\) and \(q_S\), \(\mathsf {fold}\) into the total algebra \(\sum _nQ(n)\) gives \(H\). Since \(\mathrm {pr}_1\) is a morphism, \(\mathrm {pr}_1\circ H\in \mathrm {End}(\mathbb N,\alpha )=\{\mathrm {id}\}\), and \(\mathrm {pr}_2\circ H\) is the required section.

\begin{equation} \boxed {\text {initial algebra}\ \Longrightarrow \ \text {structural recursion}+\text {structural induction}} \tag{400}\end{equation}
21.0.12 The chain

Step Derived From
0 objects identity arrows
1 endomorphisms, isomorphisms, engine \(\mathrm {dom}=\mathrm {cod}\); \(g\circ f=\mathrm {id}\)
2 functors preserve \(\mathrm {id}\) and \(\circ \)
3 adjunction bijection triangle identities: transposing twice is \(\mathrm {id}\)
4 \(\Delta \), \(+\), \(\times \), \(0\), \(1\) \((f,f)\), and adjoints of \(\Delta \) and \(!\)
5 \(\mathbf {Alg}(1+X)\) \(F(\mathrm {id})=\mathrm {id}\)
6 initial algebra, \(\mathrm {End}=\{\mathrm {id}\}\) left adjoint into \(\mathbf 1\); \(\mathrm {Free}(0)\)
7 Lambek \(\alpha \circ u\in \mathrm {End}=\{\mathrm {id}\}\)
8 \(\mathbb N\cong 1+\mathbb N\), \(0\), \(S\), Peano Lambek, \(+\dashv \Delta \)
9 \(\mathsf {fold}\), its equations, uniqueness transpose \(\psi (!_X)\)
10 induction \(m\circ u\in \mathrm {End}=\{\mathrm {id}\}\)

Only the existence of \(\mathrm {Free}\) is declared. At Steps 6, 7, 9 and 10 the decisive move is the same: an endomorphism of the initial algebra is the identity.