What does $x_0$ means when an element is not an image of an injective function?

I have a question about this theorem and its proof:

Theorem

Let $f \in \mathcal{F}(A,B)$ be a function. $f$ is injective if and only if function $g \in \mathcal{F}(B,A)$ exists such that $g \circ f$ = ${I}_{A}$.

Proof

If $f$ is injective then for each $y \in Im(f)$ the set $f^{-1}(y)$ is an unitary set and the unique element of $f^{-1}(y)$ is denoted by $a_y$, it's true that $a_{f(x)} = x$. Let $x_0$ be a fixed element of $A$. We define: \begin{align*} g \colon B &\to A\\ y &\mapsto g(y) = \begin{cases} a_y & \text{if $y \in Im(f)$} \\ x_0 & \text{if $y \notin Im(f)$} \end{cases} \end{align*} Then, $g \circ f(x) = g(f(x)) = a_{f(x)} = x$ for each $x \in A$.

Reciprocally, if function $g \in \mathcal{F}(B,A)$ exists such that $g \circ f = I_A$, suppose that $x_1$, $x_2$ exists such that $f(x_1) = f(x_2)$, then $x_1 = (g \circ f)(x_1) = g(f(x_1)) = g(f(x_2)) = (g \circ f)(x_2) = x_2$.

Then $f$ is injective. QED.

Example

What happens when $y \notin Im(f)$? In the example $white$ is not in the image set of $f$, my doubt is what really means that fixed $x_0$? what happens when you use $white$ as input in function $g$? $g(white) = {x_0}$?

• $x_0$ is an arbitrary value of $A.$ In your example it can be $x_0=1,$ $x_0=2$ or $x_0=3.$ It will change the definition of the function $g$ but $g$ has not to be unique. – mfl Aug 8 '18 at 22:18

I presume that your confusion is regarding the $(g \circ f$ = ${I}_{A}) \rightarrow (f \text{ is injective})$ part. In that case, the matter of $y$ such that $y$ is not in Im($f$) is immaterial. If you're trying to determine whether $f$ is injective, then all that matter is $a_0 \neq a_1 \rightarrow f(a_0) \neq f(a_1)$. The question of what happens when $y$ is not in Im($f$) doesn't matter, because it can't possibly affect whether $f(a_0) = f(a_1)$; both $f(a_0)$ and $f(a_1)$ are, by definition, in Im($f$). In your example, you can send $white$ to anything you want; it won't affect whether $f$ is injective. Whether $f$ is injective depends only on where the arrows in the left side of your diagram go. Where the arrows on the right side go is irrelevant.
The theorem needs the hypothesis that $A$ isn't empty; it's false if $A=\varnothing\neq B$. But once we include that hypothesis, we can let $x_0$ be any element of $A$. There may be many possibilities for this $x_0$, but there is at least one, and that's all we need. Each such $x_0$ yields a function $g$ with the required property. So, from the fact that there is at least one $x_0\in A$ (because of the assumption that $A\neq\varnothing$), it follows that there is at least one $g$ as required.