Martingale representation theorem up to a stopping time Let $W$ be a standard one dimensional Brownian motion, and let $\mathcal F_t$ be its completed natural filtration.
Let $\tau$ be an $\mathcal F_t$ stopping time with $\tau < T$ almost surely for some $T > 0$. Suppose $\xi$ is an $\mathcal F_\tau$ measurable $L^2$ random variable.
Question: Does there exist some $\mathcal F_t$ predictable process $H$ such that
$$\xi = \mathbb E[\xi] + \int_0^\tau H_s \, dW_s$$
almost surely?
Idea:
I tried to proceed as follows - since $\xi$ is $\mathcal F_\tau$ measurable and $\tau < T$ a.s., $\xi$ is clearly $\mathcal F_T$ measurable. Now the standard  martingale representation theorem gives some predictable $H$ such that
$$\xi = \mathbb E[\xi] + \int_0^T H_s \, dW_s$$
almost surely. But since $\xi$ is $\mathcal F_\tau$ measurable, it should follow that $H_s = 0$, $d\mathbb P \times d\mu$ a.e. whenever $s > \tau$, whence
$$\xi = \mathbb E[\xi] + \int_0^\tau H_s \, dW_s$$
as desired.
However, I am not fully sure how to rigorously show the claim $H_s = 0$ whenever $s > \tau$.
 A: If $\xi\in \mathbb D^{1,2}$ is in the Sobolev-Watanabe space then we can apply Clark-Ocone formula to get that
$$\xi=E[\xi]+\int_0^T E[D_s\xi|\mathcal F_s]dW_s$$
where $D_s$ is the Malliavin derivative. For $s\in [0,T]$ we may write $\xi=\xi 1_{\{\tau > s\}}+\xi 1_{\{\tau \leq s\}}$. Then
\begin{align*}
\xi&=E[\xi]+\int_0^T E[D_s(\xi 1_{\{\tau > s\}}+\xi 1_{\{\tau \leq s\}})|\mathcal F_s]dW_s\\
&=E[\xi]+\int_0^T E[D_s(\xi 1_{\{\tau > s\}})|\mathcal F_s]dW_s+\int_0^T E[D_s(\xi 1_{\{\tau \leq s\}})|\mathcal F_s]dW_s
\end{align*}
$\xi 1_{\{\tau \leq s\}}$ is $\mathcal F_s$-measurable so $D_s (\xi 1_{\{\tau \leq s\}})=0$. Also for $s>\tau$ we have that $\xi 1_{\{\tau > s\}}=0$ so $D_s (\xi 1_{\{\tau > s\}})=0$ and for $s<\tau$ we have that $\xi 1_{\{\tau > s\}}=\xi$. So
$$\xi=E[\xi]+\int_0^\tau E[D_s\xi|\mathcal F_s]dW_s.$$
A: Even if $\xi$ is just integrable (and $\mathcal F_\tau$-measurable) you can consider  (a continuous version of) the martingale
$$
X_t:=\Bbb E[\xi\mid\mathcal F_t],\qquad 0\le t\le T.
$$
By the martingale representaion theorem there is a predictable $H$ with $\int_0^T H_s^2\,ds<\infty$ a.s. such that
$$
X_t=\Bbb E[\xi]+\int_0^t H_s\,dW_s,\qquad\forall t\in[0,T],
$$
almost surely. In particular, because $\xi$ is $\mathcal F_\tau$ measurable,
$$
\xi=\Bbb E[\xi\mid \mathcal F_\tau]=X_\tau=\Bbb E[\xi]+\int_0^\tau H_s\,ds.
$$
You can modify the definition of $H$ if necessary — set $H_s(\omega)=0$ if $s>\tau(\omega)$ — without affecting the stochastic integral.
