Let $M$ be a monoid of functions on a base set X. Define $S$ = {$f$: $X$ $\to$ $X$ | $m$ $\circ$ $f$ $=$ $id_X$ for some $m$ $\in$ $M$}. Show that $S$ is a monoid of functions on $X$.
Attempt: I am confused about verifying even the closure axiom. So, I have taken two arbitrary functions $g$, $h$ $\in$ $S$ and to show that $S$ is closed, I think I have to verify that $m$ $\circ$ ($g$ $\circ$ $h$) $=$ $id_X$. What I did was following:
Let $s$ $\in$ $X$ be an arbitrary element in X. Then, to show closure I should show: $m$ $\circ$ ($g$ $\circ$ $h$) ($s$) $=$ $s$. Following by idea, I got, $m$ $\circ$ ($g$ $\circ$ $h(s$)) $=$ ($m$ $\circ$ $g$) $\circ$ $h$ ($s$) $=$ $id_X$ $\circ$ $h(s)$ = $h(s)$. I do not know what I am doing wrong, but I am not being able to verify closure. What am I doing wrong here?
You need to show $g \circ h \in S$, on the basis that $g, h \in S$. Your error is assuming that there is one $m$ such that $m \circ g$ and $m \circ h$ are both simultaneously equal to $\operatorname{id}_X$, and requiring that this same $m$ work for $g \circ h$ too.
Instead, you may assume $m \circ g$ and $n \circ h$ are both equal to $\operatorname{Id}_X$, where $m, n \in M$, and construct a different $p \in M$ such that $p \circ (g \circ h) = \operatorname{Id}_X$. The construction of $p$ will have to feature both $m$ and $n$. I'll leave the rest to you.