# A Property of Martingale of Sum of i.i.d. Random Variables

I am trying to solve the following problem:

Let $\{Y_n\}_{n=1}^{\infty}$ be a sequence of i.i.d. random variables with finite mean. Let $F_n =\sigma(Y_1,...,Y_n)$. Let $\tau$ be a stopping time adapted to the filtration $\{\mathcal{F}_n\}_{n=1}^{\infty}$ with finite mean. Define $X_n = \sum_{i=1}^n Y_i$. Show that $E(X_\tau) = E(Y_1)E(\tau )$.

The following is also given as a hint: Write $X_\tau$ as $\sum_{k} Y_kg_k(\tau )$, where $g_k(\tau)$ is $\mathcal{F_{k-1}}$-measurable.

I tried to take $$g_k(n)=\begin{cases}1\ \ {\rm if }\ \ k\leq n \\ 0\ \ \ {\rm otherwise}\end{cases}$$ But this turns out to be not $\mathcal{F_{k-1}}$-measurable, since $\tau^{-1}(g_k^{-1}(1))$ is the union of $\{\tau=m\}$'s for all $m$'s larger than or equal to $k$. Am I doing something wrong? Is there a better set of functions to take?

I solved it myself. Actually $\tau^{-1}\circ g^{-1}_k$ is measurable. Notice that obviously $$\{\omega|\tau< k-1\}\in \mathcal{F}_{k-2}\subseteq \mathcal{F}_{k-1}$$ and since $\mathcal{F}_{k-1}$ is a $\sigma$-field we get: $$\{\omega|\tau \geq k\}\in \mathcal{F}_{k-1}.$$