This is a very delicate point about the context of domain and codomain, which in set theory exist as an external properties we give functions, rather than internal properties of them (as in category theory).
This means that we first fix some domain and codomain and we can talk about functions from $A$ to $B$. Now we can say that $f$ is surjective if its range is all $B$. Note that without this context there is no codomain, and every function is onto its range, therefore the term "surjective" is meaningless.
Now when we say that a function $f$ has a right inverse we mean that there is $g\colon B\to A$ such that $f\circ g=\text{id}_B$. When we say that $f$ has a left inverse we mean there is such $g\colon B\to A$ for which $g\circ f=\text{id}_A$. Without the axiom of choice we can prove that if a function has a right inverse then it is surjective, and that $f$ is injective if and only if it has a left inverse.
The axiom of choice is equivalent to saying that whenever $A$ and $B$ are two sets, the $f$ is a surjective function if and only if it has a right inverse. But we had set the context first. Of course we can omit it, because we are talking about any set, so we may as well replace $B$ by the range of $f$. But some context must be set for otherwise the term "surjective" is meaningless.
On the other hand, the very basic theorem that $f\colon A\to B$ has an inverse if and only if it is a bijection has nothing to do with the axiom of choice. The statement is really saying that $f$ is a bijection if and only if there is some $g\colon B\to A$ which is both right and left inverse of $f$. From the above remarks you can see that without the axiom of choice if there is an inverse (both left and right, that is) then the function is a bijection; but if it is a bijection then we can construct its left inverse and show that it is also a right inverse.
Your assertions about empty sets are incorrect.
Recall that a function from a set $X$ to a set $Y$ is a subset $f\subseteq X\times Y$ such that
- For all $x\in X$ there exists $y\in Y$ such that $(x,y)\in f$;
- If $(x,y),(x,y’)\in f$ for $x\in X$ and $y,y’\in Y$, then $y=y’$.
The function is injective if and only if for all $x,x’\in X$ and $y\in Y$, if $(x,y),(x’,y)\in f$, then $x=x’$.
The function is surjective if and only if for all $y\in Y$ there exists $x\in X$ such that $(x,y)\in f$.
If $X$ is empty, and $Y$ is any set, empty or not, the empty set $\varnothing\subseteq \varnothing\times Y = X\times Y$ satisfies the definition of being a function from $X=\varnothing$ to $Y$, hence is a function. Moreover, it satisfies the definition of being injective, hence is injective: there is always a function from the empty set to any set, and it is always injective.
However, that function only has a left inverse when the codomain is empty. So the statement you are trying to prove about injective functions is not quite true as written: you must exclude $X=\varnothing$ in order for it to be true.
That said, I applaud that you recognized the need to deal with the possibility of empty sets. Many people forget about that (for example, whoever wrote this problem up did!)
Your proof of (a) is correct; but you need to take into account the case where $X=\varnothing$. In this case, you can conclude from surjectivity that $Y=\varnothing$, and from the existence of a right inverse that $Y=\varnothing$.
As to “defining” the right inverse... In the nonempty sets dcadse, the “better way” of specifying the right inverse is to explicitly use the Axiom of Choice. For example, one formulation of the Axiom of Choice is that given any nonempty family of nonempty sets $\{A_i\}_{i\in I}$, there exists a function $g\colon I\to \cup A_i$ such that $g(i)\in A_i$ for each $i$. So you could take the family $\{A_y\}_{y\in Y}$, with $A_y=f^{-1}(\{y\})$, and just verify that a function $g\colon Y\to \cup A_y$ that you obtain from the Axiom of Choice is a right inverse for $f$. This is going to be the best you can do, at least for arbitrary sets.
Your example of non-uniqueness suffices; though in general you can show that the function has multiple right inverses if and only if it is not injective, that is not required.
For (b), the forward direction is fine (since we have assumed $X\neq\varnothing$. I would say the backward direction is fine, though I would note that $x_0$ exists because we are assuming that $X$ is not empty. Again, your example of nonuniqueness is fine. One can prove that the left inverse is unique if and only if $f$ is bijective, but you are not required to do so.
Best Answer
Your if and only if proof looks pretty good to me. However your non-uniqueness proof is a bit flimsy.
To prove non-uniqueness it is sufficient (and almost always easier) to show it by an example. You can cook up any example but here is the first one that came to my head.
Suppose that $X=\mathbb{R}^2$ and $Y=\mathbb{R}$ with $f:X\to Y$ being $f(x,y)=x$. Clearly this function is onto. Now define the following map $S_1:Y\to X$ by $S_1(x)=(x,0)$. It shouldn't take much to convince you that $f(S_1(x))=i_Y$.
In addition the map $S_2:Y\to X$ defined by $S_2(x)=(x,x)$ will also give $S_2(f(x))=i_Y$. But $S_1\neq S_2$ so we have shown that there are two functions that produce the desired result that are not the same (and hence the inverse need not be unique).