Solution (source code)

= Solution

The bounded-time <optional stopping theorem> states that if $X$ is an integrable discrete-time <martingale> and $\tau$ is a <stopping time> bounded by a deterministic integer $N$, then $X_\tau$ is integrable and $\mathbb E X_\tau=\mathbb E X_0$. Indeed $|X_\tau|\le\sum_{j=0}^N|X_j|$ proves integrability, and
$$
X_\tau=X_0+\sum_{j=1}^N\mathbf1_{\{\tau\ge j\}}(X_j-X_{j-1}).
$$
The event $\{\tau\ge j\}=\{\tau>j-1\}$ belongs to $\mathcal F_{j-1}$. <Conditional expectation> of each summand given $\mathcal F_{j-1}$ is zero, so
$$
\boxed{\mathbb E X_\tau=\mathbb E X_0}.
$$
More generally, if $\sigma\le\tau\le N$ are <stopping times>, $\mathbb E[X_\tau\mid\mathcal F_\sigma]=X_\sigma$. To prove this, test against $A\in\mathcal F_\sigma$ and apply the same argument to $\mathbf1_A\mathbf1_{\{\sigma<j\le\tau\}}(X_j-X_{j-1})$; its coefficient is $\mathcal F_{j-1}$-measurable. Boundedness of the <stopping times> makes the sums finite, so no limiting optional-stopping hypothesis is being omitted.