I've already done a lot of searching (in particular: https://www.proofwiki.org/wiki/Injection_iff_Left_Inverse) to try to prove this statement:
$f: A \to B$ is injective if and only if it has a left inverse. [I'm going to also assume $A$ and $B$ are nonempty.]
My attempt so far:
$\Leftarrow$ Suppose $f$ has a left inverse and $f(a_1) = f(a_2)$ for $a_1, a_2 \in A$. Then there is a function $g: B \to A$ such that $g\left(f(a_1)\right) = a_1$ and $g\left(f(a_2)\right) = a_2$. Since $g$ is well-defined, it follows that $g\left(f(a_1)\right) = g\left(f(a_2)\right)$, and hence $a_1 = a_2$.
$\Rightarrow$Now suppose $f$ is injective. Then $f(a_1) = f(a_2) \implies a_1 = a_2$. Furthermore, since $A$ is nonempty, there is an element $x \in A$. Define $g: B \to A$ by \begin{equation*} g(b) = \begin{cases} f^{-1}(b), & b \in \text{Im}(f) \\ x, & b \in A \setminus \text{Im}(f)\text{.} \end{cases} \end{equation*} This mapping is well-defined, since if $f$ is injective, $f^{-1}(b)$ is unique.
My main question: does this imply that if $f: A \to B$ is injective that any mapping $g: \text{Im}(f) \to A$ is bijective? Otherwise, I don't understand why we can even use $f^{-1}$ on an element. [Please read the link above for more details - in proof 1.]