I'm trying to prove the following: Let $S$ and $T$ be sets and $f: S \rightarrow T$. Show that $f$ is a bijection iff there is a mapping $g: T \rightarrow S$ such that $f \circ g$ and $g \circ f$ are the identity mappings on $T$ and $S$, respectively.
Here's my proof:
Forward implication:Assume $f$ is a bijection. Then it's invertible and we have $f \circ f^{-1} = \text{id}_T$ and $f^{-1} \circ f = \text{id}_S$.
Reverse implication: Assume there is a mapping $g: T \rightarrow S$ such that $f \circ g = \text{id}_T$ and $g \circ f = \text{id}_S$. Assume $f$ is not injective. So $\exists x, y \in S \text{ with } f(x) = f(y) \text{ and } x \ne y$. This means $g(f(x)) = g(f(y))$, which is a contradiction since $x \ne y$ and $g \circ f = \text{id}_S$.
Now assume $f$ is not surjective, which means $\exists b \in T \ \forall a \in S \text{ such that } f(a) \ne b$. This means $f$ is not defined at $g(b)$, so $f \circ g \ne \text{id}_T$, which is a contradiction.
We've shown that $f$ is injective and surjective, so it is a bijection. $\blacksquare$
My questions are: Is this proof correct and satisfactory? Is there a better/simpler way to go about it?
Thanks in advance