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.