# $f$ is a function, show that if $g \circ f=id_S$ and $f \circ h=id_T$, then $f$ is bijective and $g=h=f^{-1}$

Full question: Let $S$ and $T$ be sets and let $f:S \rightarrow T$ be a function. Prove the following statements:

(a) If U is a set and g : T → U is a function such that g ◦ f is injective then also f is injective.

(b) If R is a set and h: R → S is a function such that f ◦ h is surjective then also f is surjective.

(c) Show that if g, h: T → S are functions satisfying g ◦ f = $id_S$ and f ◦ h = $id_T$ then f is bijective and $g=h=f^{-1}$. (Use (a) and (b)).

I was able to show (a) and (b), and for (c) I was able to show $f$ is bijective like so:

$g \circ f=id_S$ is injective (identity function), then $f$ is also injective according to (a). Similarly $f \circ h=id_T$ is surjective (again, identity function), then $f$ is also surjective according to (b). Therefore, $f$ is bijective.

Now to show $g=h=f^{-1}$, I am having a little trouble. This is my reasoning so far:

$\forall a \in S$, $g \circ f(a)=a$, but same is true for $f^{-1} \circ f(a)$ then $g=f^{-1}$.

$\forall b \in T$, $f \circ h(b)=b$, but same is true for $f \circ f^{-1}(a)$ then $h=f^{-1}$.

I think my above reasoning is not good enough. I feel I need to use the fact that $f$ is bijective somewhere.

Can anyone please point me to the right direction?

If you want to show that $g = h$, then we want to show that for each $x$, we have that $g(x) = h(x)$. Here is an argument: $$g(x) = g(\color{red}{f \circ h}(x)) = \color{blue}{g \circ f}(h(x)) = h(x)$$
where, I highlight that $f \circ h$ and $g \circ f$ are the identity maps by what we have already proved, in red and blue colors respectively. Therefore, $g = h$, so both are left and right inverses of $f$ and hence equal to $f^{-1}$.
What you've observed is \begin{align} g \circ f &= \mathrm{id}_S = f^{-1} \circ f \\ f \circ h &= \mathrm{id}_T = f \circ f^{-1} \end{align} To finish the argument, you could take the first equation, and compose on the left, both sides, by $f^{-1}$. Then, $$g \circ f \circ f^{-1} = f^{-1} \circ f \circ f^{-1} \implies g \circ \mathrm{id}_T = f^{-1} \circ \mathrm{id}_T \implies g = f^{-1}.$$ Similarly for the other one: compose by $f^{-1}$ on the right.