45 Associativity, again: six routes as corollaries

Associativity follows from six results already in the chain, each in one step:

Route Associativity is
path induction \(\mathsf J\) reducing the last path to \(\mathsf {refl}\)
substitution successive substitution, embedded by Cayley and Yoneda
the swap exchanging the order of a double sum
universality two universal objects for the same diagram
adjunction naturality of the counit, as the monad law
idempotents meets of commuting cuts

A1 (path induction). For paths \(p:a=b\), \(q:b=c\), \(r:c=d\), prove \((p\cdot q)\cdot r=p\cdot (q\cdot r)\) by induction on \(r\). When \(r\equiv \mathsf {refl}_c\), both sides reduce to \(p\cdot q\), since concatenation with \(\mathsf {refl}\) is the identity. By \(\mathsf J\), the equation holds for all \(r\). Associativity follows from \(\mathsf {refl}\) and its elimination rule alone.

A2 (substitution). For functions,

\begin{equation} \bigl ((h\circ g)\circ f\bigr )(x)=h\bigl (g(f(x))\bigr )=\bigl (h\circ (g\circ f)\bigr )(x): \tag{964}\end{equation}
both are the same successive substitution. Every unital multiplication embeds into functions by \(a\mapsto L_a\), \(L_a(x)=ax\) (Cayley), and every category into presheaves by Yoneda, so composition is associative wherever such an embedding exists. In particular, matrices are associative because they are linear maps.

A3 (the swap of a double sum). For matrices,

\begin{equation} \bigl ((AB)C\bigr )_{ad}=\sum _c\Bigl (\sum _bA_{ab}B_{bc}\Bigr )C_{cd}, \qquad \bigl (A(BC)\bigr )_{ad}=\sum _bA_{ab}\Bigl (\sum _cB_{bc}C_{cd}\Bigr ). \tag{965}\end{equation}
By distributivity both are sums of \(A_{ab}B_{bc}C_{cd}\) over pairs \((b,c)\), in the two orders. They agree because finite sums may be reordered: commutativity of addition, the swap of summands. For relations the sums are disjunctions; for categories they are disjoint unions.

A4 (universality). In an order, \((a\wedge b)\wedge c\) and \(a\wedge (b\wedge c)\) are both the greatest lower bound of \(\{a,b,c\}\): each is below \(a,b,c\), and anything below all three is below each. Two greatest lower bounds are below each other, so they are equal by antisymmetry. In a category, \((A\times B)\times C\) and \(A\times (B\times C)\) both represent

\begin{equation} X\mapsto \mathrm {Hom}(X,A)\times \mathrm {Hom}(X,B)\times \mathrm {Hom}(X,C), \tag{966}\end{equation}
so they are isomorphic by a unique isomorphism: the only endomorphism of a universal object is the identity.

A5 (adjunction). For \(F\dashv G\) with \(T=GF\) and \(\mu =G\varepsilon F:TT\to T\),

\begin{equation} \mu \circ T\mu =\mu \circ \mu T, \tag{967}\end{equation}
because both equal \(G(\varepsilon \circ F G\varepsilon )F=G(\varepsilon \circ \varepsilon FG)F\), an instance of naturality of \(\varepsilon \) applied to the arrow \(\varepsilon \) itself. For the free monoid, \(\mu \) flattens a list of lists, and the law says that a list of lists of lists flattens to the same list whichever level is flattened first: associativity of joining rows.

A6 (idempotents). For commuting cuts, the product is the meet:

\begin{equation} ef=e\wedge f, \tag{968}\end{equation}
the largest cut below both. Associativity of the product of commuting cuts is then A4. In the other direction, the order \(e\le f\iff fe=e\) is transitive because the product is associative, so for cuts the two facts support each other.

Coherence. Once one associativity holds, all bracketings of \(n\) factors agree: any two are related by rebracketings, and each rebracketing is the identity in the cases above. For associativity up to isomorphism, Mac Lane’s pentagon guarantees the same.

The routes compared.

