Conditional probability and almost sure equality confusion I initially began writing a lenghty post asking for clarification of my ideas, but decided to delete it and stick to one question that I hope might help my confusion:
We're on $(\Omega, \mathcal F, P)$. The definition of $E^{\mathcal G} X$ is a variable in $L_1(\Omega, \mathcal G, P|_{\mathcal G})$ that fulfils 
$$\forall G \in \mathcal G:\;\; \int_G E^{\mathcal G} X \;dP = \int_G X \;dP$$
Now, if I was to introduce a second variable $Y$ with the property that
$$\forall G \in \mathcal G:\;\; \int_G X\; dP = \int_G Y \;dP$$
Does this mean $Y\stackrel{a.s.}=E^{\mathcal G}X$? 
The problem I have with this is that while $Y$ fits the definition of the conditional expectation. The definition only looks at behaviour of integrals over sets in $\mathcal G$, whereas by declaring their almost sure equality I am actually declaring their equality on the bigger $\sigma$-algebra $\mathcal F$ (both ignoring null sets). 
Thank you very much. This is one of the times when I realize I've been misunderstanding the concepts I've been using for months and my conviction that I understand mathematics on some level just breaks down. Hope I will feel better after today!
 A: It is false. For example, if $Y=X$ and $X$ is not $\mathcal{G}$ measurable.
But, if $Y$ is $\mathcal{G}$-measurable and $\int_GXdP=\int_GYdP$ for all $G\in\mathcal{G}$, thus it is true that $Y=E[X|\mathcal{G}]$ a.e.
A: I'm pretty sure that when we talk about the random variable $E[X|\mathcal{G}]$, we consider it as an element of $L^1(\Omega,\mathcal{G},P)$. As pointed out by sinbadh, the statement that the integrals of $Y$ and $E[X|\mathcal{G}]$ agree on the subsets of $\mathcal{G}$ does not necessarily tell us that $Y = E[X|\mathcal{G}]$ in the $P$-a.s. sense.
For example, if we consider $X,Y,Z \in L^1(\Omega,\mathcal{F},P)$ and the sub-$\sigma$-algebra $\mathcal{G} = \{\emptyset,\Omega\}$, then the agreement of the integrals of the three functions on subsets of $\mathcal{G}$ tells us that $$\displaystyle\int_{\Omega} XdP = \displaystyle\int_{\Omega} YdP =\displaystyle\int_{\Omega} ZdP \Longrightarrow E[X] = E[Y] = E[Z]$$ However, this does not necessarily tell us that $Y = Z$ in the $P$-a.s. sense (relative to either $\mathcal{F}$ or $\mathcal{G}$), as $Y$ and $Z$ could be functions that disagree wildly on $\Omega$ (and consequently differ on both subsets in $\mathcal{F}$ and subsets in $\mathcal{G}$) yet still have the same expected value. However, if we require that $Y$ and $Z$ are $\mathcal{G}$-measurable, then we would find that $E[X|\mathcal{G}]$, $Y$, and $Z$ are all $P$-a.s. equal to the constant function $E[X]$ (relative to both $\mathcal{F}$ and $\mathcal{G}$). 
We can further illustrate the requirement for $Y$ and $Z$ to be $\mathcal{G}$-measurable through the standard proof of the $P$-a.s. uniqueness of conditional expectation. Suppose we have $X \in L^1(\Omega,\mathcal{F},P)$, $G \subset \mathcal{F}$ a sub-$\sigma$-algebra, and $Y,Z \in L^1(\Omega, \mathcal{G},P)$ such that $$\forall G \in \mathcal{G}, \: \: \displaystyle\int_{G} X dP = \displaystyle\int_{G} Y dP = \displaystyle\int_{G} Z dP $$ Then, noting that $\{Z>Y\},\{Y>Z\} \in \mathcal{G}$ because $Y,Z$ are $\mathcal{G}$-measurable, we have that $$\displaystyle\int_{\{Z > Y\}} ZdP  = \displaystyle\int_{\{Z > Y\}} YdP \Longrightarrow \displaystyle\int_{\{Z > Y\}} (Z-Y)dP = 0 \Longrightarrow Z \leq Y \: \: P\mathrm{-a.s.}$$ $$\displaystyle\int_{\{Y > Z\}} ZdP  = \displaystyle\int_{\{Y > Z\}} YdP \Longrightarrow \displaystyle\int_{\{Y > Z\}} (Y-Z)dP = 0 \Longrightarrow Z \geq Y \: \: P\mathrm{-a.s.} $$ Thus we can conclude that $Y = Z$ in the $P$-a.s. sense (once again, relative to either $\sigma$-algebra). 
