# Proving the uniqueness of an inverse function

We have this question for homework:

Let $h(b)\colon B\to A$ be the left inverse of $f$, and $g\colon B\to A$ the right inverse of $f$. Prove that that $h$ and $g$ are the same function.

To prove this I stated "Let $a\in A$ and $b\in B$ such that $f(a)=b$ and $g(b)=a$."

My question is: is that even legal to assume so?

If it is then all there's left to show is that $h(f(a)) = h(b) \neq g(b) = a$ is a contradiction to $h$ being an inverse function of $f$...

-

It might be best not to even deal with specific elements of $A$ and $B$. I assume $f\colon A\to B$. You're given that $h$ is the left inverse and $g$ the right inverse, so $h\circ f=\text{id}_A$ and $f\circ g=\text{id}_B$. Then $$h=h\circ\text{id}_B=h\circ(f\circ g)=\cdots$$ and remember that composition of functions is associative.