Probability – Show X Equals Y Almost Surely

conditional-expectationexpectationlebesgue-integralmeasure-theoryprobability

I am trying to solve this problem:

Let $X,Y$ be random variables on $(\Omega, \mathcal{F}, P)$ such that $E(Y|\mathcal{G}) = X$ and $E(Y^2|\mathcal{G}) = X^2$, where $\mathcal{G} \subset \mathcal{F}$ is a sigma-algebra. Prove that $X = Y$ almost surely.

What I have until now:

From the given property, it's easy to see that $\int_{G}XdP = \int_{G} YdP$, for any $G \in \mathcal{G}$. Also, $X$ is $\mathcal{G}$-measurable.

I know that if the integrals of two random variables, on the same probability space, over any element of the sigma-algebra in discussion agree, then they are equal almost surely. So, if I could prove that $Y$ is also $\mathcal{G}$-measurable I could apply this result. Or, in te other hand, if I could find a similar equality as above for any element $F \in \mathcal{F}$, then I think the problem is solved too. But I can't do it.

Also, I can't see how the information the $X^2$ can be helpful here. Any ideas? Thanks in advance for the support.

Best Answer

Since $X$ is $\mathcal{G}$-measurable we have (by the product rule) that $$E(XY) = E(E(XY|\mathcal{G})) = E(XE(Y|\mathcal{G})) = E(X^2).$$ Similarly, $$E(Y^2) = E(E(Y^2|\mathcal{G})) = E(X^2).$$ Thus, $$E((X-Y)^2) = E(X^2)+E(Y^2) - 2E(XY) = 0.$$ Hence, $$P((X-Y)^2 = 0) = 1.$$ The last line follows from the non-negativity of $(X-Y)^2$.