Solution (source code)

= Solution

Write
$$
H_t=(A_1,X_1,\ldots,A_{t-1},X_{t-1})
$$
for the observed history just before $A_t$. A sufficient condition is <sequential exchangeability>
$$
Y(a_1,\ldots,a_T)\mathrel\perp A_t\mid H_t,
\qquad t=1,\ldots,T,
$$
for every treatment regime, together with <consistency of potential outcomes> and <positivity in causal inference>. Repeated conditioning then gives the longitudinal <G-formula>
$$
\boxed{
\mathbb E[Y(\bar a_T)]
=\sum_{x_1,\ldots,x_{T-1}}
\mathbb E[X_T\mid \bar A_T=\bar a_T,\bar X_{T-1}=\bar x_{T-1}]
\prod_{t=1}^{T-1}
\mathbb P(X_t=x_t\mid\bar A_t=\bar a_t,\bar X_{t-1}=\bar x_{t-1})}.
$$
Graphically, it is enough that each $A_t$ be <D-separated> from the final counterfactual under the specified regime after conditioning on its observed past. The two independences used in part b are precisely the $T=2$ instance.