Left and Right Inverses of Mapping are Inverse Mapping/Proof 2

Theorem
Let $f: S \to T$ be a mapping such that:


 * $\exists g_1: T \to S: g_1 \circ f = I_S$
 * $\exists g_2: T \to S: f \circ g_2 = I_T$

Then:
 * $g_1 = g_2 = f^{-1}$

where $f^{-1}$ is the inverse of $f$.

Proof
From Left and Right Inverse Mappings Implies Bijection, we have that $f$ is a bijection.

Let $y \in T$ and let $x = f^{-1} \left({y}\right)$.

Such an $x$ exists because $f$ is surjective, and unique within $S$ as $f$ is injective.

Then $y = f \left({x}\right)$ and so:

So $f^{-1} = g_1$.

Also:

So $f^{-1} = g_2$.