Kleene Closure is Free Monoid

Theorem
Let $S$ be a set.

Let $S^*$ be its Kleene closure, and let $i: S \to S^*$ be the insertion of generators.

Then $\left({S^*, i}\right)$ is a free monoid over $S$.

Proof
By Kleene Closure is Monoid, $S^*$ is a monoid.

It remains to verify the universal property.

Existence
Let $\left({N, \circ}\right)$ be a monoid with identity $e_N$, and let $\left\vert{N}\right\vert$ be its underlying set.

Let $f: S \to \left\vert{N}\right\vert$ be a mapping.

Define $\bar f: S^* \to N$ by:


 * $\bar f \left({-}\right) := e_N$
 * $\bar f \left({\left\langle{s_1, \ldots, s_n}\right\rangle}\right) := f \left({s_1}\right) \circ \cdots \circ f \left({s_n}\right)$

The first condition is precisely saying that $\bar f$ preserves identity elements, and by:

it follows that $\bar f$ is a monoid homomorphism.

It also satisfies:


 * $\bar f \circ i \left({s}\right) = \bar f \left({\left\langle{s}\right\rangle}\right) = f \left({s}\right)$

and hence meets the set requirements.

Uniqueness
It remains to verify the uniqueness of $\bar f$.

So let $g: S^* \to N \in \mathbf{Mon}_1$ be a monoid homomorphism such that for all $s \in S$:

$g \circ i \left({s}\right) = f \left({s}\right)$

Then for any $\left\langle{s_1, \ldots, s_n}\right\rangle \in S^*$, compute:

Hence $\left({S^*, i}\right)$ is a free monoid for $S$.