Solution (source code)

= Solution

Recall that $g_i\in L^1_{\mathrm{loc}}(\Omega)$ is the <weak derivative> $D_i u$ if $u\in L^1_{\mathrm{loc}}(\Omega)$ and $\int uD_i\phi=-\int g_i\phi$ for all $\phi\in C_c^\infty(\Omega)$. A global <weak derivative> restricts to every open neighborhood simply by taking <test functions> supported there.

Conversely, suppose local <weak derivatives> exist near each point. <local integrability> of $u$ follows by a finite cover of each compact subset. On overlapping neighborhoods the two candidates for $D_i u$ have identical integrals against every smooth compactly supported <test function>. The fundamental lemma for <locally integrable> functions therefore makes them equal <almost everywhere>. Choose a countable local cover, possible in Euclidean space; the countably many exceptional overlap sets can all be discarded. The derivatives consequently patch to measurable $g_i\in L^1_{\mathrm{loc}}(\Omega)$.

For a <test function> $\phi$, take a smooth <partition of unity> $(\chi_j)$ subordinate to the local cover and locally finite on its support. Only finitely many terms occur there. Because $\sum_j\chi_j=1$ near the support,
$$
\int_\Omega uD_i\phi=\sum_j\int_\Omega uD_i(\chi_j\phi)
=-\sum_j\int_\Omega g_i\chi_j\phi=-\int_\Omega g_i\phi.
$$
The derivatives of the partition sum to zero, explaining the first equality. Thus the patched functions are the global <weak derivatives>. This proves both directions of <locality of weak differentiability>.