Let $X, Y, Z$ be random variables. If $X\le Y$, I wonder if $$\mathbb{E}[X|Z=z]\le \mathbb{E}[Y|Z=z]$$ holds.
I have a contradiction between math and intuition.
First, math. I think math shows that this inequality is correct. Since $X\le Y$, we have $X-Y\le 0$. Then, $$\mathbb{E}[X-Y|Z=z]=\sum_{x,y} (x-y)p(X=x,Y=y|Z=z)$$ Since $x-y\le0$ and $p(x,y|z)\ge0$, it is clear that $\mathbb{E}[X-Y|Z=z]\le0$ which implies $\mathbb{E}[X|Z=z]\le \mathbb{E}[Y|Z=z]$.
Second, intuition. Intuitively, the inequality is incorrect. For example, it is possible that when $Z=z$, the possibility to have $Y=y$ is zero for all $y$. And it is possible that $\mathbb{E}[X|Z=z]$ is positive. In this case, the inequality does not hold.
Is the intuition wrong? or the math wrong? I searched a bit and found a note saying that the inequality holds almost surely. I don't understand why it is almost surely.
The inequality is true for all integrable random variables $X$ and $Y$.
For any $A\in\sigma(Z)$,
$E[E[X\mid Z]1_A]=E[X1_A]\leq E[Y1_A]=E[E[Y\mid Z]1_A].$
A measure-theoretic argument implies that $E[X\mid Z]\leq E[Y\mid Z]$ almost surely.
The reason why the inequality holds almost surely is because the conditional expectation is only defined up to null events. One can propose different conditional expectations which only differ on events of probability $0$.
For example take $Z\sim U(0,1)$ and $X=Z^2$, $Y=Z$.
We have $X\leq Y$ and I can write $E[Y\mid Z]=Z$.
I can also write $E[X\mid Z]=Z^2$ or $E[X\mid Z]=Z^21_{Z\neq1/2}+161361_{Z=1/2}$.
Both these choices for $E[X\mid Z]$ are valid and in both cases I would have $E[X\mid Z]\leq E[Y\mid Z]$ almost surely, but the second choice for $E[X\mid Z]$ would not allow me to say $E[X\mid Z]\leq E[Y\mid Z]$ for all values of $Z$.