Does equality of (weak) gradients imply equality of functions up to a constant? This seems like a pretty basic question, but I can't figure it out.
Suppose we have two measurable functions, $u$ and $v$, whose (weak) partial derivatives are all well defined, and we have $\partial_i u = \partial_i v$ for each $i$. Can we then conclude that $u=v+C$ for some constant $C$?
Note: I'm mainly interested in the weak case but I couldn't think of a proof in the classical setting either.
 A: For the classical case, suppose $\varphi \in C^\infty (U)$, where $U\subset \mathbb R^n$ is a connected open domain. If $D_i \varphi = 0$ for all $i$, then $\varphi$ must be constant. Indeed, if $x_1$, $x_2$ are two points in $\Omega$, and $\gamma \subset \Omega$ is a path connecting them, then
$$ \varphi(x_2) - \varphi(x_1) =\int_\gamma D_i \varphi.dx_i = 0.$$
For the weak case, suppose $u \in L^1_{\rm loc}(U)$, and suppose that $D_i u \in L^1_{\rm loc}(U)$ ($i \in \{1, \dots, n \}$) are its weak derivatives. I think the trick here is to reduce to the classical case, by considering mollifications of $u$, which are smooth functions. Indeed, if $\eta_\epsilon (x) = \frac C {\epsilon^n}\exp\left(\frac{1}{|x/\epsilon|^2 - 1}\right) \mathbf 1_{|x| < 1}$ is the mollifying bump function, then the convolution $u \star \eta_\epsilon $ is in $C^{\infty} (U_\epsilon)$ (where $U_\epsilon = \{ x \in U : {\rm dist}(x,\partial U) > \epsilon \}$). This is proved in Evans, C.4 Theorem 7, p.714. It is also proved on the same page of Evans that $u \star \eta_\epsilon $ tends to $u$ pointwise almost everywhere in $U$ as $\epsilon \to 0$. Also, the weak derivative of the mollification is equal to the mollification of the weak derivative, $D_i(u \star \eta_\epsilon )=(D_iu)\star \eta_\epsilon$ on $U_\epsilon$ (see Evans 5.3 Theorem 1, p.264). So if the weak derivative $D_i u$ vanishes on $U$, then $D_i(u \star \eta_\epsilon) = 0$, hence $u \star \eta_\epsilon$ is constant on $U_\epsilon$ by the classical case. Taking the limit $\epsilon \to 0$, we have that $u$ is constant almost everywhere on $U$.
