Set of all Self-Maps under Composition forms Semigroup

Theorem
Let $S$ be a set.

Let $S^S$ be the set of all mappings from $S$ to itself.

Let the operation $\circ$ represent composition of mappings.

Then the algebraic structure $\left({S^S, \circ}\right)$ is a semigroup.

Proof
Let $f, g \in S^S$.

As the domain of $g$ and codomain of $f$ are the same, the composition $f \circ g$ is defined.

By the definition of composition, $f \circ g$ is a mapping from the domain of $g$ to the codomain of $f$.

Thus $f \circ g: S \to S$, so $f \circ g \in S^S$.

Since this holds for all $f, g \in S^S$, $\left({S^S, \circ}\right)$ is closed.

By Composition of Mappings is Associative, $\circ$ is associative.

Since $\left({S^S, \circ}\right)$ is closed and $\circ$ is associative:


 * $\left({S^S, \circ}\right)$ is a semigroup.