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?

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 }.$
