Question about definition of inverse function So, I've been reading Precalculus books and I found a question in the definition of inverse function,
some of my books say:

Let $f\colon X\to Y$ be a real function, where $X,Y\subseteq\mathbb{R}$ such that: $g\colon Y\to X$ is the inverse function of $f$ if for each $x\in X$, such that $$g(f(x))=x,\ \forall x\in X\quad\text{and}\quad f(g(y))=y,\ \forall y\in Y.$$

And others of my books say:

Let $f\colon X\to Y$ be a real function, such that $g\colon Y\to X$ is the inverse functdion of $f$ if for each element $x\in X$, if always it’s true that
$$y=f(x)\quad\text{if and only if}\quad x=g(y),\qquad \forall x\in X\text{ and }\forall y\in Y.$$

So, my question is:
What of these is the true definition of inverse function? and
If posible to proof the other definition with the real definition of inverse function?
Further,  What if the proof the link a bijective function and inverse function?
 A: Claim. Let $X,Y$ be sets amd $f\colon X\to Y$, $g\colon Y\to X$ be functions. Then the following are equivalent
$$\tag1\forall x\in X\colon g(f(x))=x\;\land\;\forall y\in Y\colon f(g(y))=y$$
$$\tag2 \forall x\in X,\forall y\in Y\colon y=f(x)\leftrightarrow x=g(y)$$
Proof.
Assume $(1)$. To show $(2)$, let $x\in X, y\in Y$ be given. We wan to show $y=f(x)\iff x=g(y)$. So first assume $y=f(x)$. Then by the first part of $(1)$, $g(y)=g(f(x))=x$. In summary, $y=f(x)\to x=g(y)$. Conversely assume $x=g(y)$. Ten by the seoncd part of $(1)$, $f(x)=f(g(y))=y$. In summary, $x=g(y)\to y=f(x)$. IN overall summary, $y=f(x)\leftrightarrow x=g(y)$. As $x, y$ were arbitrary elements of $X$ and $Y$ respectively, we have shown $(2)$ from $(1)$.
Next, Assume $(2)$. To show the first part of $(1)$, let $x\in X$ be given. As $f$ is a function $X\to Y$, we can let $y=f(x)\in Y$. Specialize $(2)$ to $x$ and $y$ to find $y=f(x)\leftrightarrow x=g(y)$. By choice of $y$, the left side holds, hence $x=g(y)=g(f(x))$, or: $g(f(x))=x$. As $x$ was an arbitrary element of $X$, this shows $\forall x\in X\colon g(f(x))=x$.
To show the first part of $(1)$, let $y\in Y$ be given. As $g$ is a function $Y\to X$, we can let $x=f(y)\in X$. Specialize $(2)$ to $x$ and $y$ to find $y=f(x)\leftrightarrow x=g(y)$. By choice of $x$, the right side holds, hence $y=f(x)=f(g(y))$, or: $f(g(y))=y$. As $y$ was an arbitrary element of $Y$, this shows $\forall y\in Y\colon f(g(y))=y$.
Now that we have shown both $\forall x\in X\colon g(f(x))=x$ and $\forall y\in Y\colon f(g(y))=y$, we have in fact shown $\forall x\in X\colon g(f(x))=x\;\land\;\forall y\in Y\colon f(g(y))=y$, i.e., we have shown $(1)$ from $(2)$.
In summary, $(1)$ and $(2)$ are equivalent. $\square$
A: Consider a map ${ f : X \to Y }.$
Def: Inverse of ${ f }$ is a map ${ g : Y \to X }$ such that ${ (f \text{ sends } x \text{ to } y) }$ ${ \iff (g \text{ sends } y \text{ to } x) }.$
Here the constraint "${ (f(x)=y) \implies (g(y) = x) }$" is equivalent to "${ g \circ f = \text{id} _X }$".
The constraint "${ (f(x)=y) \impliedby (g(y) = x) }$" is equivalent to "${ f \circ g = \text{id} _Y }$".
So equivalently:
Inverse of ${ f }$ is a map ${ g : Y \to X }$ such that ${ g \circ f = \text{id} _X }$ and ${ f \circ g = \text{id} _Y }.$