Route Where it holds Primitive used
A1 identity types, paths \(\mathsf {refl}\), \(\mathsf J\)
A2 functions, Cayley and Yoneda images substitution
A3 matrices, relations, categories reordering a sum
A4 meets, products uniqueness of universal objects
A5 monads, free monoids naturality of the counit
A6 commuting cuts idempotents, meet

45.1 Commutativity, distributivity and associativity in one cascade

Starting from the identity, one cascade constructs the product and the sum, and derives the three laws:

Each tool is derived before it is used. The laws then pass to meets in orders, to the natural numbers by counting, and to matrices.

C0 (identity). For each object \(A\) there is \(\mathrm {id}_A\) with \(\mathrm {id}\circ f=f=f\circ \mathrm {id}\).

C1 (diagonal). Pairing the identity with itself gives \(\Delta _A=\langle \mathrm {id}_A,\mathrm {id}_A\rangle \), the functor \(A\mapsto (A,A)\).

C2 (product). The product of \(A\) and \(B\) is an object \(A\times B\) with projections \(\pi _1,\pi _2\) such that for all \(f:X\to A\), \(g:X\to B\) there is exactly one \(\langle f,g\rangle :X\to A\times B\) with \(\pi _1\langle f,g\rangle =f\) and \(\pi _2\langle f,g\rangle =g\):

\begin{equation} \mathrm {Hom}(X,A\times B)\cong \mathrm {Hom}(X,A)\times \mathrm {Hom}(X,B), \tag{969}\end{equation}
the right adjoint of \(\Delta \). In sets, \(A\times B\) is the set of pairs. Uniqueness gives \(\langle \pi _1,\pi _2\rangle =\mathrm {id}_{A\times B}\), since the identity has components \(\pi _1,\pi _2\).

C3 (sum). Dually, \(A+B\) with injections satisfies

\begin{equation} \mathrm {Hom}(A+B,X)\cong \mathrm {Hom}(A,X)\times \mathrm {Hom}(B,X), \tag{970}\end{equation}
the left adjoint of \(\Delta \). In sets, the disjoint union.

C4 (Yoneda lemma). For a presheaf \(F\),

\begin{equation} \mathrm {Nat}\bigl (\mathrm {Hom}(-,A),F\bigr )\cong F(A), \qquad \eta \mapsto \eta _A(\mathrm {id}_A). \tag{971}\end{equation}
For \(f:X\to A\), \(f=\mathrm {id}_A\circ f\), so naturality gives \(\eta _X(f)=F(f)(\eta _A(\mathrm {id}_A))\): \(\eta \) is fixed by where it sends the identity. Conversely, each \(x\in F(A)\) defines \(f\mapsto F(f)(x)\).

C5 (representing objects are unique). Taking \(F=\mathrm {Hom}(-,B)\) in C4,

\begin{equation} \mathrm {Nat}\bigl (\mathrm {Hom}(-,A),\mathrm {Hom}(-,B)\bigr )\cong \mathrm {Hom}(A,B). \tag{972}\end{equation}
A natural isomorphism \(\mathrm {Hom}(-,A)\cong \mathrm {Hom}(-,B)\) therefore comes from a unique isomorphism \(A\cong B\). Dually for \(\mathrm {Hom}(A,-)\).

C6 (the swap is an involution). Let \(\sigma =\langle \pi _2,\pi _1\rangle :A\times B\to B\times A\). The composite \(\sigma \circ \sigma \) has components \(\pi _1\) and \(\pi _2\), so by uniqueness in C2,

\begin{equation} \sigma \circ \sigma =\langle \pi _1,\pi _2\rangle =\mathrm {id}. \tag{973}\end{equation}

C7 (commutativity). By C6, \(\sigma \) is an isomorphism with inverse \(\sigma \):

\begin{equation} A\times B\cong B\times A . \tag{974}\end{equation}
Equivalently, \(\mathrm {Hom}(X,A)\times \mathrm {Hom}(X,B)\cong \mathrm {Hom}(X,B)\times \mathrm {Hom}(X,A)\) by swapping the pair, and C5 converts this into the isomorphism of objects. The same holds for \(+\).

