Left and Right Inverses of Mapping are Inverse Mapping

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$.