[step:Prove a local divergence lemma on $\mathbb{R}^n$][claim:Divergence lemma on the open cube]
Let $f \in C_c^\infty(Q)$ where $Q = (-1, 1)^n$, with $\int_{\mathbb{R}^n} f \, d\mathcal{L}^n = 0$. Then there exist $u_1, \dots, u_n \in C_c^\infty(Q)$ such that
\begin{align*}
f = \sum_{i=1}^n \frac{\partial u_i}{\partial x_i}.
\end{align*}
[/claim]
[proof]
We induct on $n$.
Base case $n = 1$. Given $f \in C_c^\infty(-1, 1)$ with $\int_{-1}^{1} f \, d\mathcal{L}^1 = 0$, define
\begin{align*}
u_1 : \mathbb{R} &\to \mathbb{R} \\
x &\mapsto \int_{-\infty}^x f(t) \, d\mathcal{L}^1(t).
\end{align*}
By the fundamental theorem of calculus, $u_1'(x) = f(x)$ for all $x$. Compact support: for $x \le -1$, $u_1(x) = 0$ (integrand vanishes); for $x \ge 1$, $u_1(x) = \int_{-1}^{1} f \, d\mathcal{L}^1 = 0$. Thus $\operatorname{supp}(u_1) \subset [-1, 1]$, and since $u_1$ is smooth and vanishes in neighbourhoods of $\pm 1$, actually $u_1 \in C_c^\infty(-1, 1)$.
Inductive step. Fix $n \ge 2$ and assume the claim for dimension $n-1$. Pick $\chi \in C_c^\infty(-1, 1)$ with $\int_{-1}^{1} \chi \, d\mathcal{L}^1 = 1$ (a bump function, normalised). Define
\begin{align*}
g : \mathbb{R}^{n-1} &\to \mathbb{R} \\
(x_2, \dots, x_n) &\mapsto \int_{-1}^{1} f(t, x_2, \dots, x_n) \, d\mathcal{L}^1(t),
\end{align*}
a smooth function (differentiation under the integral is justified by compact support of $f$), compactly supported in $(-1, 1)^{n-1}$. Total integral:
\begin{align*}
\int_{\mathbb{R}^{n-1}} g \, d\mathcal{L}^{n-1} = \int_{\mathbb{R}^n} f \, d\mathcal{L}^n = 0,
\end{align*}
by Fubini. By the inductive hypothesis applied to $g$ on $(-1, 1)^{n-1}$, there exist $v_2, \dots, v_n \in C_c^\infty((-1, 1)^{n-1})$ with $g = \sum_{i=2}^n \partial_{x_i} v_i$. Now define
\begin{align*}
u_i(x_1, \dots, x_n) &:= \chi(x_1) \, v_i(x_2, \dots, x_n), \quad i = 2, \dots, n.
\end{align*}
Each $u_i \in C_c^\infty(Q)$. Their total divergence contribution is
\begin{align*}
\sum_{i=2}^n \frac{\partial u_i}{\partial x_i}(x_1, \dots, x_n) = \chi(x_1) \sum_{i=2}^n \frac{\partial v_i}{\partial x_i}(x_2, \dots, x_n) = \chi(x_1) g(x_2, \dots, x_n).
\end{align*}
The residual
\begin{align*}
h(x_1, \dots, x_n) := f(x_1, \dots, x_n) - \chi(x_1) g(x_2, \dots, x_n)
\end{align*}
is in $C_c^\infty(Q)$ with the "slice-zero" property
\begin{align*}
\int_{-1}^{1} h(t, x_2, \dots, x_n) \, d\mathcal{L}^1(t) &= \int_{-1}^{1} f(t, x_2, \dots, x_n) \, d\mathcal{L}^1(t) - \left( \int_{-1}^{1} \chi(t) \, d\mathcal{L}^1(t) \right) g(x_2, \dots, x_n) \\
&= g(x_2, \dots, x_n) - 1 \cdot g(x_2, \dots, x_n) = 0,
\end{align*}
for every $(x_2, \dots, x_n)$. Therefore the function
\begin{align*}
u_1(x_1, \dots, x_n) &:= \int_{-\infty}^{x_1} h(t, x_2, \dots, x_n) \, d\mathcal{L}^1(t)
\end{align*}
satisfies $\partial_{x_1} u_1 = h$ and, by the slice-zero identity, $u_1(x_1, x_2, \dots, x_n) = 0$ for $x_1 \ge 1$ (same argument as the base case applied slicewise). Compact support of $u_1$ in $Q$ follows. Summing,
\begin{align*}
\sum_{i=1}^n \frac{\partial u_i}{\partial x_i} = h + \chi(x_1) g = f.
\end{align*}
[/proof][/step]