Solution (source code)

= Solution

Use the <filtered probability space> $([0,1),\mathcal B([0,1)),(\mathcal F_n),\lambda)$, with its half-open <dyadic intervals>. Complete the initial definition by putting $X_0=\mu([0,1))$. This is the same cell-average formula at level zero, where the only cell is $[0,1)$.

The function $X_n$ is $\mathcal F_n$-measurable and nonnegative. Its <expectation> is
$$
\mathbb E_\lambda X_n=\sum_{k=0}^{2^n-1}2^n\mu(D_k^n)\lambda(D_k^n)=\mu([0,1))<\infty.
$$
Every parent cell is the disjoint union of its two half-open child cells. On $D_k^n$, the <conditional expectation> of $X_{n+1}$ is its cell average:
$$
\frac{1}{\lambda(D_k^n)}\int_{D_k^n}X_{n+1}\,d\lambda
=2^n\left[\mu(D_{2k}^{n+1})+\mu(D_{2k+1}^{n+1})\right]
=2^n\mu(D_k^n).
$$
Thus \b[$\mathbb E[X_{n+1}\mid\mathcal F_n]=X_n$], including at $n=0$. This proves that $X$ is a <nonnegative martingale>, specifically the <dyadic density martingale>. The half-open endpoints are essential to the disjoint partition for an arbitrary <measure>, which may have atoms.