TITLE: Use of multi-valued function in proving the equivalence of surjectivity and existence of a right inverse
QUESTION [5 upvotes]: In Dummit and Foote's Abstract Algebra, the first two claims of Proposition 0.1 state that:

Let $f: A \rightarrow B$.

If $A \neq \emptyset$, the map $f$ is injective if and only if $f$ has a left inverse.

The map $f$ is surjective if and only if $f$ has a right inverse.



For $(1)$, if $f$ is injective, then we can construct a function $g: B \rightarrow A$ such that $\forall f(a) = b \in B$, we have the "reverse" mapping
$$g(b) = a$$
and by appealing to the injectivity of $f$, it follows that the composition map $g \circ f$ is in fact the identity map, so $f$ has a left inverse. Conversely, if we suppose that $f$ has a left inverse, then we can consider $a_1, a_2 \in A$ such that $a_1 = a_2$. Since $f$ has a left inverse, we can write $g(f(a_1)) = a_1$ and $g(f(a_2))=a_2 \implies g(f(a_1)) = g(f(a_2)) \implies f(a_1) = f(a_2)$ due to the fact that $g$ is a function.
In the case of $(2)$, we suppose that $f$ is surjective and construct a function $h: B \rightarrow A$ such that
$$h(b) \in \{a \in A : f(a) = b \}$$
i.e., considering reserve mapping of sorts where $h(b)$ can be any value $a$ where $f$ maps $a$ back to $b$. Thus $f$ has a right inverse. In the other direction, it is easy to show that the existence of a right inverse guarantees that $\forall b \in B$, $\exists a \in A$ such that $f(a) = b$, namely, $a = h(b)$, satisfying the definition of surjectivity.
My main concern deals with the construction of the relation $h$. By the set theoretic definition of function, we must have that no two ordered pairs in the relation $h$ have the same first element, but the very notion of having a multi-valued seems to contradict that definition. In other words, I am intuitively thinking of injectivity as an information preserving property, so one can have a reverse mapping without any ambiguities, but surjectivity is a property that results in information loss as multiple elements in $A$ could map to $b \in B$, and there being no well-defined way to map back to the original $a$ from $b$. I would like to verify if my reasoning above is correct, and by extension, if the proofs are rigorous enough in their current form.

REPLY [3 votes]: Suppose that $f:A\rightarrow{}B$ is surjective. Consider a function $g:B\rightarrow{}A$ such that $\forall y\in{}B, g(y) := \text{some }x\in{}A\text{ such that }f(x)=y$. Then $\forall y\in{}B, (f\circ{}g)(y)=y$.
Such a function $g$ exists because, by surjectivity, $\forall{}y\in{}B, f^{-1}(\{y\})\neq\emptyset$.
More formally, since $\forall{}y\in{}B$ the set $G_y:=\{(y,x)|x\in{}f^{-1}(\{y\})\}$ is non-empty, per the axiom of choice, the cartesian product of the $G_y$ for all $y\in{}B$ is non empty. Let's take an element $G$ of that product. Then the triplet $g:=(B,A,G)$ is a function with $B$ as domain, $A$ as codomain and $G$ as graph, which fulfills the property that $\forall{}y\in{}B, g(y)\in{}f^{-1}(\{y\})$.