Let $(\Omega,\mathscr A,\mathscr F_n,\mathbb P)$ be a filtered probability space and $\tau$ be an $\mathscr F_n$ stopping time. $\mathscr F_n$ is discretely indexed.
Show that $X:\Omega \to \mathbb R$ is measurable with respect to the stopped sigma algebra $\mathscr F_\tau$ if and only if $$X(\omega)=\sum_{n=1}^\infty Y_n(\omega)1_{\{\tau =n\}}(\omega).$$ for an $\mathscr F_n$ adapted process $Y_n$.
Showing $X$ of that form is $\mathscr F_\tau$ measurable is more or less straightforward. $\tau$ is $\mathscr F_\tau$ measurable and indicators on measurable sets are measurable. $Y_n$ is adapted and taking intersection gives the result. For the other direction, how can I find the $Y_n$?
We need to assume $\tau<\infty$ almost surely. (If $\mathbb P(\tau=\infty)>0$, then $\tau$ itself is an $\mathscr F_\tau$-measurable random variable which cannot be expressed in the given form.)
For each $n\in\mathbb N$, let $Y_n = X1_{\{\tau=n\}}$. Since $X$ is $\mathscr F_\tau$-measurable, $Y_n$ is $\mathscr F_n$-measurable, that is, $\{Y_n\}$ is adapted. Clearly, we have
$$ X = X\sum_{n=1}^\infty 1_{\{\tau=n\}} =\sum_{n=1}^\infty X1_{\{\tau=n\}} = \sum_{n=1}^\infty Y_n=\sum_{n=1}^\infty Y_n1_{\{\tau = n\}}, $$
as required.