C8 (adjunction). An adjunction \(L\dashv R\) is a natural bijection \(\mathrm {Hom}(LA,B)\cong \mathrm {Hom}(A,RB)\). Its unit and counit are the transposes of identities, and transposing twice returns, which gives the triangle identities.

C9 (currying). In sets, a function of two arguments is a function into functions:

\begin{equation} \mathrm {Hom}(A\times B,C)\cong \mathrm {Hom}(A,C^B), \qquad f\mapsto \bigl (a\mapsto f(a,-)\bigr ), \tag{975}\end{equation}
natural in \(A\) and \(C\). So \(-\times B\) is left adjoint to \((-)^B\), with counit the evaluation \(C^B\times B\to C\).

C10 (left adjoints preserve sums). For \(L\dashv R\) and any \(X\),

\begin{equation} \mathrm {Hom}(L(B+C),X)\cong \mathrm {Hom}(B+C,RX)\cong \mathrm {Hom}(B,RX)\times \mathrm {Hom}(C,RX)\cong \mathrm {Hom}(LB+LC,X), \tag{976}\end{equation}
naturally in \(X\). By C5, \(L(B+C)\cong LB+LC\).

C11 (distributivity). Applying C10 to \(L=A\times -\), a left adjoint by C9,

\begin{equation} A\times (B+C)\cong A\times B+A\times C, \qquad A\times 0\cong 0 . \tag{977}\end{equation}

C12 (associativity). For every \(X\),

\begin{equation} \mathrm {Hom}\bigl (X,(A\times B)\times C\bigr )\cong \mathrm {Hom}(X,A)\times \mathrm {Hom}(X,B)\times \mathrm {Hom}(X,C)\cong \mathrm {Hom}\bigl (X,A\times (B\times C)\bigr ), \tag{978}\end{equation}
naturally in \(X\), by applying C2 twice on each side. By C5,
\begin{equation} (A\times B)\times C\cong A\times (B\times C), \tag{979}\end{equation}
by a unique isomorphism. The same argument with C3 gives associativity of \(+\).

C13 (meets in orders). In an order, regarded as a category with at most one arrow between two objects, the product is the meet \(a\wedge b\) and the sum is the join \(a\vee b\). Isomorphic objects of an order are equal, so C7, C11 and C12 become

\begin{equation} a\wedge b=b\wedge a, \qquad a\wedge (b\vee c)=(a\wedge b)\vee (a\wedge c), \qquad (a\wedge b)\wedge c=a\wedge (b\wedge c), \tag{980}\end{equation}
the second whenever \(a\wedge -\) has a right adjoint \(a\Rightarrow -\), as in a Heyting algebra.

C14 (numbers). For finite sets, \(|A\times B|=|A|\,|B|\) and \(|A+B|=|A|+|B|\), and isomorphic sets have equal size. Taking sizes in C7, C11 and C12,

\begin{equation} \begin {gathered} mn=nm, \qquad m(n+k)=mn+mk, \qquad (mn)k=m(nk),\\ m+n=n+m, \qquad (m+n)+k=m+(n+k). \end {gathered} \tag{981}\end{equation}
C15 (matrices). Matrix multiplication sums over the matched middle index. Distributivity (C14) expands both bracketings into sums of \(A_{ab}B_{bc}C_{cd}\), and commutativity of addition (C14) reorders the double sum:
\begin{equation} \sum _c\Bigl (\sum _bA_{ab}B_{bc}\Bigr )C_{cd}=\sum _{b,c}A_{ab}B_{bc}C_{cd}=\sum _bA_{ab}\Bigl (\sum _cB_{bc}C_{cd}\Bigr ). \tag{982}\end{equation}

The cascade.

Step Result From
C0–C1 identity, diagonal —
C2–C3 product, sum right and left adjoints of \(\Delta \)
C4–C5 Yoneda; uniqueness of representing objects the identity decides
C6–C7 swap involution; commutativity uniqueness of pairing
C8–C9 adjunction; currying transposing the identity
C10–C11 left adjoints preserve sums; distributivity C5, C9
C12 associativity C2 twice, C5
C13 lattice laws orders as categories
C14 laws of \(\mathbb N\) sizes of finite sets
C15 associativity of matrices distributivity, reordering

