Left Inverse: An Analysis on Injectivity I'm told that $g$ is a left inverse of $f$ if $g\circ f=1_X$. I'm also told that if $f$ has a left inverse, then $f$ must be injective. I'm now asked to prove the converse, namely that if $f:X\rightarrow Y$ is injective, then there exists a function $g:Y\rightarrow X$ such that $g\circ f =1_X$. Where might I start here?
 A: One way to think about injective functions is that they preserve information in the domain. Suppose $f:X\to Y$ is injective, then we can tell whether $x=y\in X$ just by looking at whether $f(x)=f(y)\in Y$, so we see the information about points in the domain are preserved by this mapping.
Then it follows easily that such functions have left-inverses, because since all information in the domain is preserved in the image, then we can get the domain from the image. This is what a left-inverse does.
Following this philosophy, we might just define this $g: Y\to X$ on two pieces. On $f(X)$, we define $g(y)=x$ where $f(x)=y$. On $Y\backslash f(X)$, we just pick an arbitrary point $x^*\in X$ and let $g$ maps constantly to this $x^*$.
A: Assume $X$ is not empty. If $f:X\to Y$ is injective define $g:Y\to X$ by $g(y)=x$ if $y=f(x)$ and define it arbitrarily on the rest of $Y$. With this definition we have that
$g(f(x))=x$ by definition. so $gof=Id_X$
A: Since $f: X \to Y$ is an injection, it is a bijection onto its image.   Hence, there is an inverse $h: f(X)  \to X$.  Choose a point $x \in X$.   Define $g: Y \to X$ by
$$
g(y) =
\begin{cases}
h(y) & \text{if } y \in f(X) \\
x & \text{otherwise}
\end{cases}
$$
