Let $X$ be in $\mathfrak{L}^1(\Omega,\mathfrak{F},P)$ and $\mathfrak{G}\subset \mathfrak{F}$.
Prove that if $X$ and $E(X|\mathfrak{G})$ have same distribution, then they are equal almost surely.
I know what I have to show, that $X$ is $\mathfrak{G}$ measurable, but I don't know how...
Here, the main difficulty is that we do not assume finiteness of the expectation of $X^2$.
Fix a real number $x$ and define $A:=\{X\leqslant x\}$ and $B:=\{\mathbb E[X\mid\mathcal G]\leqslant x\}$. Using the assumption, we have $$\mathbb E[X\chi(A)]=\mathbb E[X\chi(B)].$$
Indeed, since $B$ belongs to $\mathcal G$, we have $$\mathbb E[X\chi(B)]=\mathbb E[\mathbb E[X\mid\mathcal G]\chi(B)] =\mathbb E[\mathbb E[X\mid\mathcal G]\chi\{\mathbb E[X\mid\mathcal G]\leqslant x\}],$$ and the random variables $X\chi\{X\leqslant x\}$ and $\mathbb E[X\mid\mathcal G]\chi\{\mathbb E[X\mid\mathcal G]\leqslant x\}$ have the same distribution.
Define $C_1:=A\setminus B$ and $C_2:=B\setminus A$. Since $\mathbb P(A)=\mathbb P(B)$, we have $$\mathbb E\left[(X-x)\chi(C_1)\right]=\mathbb E[(X-x)\chi(C_2)].$$ As $(X-x)\chi(C_1)\leqslant 0\leqslant (X-x)\chi(C_2)$, we get that $\mathbb P(A\Delta B)=0$. Define $A':=\{X\geqslant -x\}$ and $B':=\{\mathbb E[X\mid\mathcal G]\geqslant -x\}$. By the argument uses with $-X$ instead of $X$, we get $\mathbb P(A'\Delta B')=0$. Defining $A'':=A\cap A'$ and $B'':=B\cap B'$, we have $\mathbb P(A''\Delta B'')=0$ hence $$\mathbb E[\left(\mathbb E[X\mid\mathcal G]\right)^2\chi(A'')]=\mathbb E[\left(\mathbb E[X\mid\mathcal G]\right)^2\chi(B'')]=\mathbb E[X^2\chi(|X|\leqslant x)]$$ and $$\mathbb E\left[X\mathbb E[X\mid\mathcal G]\chi(A'')\right]=\mathbb E[\left(\mathbb E[X\mid\mathcal G\right)^2\chi(B'')],$$ hence $$\mathbb E\left[\left(X-\mathbb E[X\mid\mathcal G]\right)^2\chi\{|X|\leqslant x\}\right]=0.$$ As $x$ is arbitrary, the conclusion follows.