Is the substitution of variables allowed in proofs? EDIT: I later realized no one saw that substituting $\sqrt{x} =  x$ is not valid because they are not equal, you would have to assume $x$ as a completely different variable (i.e. $a$) and not the same one because they have no relation to each other. However, the solution to my proof problem is given. 
So for example I have to prove:
$2y \leq \frac{y^2}{x^2} + x^2$ (for any real numbers $x$ and $y$ and $x$ $\neq$ $0$), 
and I do some rough work at start with this and end up with the arithmetic-geometric mean inequality:
$\sqrt{xy} \le \frac{x+y}{2}$ (using substitution of variables). 
Now to prove it, I start with the arithmetic-geometric mean inequality, then do the following steps: 
$\sqrt{xy} \leq \frac{x+y}{2}$
$\sqrt{x}\sqrt{y} \leq \frac{x+y}{2}$
Now, substitute $\sqrt{x}$ with $x$ and so:
$xy \leq x^2+\frac{y^2}{2}$
Then throughout, I do one more substitution:
$\sqrt{x} = x$
to end up with the first (1) equation. Would this be allowed or is there another way of proving it? Such as squaring the right side of arithmetic-geometric mean inequality? I am not too sure. Thanks. 

HINT
We have that
$$2y\le \frac{y^2}{x^2}+x^2 \iff2yx^2\le y^2+x^4 \iff x^4-2yx^2+y^2\ge 0$$
