Injective if and only if Left Inverse Exists (Proof Verification)

elementary-set-theorysolution-verification

So, here's the question that I'm trying to do.

Let A and B be sets. Let $f:A \to B$ be a function. Show that $f$ is injective iff there exists a function $g:B \to A$ such that $gf = id_A$.


Let us prove the backwards direction first. Suppose that there does exist a function $g:B \to A$ such that $gf = id_A$. Let $f(a_1) = f(a_2)$, where $a_1,a_2 \in A$. Since g is a function, it follows that every element in B has a unique image in A. Hence, $a_1 = a_2$. This proves that f is injective.

Now, we suppose that f is injective. Then, we want to show that there exists a function $g:B \to A$.

We define a relation $g:B \to A$ as some subset of $A \times B$. We have to show that g is well-defined and that it is totally defined.

Suppose that $(b,a_1) \in g \land (b,a_2) \in g$. This implies that $a_1 = a_2$ because of the injectivity of f. Hence, g is well-defined. Now, if g is totally defined, then every element in B has an image in A.

Now, here's where I'm stuck. I'm not quite sure how to show that g is totally defined.

Best Answer

It is not true in general that an injective function $f:A\to B$ has a left inverse $g:B\to A$.

Counterexample: If $A=\varnothing$ then we have the empty function $\varnothing\to B$ which is (vacuously) injective. However if $B\neq\varnothing$ then a function $g:B\to\varnothing$ does not exist.

If $A=\varnothing=B$ then we can take the empty function for $g$ so in that case there is a left inverse.

Also if $A\neq\varnothing$ an injective function $f:A\to B$ has a left inverse, which can constructed as follows:

Let $a_0\in A$.

If $b=f(a)$ for some $a\in A$ then let $g(b)=a$ and if $b$ is not in the range of $f$ then let $g(b)=a_0$.

It can easily be verified that $g\circ f=\mathsf{id}_A$ if $f$ is injective.