I am new to writing proofs, as a result even when i may know an answer i sometimes doubt if i know how to write the proof. So here is the problem which should be an easy one. In fact i think the proof is harder to write because it is too simple.
Let $f$ be a function. If there exists a function $g$ such that $g \circ f = \text{Id}_{\text{Dom}(f)}$ then $f$ is invertible and $f^{-1} = g$ restricted to $\text{range}(f)$. If there exists a function $h$ such that $f \circ h = \text{Id}_{\text{Range}(f)}$ then $f$ may fail to be invertible.
Some scratch work
Clearly in the left inverse case we start from our function $f$'s domain go to $f$'s range and then using the g restricted to range of $f$ get back to $f$'s domain. Hence we can see a one-to-one correspondance.
In case of the right inverse we start from domain of some function $h$ and end up with range of $h$ which also happens to restrict f's domain, using f we get to range of $f$. In this case we have only observed for each x in domain of f there exists a $y$ in range of $f$, but we haven't seen that for each $y$ there exists a unique $x$ to establish the one-to-one correspondence needed for invertibility.
My Proof attempt
g o f = Id(dom f) the f is invertible and $f^{-1} = g$ restricted to $\text{Range}(f)$. If $g \circ f = \text{Id}_{\text{Dom}(f)}$ then $g(f(x)) = \text{Id}_{\text{Dom}(f)}$.
So for all $x$ such that $x$ belongs to $\text{Dom}(f)$ there exists a $y$ such that y belong to $\text{Range}(f)$ and by definition of function composition $y$ also belongs to domain of $g$ and $g(y) = x$. Hence $g$ restricted to range of $f = f^{-1}$ and $f$ is invertible.
Not so sure how to write the proof of the right inverse case.
Any help would be highly appreciated.