If $\mathbf{E}X<\infty$ and $\tau$ is a stopping time, then $$\mathbf{E}(X|\mathcal{F}_\tau)=\sum_{n\in\mathbb{N}}\mathbf{E}(X|\mathcal{F}_n)\mathbf{1}_{\{\tau=n\}}.$$
My attempt: First assume that $X$ is nonnegative. The general case will follow directly from nonnegative case.
Let $A\in \mathcal{F}_\tau.$ Then $A\cap \{\tau=n\}\in \mathcal{F}_n$ for every $n\in\mathbb{N}.$ Therefore, \begin{align*} \int_{A}\sum_{n\in\mathbb{N}}\mathbf{E}(X|\mathcal{F}_n)\mathbf{1}_{\{\tau=n\}}d\mathbf{P}&=\sum_{n\in\mathbb{N}}\int_{A}\mathbf{E}(X|\mathcal{F}_n)\mathbf{1}_{\{\tau=n\}}d\mathbf{P}=\sum_{n\in\mathbb{N}}\int_{A\cap \{\tau=n\}}\mathbf{E}(X|\mathcal{F}_n)d\mathbf{P}\\&=\sum_{n\in\mathbb{N}}\int_{A\cap \{\tau=n\}}Xd\mathbf{P}=\int_A Xd\mathbf{P} \end{align*} where the first equality follows from monotone convergence theorem, third follows from the definition of the conditional expectation.
Question: (1) To prove that $\sum_{n\in\mathbb{N}}\mathbf{E}(X|\mathcal{F}_n)\mathbf{1}_{\{\tau=n\}}$ is indeed the conditional expectation of $X$ wrt $\mathcal{F}_\tau$, I have to prove that it is $\mathcal{F}_\tau$-measurable. How should I do so?
(2) Since the stopping time can take infinite value, my calculation of the integration above holds only when $\tau<\infty$ almost surely. Is the condition $\tau<\infty$ a.s. necessary here?
Thanks in advance!
(1) Recall $\mathscr{F}_\tau$ is, by definition, the set of events satisfying $\mathrm{E} \cap \{\tau = n\} \in \mathscr{F}_n.$ Then, all you need to do is to show that $\underbrace{\left\{ \sum\limits_{n\in \mathbf{N}} \mathbf{E}(X \mid \mathscr{F}_n) \mathbf{1}_{\{\tau=n\}} \in \mathrm{A} \right\}}_{\mathrm{E}} \cap \{\tau = m\} \in \mathscr{F}_m.$ The intersection on the left side becomes $\{\mathbf{E}(X \mid \mathscr{F}_m) \in \mathrm{A}\}\cap\{\tau=m\},$ which clearly belongs to $\mathscr{F}_m.$ Q.E.D.
(2) If $\tau = \infty$ with positive probability, you would need to add it in the sum and make sense of the case $n = \infty$ everywhere.