$\DeclareMathOperator{\dom}{dom}\DeclareMathOperator{\ran}{ran}$I need help in the following exercise, I appreciate all the forms for the demonstration:
Let $f:A→B$ and $g:B→A$ be functions. Suppose that $y=f(x)$ and only if $x=g(y)$. Prove that $f$ is invertible and $g=f^{−1}$.
By now this is what I have done but I don't reach the goal:
Since $\dom_f=A$ and $\ran_f=B$, thus $\dom_g=B$ and $\ran_g=A$. $(y_1,x)\in f^{-1}$ and $(y_2,x)\in f^{-1}$ implies that $(x,y_1)\in f$ and $(x,y_2)\in f$, so $y_1=y_2$.
Let $x\in A$ Write $f(x)=y$, $f(x)=y$ implies that $g(y)=g(f(x))=x$, we deduce that $g\circ f=id_A$
Let $y\in B$, write $g(y)=x$, $g(y)=x$ implies that $f(x)=f(g(y))=y$, we deduce that $f\circ g =id_B$.