Square of conditional variables I thought that the following would hold but my classmates doubt me unfortunately:
$Z = X|Y \rightarrow Z^2 = X^2|Y$
The original problem was an expectation of this and I tried to go back to the formal definition that:
$E[X|Y] = E[X|\sigma(Y)] = \sum_i E[X|A_i] 1_{\omega \in A_i}$
where $i \neq j \rightarrow A_i \cap A_j = \emptyset$ and $\cup_{i=1}^\infty A_i = \Omega$
...and that it would not make any sense to try to square the sigma algebra or something the like so that this must be right:
$E[Z^2] = E[X^2|\sigma(Y)] = \sum_i E[X^2|A_i] 1_{\omega \in A_i} = E[X^2|Y]$
Also wrote it like this:
$E[Z^2] = \int_{-\infty}^\infty x^2 f_X(x|y)dx = E[X^2|Y]$
I also though in a more intuitive fashion that the conditioning is simply something like a parameter of a function like letting:
$f(x)|y = xy$
$f(x)^2|y = (xy)^2$
$(f(x)|y)^2 = (xy)^2$
...where $y$ can be a scalar or an other function or whatever.
Am I right or wrong and how do you reason that this is correct or wrong?
 A: The notation $z=x|y$ is ambiguous, so I am not quite sure if this will answer your question, but I hope it helps.
First, given some function $f[x]$ (e.g. $x^2$), we need to distinguish between its  expectation vs. its probability density. Consistency requires that the expectation should be the same whether we integrate over $x$ or $f[x]$, i.e.
$$\langle f[x]\rangle = \int f[x] \, p[x] \, dx = \int p[f] \, df$$
which means the density of $f[x]$ must satisfy
$$p[f]=p[x]\left|\frac{dx}{df}\right|$$
The point here is that if you use the first integral, $p[x]$ is always the same, needed, i.e. it does not care what the function $f$ is (only that it is deterministic).
Now for $p[x|y]$, you are correct that this can be thought of as a parameterized family of densities for $x$. That is, for a particular value of $y$, the conditional density $p[x|y]$ is just some fixed density function for the variable $x$.
So in the end we have
$$\langle f[x] \mid y \rangle = \int f[x] \, p[x\mid y] \, dx$$
but
$$p[f \mid y]=p[x \mid y]\left|\frac{dx}{df}\right|$$
So in terms of your original question, if you say $z=x|y$, then "$z$" is not really purely a random variable (like $x$ is), but also includes a statement about the "conditions" under which $x$ is being sampled (i.e. $y=c$ for some fixed constant $c$). Given this, the meaning of "$z^2$" seems ambiguous. The above discussion was my attempt to distinguish between the two aspects of $z=x|y$. I hope it was helpful!
