Is it correct my demonstration in this issue of functions on sets? 
Let $f:A \rightarrow B$ and $g:B \rightarrow A$ be functions. Suppose that $y=f(x)$ iff $x=g(y)$. Prove that $f$ is invertible and $g=f^{-1}$

I say, if $f$ is invertible then $f$ is a biyective function. I'm gonna see if $f$ is inyective:

Let $(x_1,y)\in f$ and $(x_2,y)\in f$ $\implies$ $(y,x_1)\in g$ and $(y,x_2) \in g$, as $g$ is a function, then $x_1=x_2$

Now, i'm gonna see if $f$ is surjective. Let $y \in B$, as $g$ is a function then $(\forall y \in B)(\exists x \in A)(y,x) \in g \implies (\forall y \in B)(\exists x \in A)(x,y)\in f $. Then $f$ is subjective.
As $f$ is biyective then $f$ is invertible.
Now, i'm gonna try prove that $f^{-1}=g$
Let $(y,x)\in f^{-1} \iff (x,y) \in f \iff(y,x)\in g$
Then $f^{-1}=g \blacksquare$
Is it correct my show? Any recommendations?
 A: Yes your proof is correct, but unorthodox. Usually functions are not used so formally; one writes $y=f(x)$ instead of $(x,y)\in f$. Furthermore, just point out that to prove that $f$ in invertible it is enough to show that it is injective. You would need the fact that $f$ is also surjective later to prove that $f^{-1}=g$ so it is ok anyway.
The "orthodox proof" would be as follows: Let $x_1,x_2\in A$. The equation $f(x_1)=f(x_2)$ implies by hypothesis that
$$x_1=g(f(x_2))=g(f(x_1))=x_2,$$
so $f$ must be injective and therefore exists $f^{-1}:f(A)\subset B\to A$.
To show that $f^{-1}=g$ we need first to check that $f(A)=B$; i.e. that $f$ is surjective. Let $y\in B$ and denote $x=g(y)$. By hypothesis $y=f(x)$, so $y\in f(A)$ and the surjectiveness of $f$ follows. To see that $f^{-1}=g$
we need finally to check that $f(g(y))=y$ for every $y\in B$ and $g(f(x))=x$ for every $x\in A$. Using the hypothesis again you get that these conditions are equivalent to $f(x)=f(x)$ and $g(y)=g(y)$, which obviously hold.