45.2 Arithmetic in one cascade: currying, \(\mathbb N\), operations and the ring axioms

The three operations of arithmetic are sizes of three universal constructions built from the diagonal:

Operation Construction Adjunction
\(m+n\) sum \(A+B\) left adjoint of \(\Delta \)
\(mn\) product \(A\times B\) right adjoint of \(\Delta \)
\(n^m\) function set \(B^A\) right adjoint of \(-\times A\) (currying)

The inverse operations, monus, quotient and integer logarithm, are right adjoints in the order of \(\mathbb N\). The ring \(\mathbb Z\) arises from pairs, with negation the swap, and its axioms are inherited from \(\mathbb N\).

N0 (identity, diagonal, sum, product). From \(\mathrm {id}\) and \(\Delta =\langle \mathrm {id},\mathrm {id}\rangle \), the sum \(A+B\) and product \(A\times B\) are the left and right adjoints of \(\Delta \), with units \(0\) (initial: the empty set) and \(1\) (terminal: a single point).

N1 (currying). For sets, the map

\begin{equation} \Lambda :\mathrm {Hom}(A\times B,C)\to \mathrm {Hom}(A,C^B), \qquad \Lambda f(a)=f(a,-), \tag{983}\end{equation}
has inverse \(g\mapsto \bigl ((a,b)\mapsto g(a)(b)\bigr )\): a function of a pair is the same as a function into functions. \(\Lambda \) is natural in \(A\) and \(C\), so \(-\times B\dashv (-)^B\). The counit is evaluation, \(\mathrm {ev}(h,b)=h(b)\), and the triangle identity \(\mathrm {ev}\circ (\Lambda f\times \mathrm {id})=f\) is \(\beta \)-reduction.

N2 (natural numbers). Starting from \(0\) and adjoining one point at a time,

\begin{equation} \underline 0=\varnothing , \qquad \underline {n+1}=\underline n+1, \tag{984}\end{equation}
gives the finite sets up to isomorphism, the rows of marks. Their isomorphism classes are the natural numbers; collecting them into one object \(\mathbb N\) is the declaration of Infinity. Size is the class: \(|A|=n\) when \(A\cong \underline n\).

N3 (the operations).

\begin{equation} m+n=|\underline m+\underline n|, \qquad mn=|\underline m\times \underline n|, \qquad n^m=|\underline n^{\,\underline m}|. \tag{985}\end{equation}
These are well defined, since isomorphisms of the factors give isomorphisms of the constructions.

N4 (successor and recursion). \(\underline {n+1}=\underline n+1\) by N2, and associativity of \(+\) gives

\begin{equation} m+(n+1)=(m+n)+1, \qquad m(n+1)=mn+m, \qquad k^{n+1}=k^nk, \tag{986}\end{equation}
the last two by distributivity and by \(\mathrm {Hom}(A+1,C)\cong \mathrm {Hom}(A,C)\times C\). These are the recursive definitions of arithmetic, now theorems.

N5 (units and absorption).

Law Isomorphism
\(0+n=n\) \(\varnothing +A\cong A\)
\(1\cdot n=n\) \(1\times A\cong A\)
\(0\cdot n=0\) \(\varnothing \times A\cong \varnothing \)
\(n^0=1\) \(A^{\varnothing }\cong 1\), the empty function
\(n^1=n\) \(A^1\cong A\)
\(1^n=1\) \(1^A\cong 1\)
\(0^n=0\) for \(n\ge 1\) \(\varnothing ^A=\varnothing \) for \(A\neq \varnothing \)

N6 (commutative semiring). By the swap, distributivity and Yoneda (Subsection 45.1),

\begin{equation} m+n=n+m, \quad (m+n)+k=m+(n+k), \quad mn=nm, \quad (mn)k=m(nk), \quad m(n+k)=mn+mk . \tag{987}\end{equation}

