In a paper I am writing I need to show that a certain real-valued function $f\in C^0(B_1)$ belongs to the Sobolev space $W^{1,2}(B_1)$ ($B_1$ is the unit ball). So far I have been able to show that the weak derivative $Df$ exists on the open set $B_1\setminus \{f=0\}$ and $Df \mathbb{1}_{f\neq 0}\in L^2(B_1)$, so now I only have to deal with the set $\{f=0\}$. I suspect that it shouldn't matter and that the weak differential $Df$ exists on all $B_1$ and is equal to $Df \mathbb{1}_{f\neq 0}$ a.e., but I am having troubles proving it formally. Any help/hint is appreciated.