Solution (source code)

= Solution

Conditional on $X$,
$$
\mathbb E\!\left[\frac{ZY}{e(X)}\middle|X\right]
=\mathbb E[Y\mid Z=1,X],
\qquad
\mathbb E\!\left[\frac{(1-Z)Y}{1-e(X)}\middle|X\right]
=\mathbb E[Y\mid Z=0,X].
$$
Multiplying by $\mathbf1\{X_1=x_1\}$, taking expectations, dividing by $\mathbb P(X_1=x_1)$, and using part (i) proves the <inverse probability weighting> formula.