Math Help - Proof of invertibility of injective functions

1. Proof of invertibility of injective functions

If $f:A\to B$ is invertible, there exists $g:B\to A$ such that $g\circ f =I_A$ . Now,
$f(x_1)=f(x_2)\Rightarrow g[f(x_1)]=g[f(x_2)]\Rightarrow$
$(g\circ f)(x_1)=(g\circ f)(x_2)\Rightarrow I_A(x_1)=I_A(x_2)\Rightarrow x_1=x_2$