Problem:
Let us introduce this definition:
Definition: given an open set $\Omega \subset \mathbb{R}^d$ and $u \in L_{loc}^1(\Omega)$ we say $v \in L_{loc}^1(\Omega)$ is $\frac{\partial}{\partial x_i}u$ in the weak sense if for every $\varphi \in C_{c}^{\infty}(\Omega)$:
$$\int_{\Omega}u \cdot \frac{\partial}{\partial x_i} \varphi = \int_{\Omega} v \cdot \varphi$$
We can now formulate the question.
Question: Suppose that $u \in L_{loc}^1(\Omega^1)$ admits a weak derivative for every $i \in \{1, \dots, d\}$ and $w \in L_{loc}^1(\Omega^2)$ admits a weak derivative for every $i \in \{1, \dots, d\}$. Suppose $u=w$ in $\Omega^1 \cap \Omega^2$. If $\Omega := \Omega^1 \cup \Omega^2$, how can we prove that:
$$f(x)=\begin{cases} u(x) \mbox{ if } x \in \Omega^1\\ w(x) \mbox{ if } x \in \Omega^2 \end{cases}$$ admits a weak derivative in $\Omega$?
Attempt: I tried using approximation by $u \in C_{c}^{\infty}(\mathbb{R}^d)$ but I don't even know if we can.