I am wondering if the proof of this equation below using the optional stopping theorem is correct.
$\textbf{Proposition}$ Let $\tau : \omega \mapsto \{1,2,\dots,\infty\}$ be a stopping time w.r.t a filtration $\{\mathcal{F}_t\}_{t=1,2,\dots}$.
Let $x_1,x_2,\dots$ be a collection of integrable random variables ($\mathbb{E}[|x_i|] < \infty$ for all $i$).
Further suppose that there is a finite $c$ such that $\tau \leq c$ with probability $1$.
Then \begin{equation}\tag{1} \mathbb{E}\left[\sum\limits_{i=1}^{\tau}x_i\right] = \mathbb{E}\left[\sum\limits_{i=1}^{\tau}\mathbb{E}\left[x_i \mid \mathcal{F}_{i-1}\right]\right]. \end{equation}
$\textbf{Proof idea}$
- Define $S_1 = x_1 - \mathbb{E}[x_1]$ and for $n>1$ set $S_n = \sum\limits_{i=1}^{n}(x_i - \mathbb{E}[x_i \mid \mathcal{F}_{i-1}])$.
- Then $S_n$ is a martingale w.r.t $\{\mathcal{F}_t\}_{t=1,2,\dots}$
- Since it is also true that $\tau$ is bounded w.p.1, the optional sampling theorem applies and $\mathbb{E}[S_{\tau}] = \mathbb{E}[S_1] = 0$, which is exactly equivalent to Equation $1$.