I am trying to understand the proof of $E[E[X|Y]]=E[X]$ and there is one part that I am not getting.
$$\sum_{y=-\infty}^\infty E[X|Y=y]Pr[Y=y] $$
I know that the left side by definition equals to the sum shown above, and I also know that
$$\sum_{y=-\infty}^\infty \sum_{x=-\infty}^{\infty}xPr[X=x|Y=y] Pr[Y=y] $$
is my next step.
However, I do not understand why one is able to pull out the expression as the following
$$\sum_{x=-\infty}^\infty x \sum_{y=-\infty}^{\infty} Pr[X=x|Y=y] Pr[Y=y]$$
my argument is that $Pr[X=x|Y=y]$ has an $x$ in it, so I cannot freely just move it around like this...
I appreciate your input.
Since all the terms being summed are positive, Fubini's theorem allows you to shuffle them, so that $$ \sum_{y = - \infty}^{\infty} \sum_{x = -\infty}^{\infty} xP(X = x| Y = y)P(Y=y) = \sum_{x = - \infty}^{\infty} \sum_{y = -\infty}^{\infty} xP(X = x| Y = y)P(Y=y) $$ Then the innermost sum doesn't depend on $x$ and you can pull it out without worry. It's worth reiterating that interchanging infinite sums is not in general fair game, and that a necessary condition was satisfied here.