Let $f:A \to B$ , $g:B \to A$, and $\operatorname{id}:A \to A$ be the identity. If the diagram 

$\hspace{4cm} $ ![enter image description here](https://i.stack.imgur.com/BD0fL.jpg)

commutes, prove that ${ f}$ is one-one and ${ g}$ is onto.

**THEOREM** If the diagram above commutes, then $ f$ is one-one and $g$ is onto.

**PROOF** The commutativity of the diagram implies that

$${g f}(x)=x \;; \forall x\in A$$ 

thus $gf $ is one-one and onto. 

$(1)$ $ f$ is one-one. Assume that ${ f}(x)={ f}(y)$.Then

$${ f}(x)={ f}(y)$$

$${ gf}(x)={ gf}(y)$$

$$x=y$$

so that $ { f}$ is one-one.

$(2)$ $g$ is onto. If it wasn't the case $gf $ wouldn't be onto, which is impossible.

---

I don't know wether the last "proof" is right. I can see why it must be the case but I'm not able to exlain it and give a clear proof like that of $f$ being one-one which seems very clear.