I'm learning Category Theory by Steve Awodey's book. in the exercise 11 we have :
- Show that the free monoid functor $$ M: \text { Sets } \rightarrow \text { Mon } $$ exists, in two different ways:
(a) Assume the particular choice $M(X)=X^{*}$ and define its effect $$ M(f): M(A) \rightarrow M(B) $$ on a function $f: A \rightarrow B$ to be $$ M(f)\left(a_{1} \ldots a_{k}\right)=f\left(a_{1}\right) \ldots f\left(a_{k}\right), \quad a_{1}, \ldots a_{k} \in A . $$
(b) Assume only the UMP of the free monoid and use it to determine $M$ on functions, showing the result to be a functor. Reflect on how these two approaches are related.
solution :
(a) The functor $M:$ Sets $\rightarrow$ Mon that takes a set $X$ to the free monoid on $X$ (i.e., strings over $X$ and concatenation) and takes a function $f: X \rightarrow Y$ to the function $M(f)$ defined by $M(f)\left(a_{1} \ldots a_{k}\right)=f\left(a_{1}\right) \ldots f\left(a_{k}\right)$ is a functor; $M(f)$ is a monoid homomorphism $M X \rightarrow M Y$ since it preserves the monoid identity (the empty string) and the monoid operation (composition). It can be checked that $M$ preserves identity functions and composition: $M\left(1_{X}\right)\left(a_{1} \ldots a_{k}\right)=1_{X}\left(a_{1}\right) \ldots 1_{X}\left(a_{k}\right)=a_{1} \ldots a_{k}$ and $$ \begin{gathered} M(g \circ f)\left(a_{1} \ldots a_{k}\right)=(g \circ f)\left(a_{1}\right) \ldots(g \circ f)\left(a_{k}\right) \\ =g\left(f\left(a_{1}\right)\right) \ldots g\left(f\left(a_{k}\right)\right)=M(g)\left(M(f)\left(a_{1} \ldots a_{k}\right)\right) \\ =(M(g) \circ M(f))\left(a_{1} \ldots a_{k}\right) . \end{gathered} $$
how we can solve 'b'? Reflect on how these two approaches are related.
Hint The free monoid $M(B)$ comes with a certain map $\eta_B:B \to M(B)$ that is related to the universal property. Now apply the universal property of $M(A)$ to the composition $A \xrightarrow{f} B \to M(B)$
Edit: Second Hint For the functoriality $M(g \circ f)=M(g) \circ M(f)$, where $A \xrightarrow{f} B \xrightarrow{g} C$. Consider the two maps $A \to M(C)$: on the one hand we have $M(g \circ f) \circ \eta_A$, on the other hand we have $M(g) \circ M(f) \circ \eta_A$. Now try to show that $M(g \circ f) \circ \eta_A=M(g) \circ M(f) \circ \eta_A$ (further hint: the definition of the universal property that was used to define $M(f)$ tells you that $M(f)\circ \eta_A=\eta_B \circ f$, try to apply this for $M(f), M(g)$ and $M(g\circ f)$) and use the uniqueness part of the universal property of $M(A)$ to conclude.