Uniqueness proof of the left-inverse of a function I attempted to prove directly that a function cannot have more than one left inverse, by showing that two left inverses of a function $f$, must be the same function. 
My Proof
Let $f: A \to B, g: B \to A, h: B \to A$. Suppose $g$ and $h$ are left-inverses of $f$.
Thus $ g \circ f = i_A = h \circ f$. Where $i_A(x) =x$ for all $x \in A$.
Therefore we have $g(f(a)) = h(f(a))$ for $a\in A$. Now since $f$ must be injective for $f$ to have a left-inverse, we have $f(a) = f(a) \implies a = a$ for all $a \in A$ and for all $f(a) \in B$
Put $b = f(a)$. Then $g(b) = h(b) \
 \ \ \forall b \in B$, and thus $g = h$. $\square$

However based on the answers I saw here: Can a function have more than one left inverse?, it seems that my proof may be incorrect. But which part of my proof is incorrect, I can't seem to find anything wrong with my proof.
 A: You're assuming that whenever you have a $b\in B$ there will be some $a$ such that $b=f(a)$. This is not necessarily the case!
However, if you explicitly add an assumption that $f$ is surjective, then a left inverse, if it exists, will be unique.

For your comment: There are two different things you can conclude from the additional assumption that $f$ is surjective:


*

*There is at least one right inverse.

*There is at most one left inverse (and if there is one, it is actually two-sided).


Conversely, if you assume that $f$ is injective, you will know that


*

*There is at most one right inverse (and if there is one, it is actually two-sided).

*There is at least one left inverse (except in the case drhab points out below).

A: Do you necessarily have $ \forall b \in B, \exists a \in A, b = f(a) $?  
A: I'd like to specifically point out that the deduction "Now since $f$ must be injective for $f$ to have a left-inverse, we have $f(a)=f(a)\Rightarrow a=a$ for all $a\in A$ and for all $f(a)\in B$" is rather pointless, since $a=a$ for every $a\in A$ anyway. The problem is in the part "Put $b=f(a)$. Then $g(b)=h(b)$ $\forall b\in B$, and thus $g=h$." This is where you implicitly assumed that the range of $f$ contains $B$.
The claim "a function cannot have more than one left inverse" itself can be false or true, depending on what you mean by a "function" and "left inverse". In the "category convention" it is false, as explained in previous answers, and in the "graph convention" it is true, if one interprets "left inverse" in a proper fashion.  
Adopt the "graph convention" in which a function $f$ is a rule which assigns a unique value $f(x)$ into each $x$ in its domain $\mathrm{dom}(f)$. In this convention two functions $f$ and $g$ are the same if and only if $\mathrm{dom}(f)=\mathrm{dom}(g)$ and $f(x)=g(x)$ for every $x$ in their common domain. Denote $\mathrm{ran}(f):=\{ f(x): x\in \mathrm{dom}(f)\}$. The statement "$f:A\to B$ is a function" is interpreted as "$f$ is a function with $\mathrm{dom}(f)=A$ and $\mathrm{ran}(f)\subset B$" and the statement "$f:A\to B$ is a surjection" as "$f:A\to B$ is a function with $\mathrm{ran}(f)=B$." The statement "$f$ is a surjection" is meaningless in this convention.
Let us say that "$g$ is a left inverse of $f$" if $\mathrm{dom}(g)=\mathrm{ran}(f)$ and $g(f(x))=x$ for every $x\in\mathrm{dom}(f)$. Then it is trivial that if $g_1$ and $g_2$ are left inverses of $f$, then $g_1=g_2$. In fact, in this convention $f$ is an injection if and only if $f$ has a left inverse $g$, and if this is the case, $g$ is the inverse function of $f:\mathrm{dom}(f)\to\mathrm{ran}(f)$.
A: Consider the example
$$A=\{1,2\};B=\{1,2,3\}$$ and $$f:A\to B, g,h:B\to A$$ given by $$f(1)=1; f(2)=2; g(1)=1;g(2)=2;g(3)=1;h(1)=1;h(2)=2;h(3)=2.$$
Note that $h\circ f=g\circ f=id_A.$ However $g\ne h.$ What fails to have equality? That $f$ is not surjective. 