N7 (exponent laws).

Law Isomorphism Source
\(c^{a+b}=c^ac^b\) \(\mathrm {Hom}(A+B,C)\cong \mathrm {Hom}(A,C)\times \mathrm {Hom}(B,C)\) sum
\((bc)^a=b^ac^a\) \(\mathrm {Hom}(A,B\times C)\cong \mathrm {Hom}(A,B)\times \mathrm {Hom}(A,C)\) product
\((c^b)^a=c^{ab}\) \(\mathrm {Hom}(A,C^B)\cong \mathrm {Hom}(A\times B,C)\) currying

N8 (order). \(m\le n\) when \(\underline m\) injects into \(\underline n\), equivalently \(n=m+k\) for some \(k\). Pairing two rows mark by mark gives trichotomy.

N9 (inverse operations as right adjoints).

Inverse Galois connection Left adjoint
monus \(m\mathbin {\dot -}n\) \(n+k\le m\iff k\le m\mathbin {\dot -}n\) \(+n\)
quotient \(\lfloor m/d\rfloor \), \(d\ge 1\) \(dk\le m\iff k\le \lfloor m/d\rfloor \) \(\times d\)
integer logarithm \(\lfloor \log _bm\rfloor \), \(b\ge 2\), \(m\ge 1\) \(b^k\le m\iff k\le \lfloor \log _bm\rfloor \) \(b^{(-)}\)
integer root \(\lfloor \sqrt [e]{m}\rfloor \) \(k^e\le m\iff k\le \lfloor \sqrt [e]{m}\rfloor \) \((-)^e\)

Division with remainder is the unit of the second: \(m=d\lfloor m/d\rfloor +r\) with \(0\le r<d\).

N10 (integers: the ring). Pairs \((a,b)\) of natural numbers, read \(a-b\), with \((a,b)\sim (c,d)\iff a+d=c+b\), form \(\mathbb Z\). The operations are forced by distributivity on \((a-b)(c-d)\):

\begin{equation} (a,b)+(c,d)=(a+c,\ b+d), \qquad (a,b)(c,d)=(ac+bd,\ ad+bc). \tag{988}\end{equation}

N11 (the ring axioms).

Axiom Source
additive group: \(0=[(a,a)]\), \(-(a,b)=(b,a)\) the diagonal; the swap
associativity, commutativity of \(+\) and \(\times \) inherited from N6, coordinatewise
distributivity inherited from N6
unit \(1=[(1,0)]\) N5
\((-1)(-1)=1\) \((0,1)(0,1)=(1,0)\): the swap twice, \(\sigma ^2=\mathrm {id}\)
\((-x)y=-(xy)\) \((b,a)(c,d)=\sigma \bigl ((a,b)(c,d)\bigr )\)

\(\mathbb Z\)is the group completion of \((\mathbb N,+)\): the universal way to make addition invertible.

N12 (beyond). Pairs \((p,q)\) with \(q\neq 0\), read \(p/q\), with the swap as reciprocal, give the field \(\mathbb Q\); completion gives \(\mathbb R\); doubling gives \(\mathbb C\).

The cascade.

Step Result From
N0 sum, product, \(0\), \(1\) adjoints of \(\Delta \)
N1 currying, evaluation functions of pairs
N2 finite sets, \(\mathbb N\) adjoining one point; Infinity
N3–N4 \(+\), \(\times \), exponentiation; recursion sizes; associativity
N5–N7 unit laws, semiring, exponent laws isomorphisms of constructions
N8–N9 order; monus, quotient, logarithm, root injections; right adjoints
N10–N11 \(\mathbb Z\), ring axioms pairs; swap
N12 \(\mathbb Q\), \(\mathbb R\), \(\mathbb C\) pairs, completion, doubling
\[ \boxed { \begin {array}{l} (-1)(-1)=(0,1)(0,1)=(0\cdot 0+1\cdot 1,\;0\cdot 1+1\cdot 0)=(1,0)=1\\[4pt] \text {\textbf {Swap twice = identity.}} \end {array} } \]