A question about conditional expectations Let $(\Omega, \mathcal{F}, P)$ be the underlying probability space. Let $\mathcal{G}$ be a sub-sigma-algebra of $\mathcal{F}$. Let $f: \mathbb{R}^2 \rightarrow \mathbb{R}$ be a measurable function. Suppose $X$ is a random variable indepdent of $\mathcal{G}$ and that $Y$ is a $\mathcal{G}$-measurable random variable. Is the following true, and if so how do you prove it?
$$ E(f(X,Y) \mid \mathcal{G}) = E(f(X,u)) |_{u = Y}  $$
Many thanks for your help.
 A: Suppose first that $f\geq 0$ are such that $f(X,Y)$ is integrable (to ensure that the conditional expectations exist), and let 
$$
\varphi(y)={\rm E}[f(X,y)]=\int_{\mathbb{R}} f(x,y)\, P_X(\mathrm dx),\quad y\in\mathbb{R}.
$$
Then we claim that ${\rm E}[f(X,Y)\mid\mathcal{G}]=\varphi(Y)$. Tonelli's theorem ensures that $y\mapsto \varphi(y)$ is Borel measurable and that $\varphi(Y)$ is integrable, and hence we only need to show that
$$
\int_{\Omega} \varphi(Y)\mathbf{1}_A\,\mathrm dP=\int_{\Omega} f(X,Y)\mathbf{1}_A\,\mathrm dP
$$
for all $A\in\mathcal{G}$. Letting $Z=\mathbf{1}_A$ we have by assumption that $X$ is independent of $(Y,Z)$ and hence
$$
\begin{align}
\int_{\Omega} \varphi(Y)Z\,\mathrm dP&=\int_{\mathbb{R}} \varphi(y) z\,P_{(Y,Z)}(\mathrm dy,\mathrm dz)=\int_{\mathbb{R}}\left[\int_{\mathbb{R}}f(x,y)z\, P_X(\mathrm dx)\right]\,P_{(Y,Z)}(\mathrm dy,\mathrm dz)\\
&=\int_{\mathbb{R}^3}f(x,y)z\,P_{(X,Y,Z)}(\mathrm dx,\mathrm dy,\mathrm dz)=\int_\Omega f(X,Y)Z\,\mathrm dP,
\end{align}
$$
where we explicitly used that $P_X\times P_{(Y,Z)}=P_{(X,Y,Z)}$ due to independence.
For a general $f$ we just use the decomposition $f=f^+-f^-$ into the two non-negative functions $f^+$ and $f^-$.
