[guided]The goal is to prove the weak derivative identity for the arbitrary test function $\phi \in C_c^\infty(U)$, where $\phi: U \to \mathbb{R}$ is smooth with compact support. Let $\mathcal{L}^n$ denote $n$-dimensional Lebesgue measure on $\mathbb{R}^n$. Define
\begin{align*}
K := \operatorname{supp}\phi.
\end{align*}
The set $K$ is compact and satisfies $K \subset U$. Since $U$ is open, every point of $K$ lies in an open rectangular box whose closure is contained in $U$; compactness of $K$ gives finitely many such boxes $Q_1,\dots,Q_N \subset \mathbb{R}^n$ with $\overline{Q_j} \subset U$ and
\begin{align*}
K \subset \bigcup_{j=1}^N Q_j.
\end{align*}
This localization lets us use product-coordinate integration by parts while keeping all derivatives of $u$ defined on neighbourhoods of the closed boxes.
Apply the support-contained form of the [Existence of Partitions of Unity](/theorems/57) to the open cover $Q_1,\dots,Q_N,U\setminus K$ of $U$. The hypotheses of the theorem are satisfied: $U \subset \mathbb{R}^n$ is open, each $Q_j$ is open, $U\setminus K$ is open because $K$ is closed, and the family covers $U$ because the boxes cover $K$. Hence there are smooth functions $\rho_1,\dots,\rho_N,\rho_0 \in C^\infty(U)$ forming a partition of unity subordinate to this cover. In particular, $\operatorname{supp}\rho_j \subset Q_j$ for $j \in \{1,\dots,N\}$ and $\operatorname{supp}\rho_0 \subset U\setminus K$. Since $\operatorname{supp}\rho_0$ is disjoint from $K$, the function $\rho_0$ vanishes on a neighbourhood of $K$, so
\begin{align*}
\sum_{j=1}^N \rho_j(x) = 1
\end{align*}
for every $x$ in a neighbourhood of $K$. For each $j$, define the function $\phi_j: U \to \mathbb{R}$ by
\begin{align*}
\phi_j(x) := \rho_j(x)\phi(x)
\end{align*}
for $x \in U$. Then $\phi_j$ is smooth, compactly supported in $Q_j$, and extends by zero to an element of $C_c^\infty(Q_j)$. Since $\sum_{j=1}^N \rho_j = 1$ near $K$ and $\phi$ vanishes outside $K$, we have
\begin{align*}
\phi = \sum_{j=1}^N \phi_j
\end{align*}
on all of $U$.
Now fix $j \in \{1,\dots,N\}$ and write
\begin{align*}
Q_j = (a_1,b_1) \times \cdots \times (a_n,b_n).
\end{align*}
Because $\phi_j \in C_c^\infty(Q_j)$ and $u \in C^{|\alpha|}(U)$, the functions $uD^\alpha\phi_j$ and $D^\alpha u\,\phi_j$ are continuous on the compact support of $\phi_j$ and vanish outside a compact subset of $Q_j$. Hence they are integrable with respect to $\mathcal{L}^n$ on $Q_j$, and the standard iterated-integral form of [Fubini's theorem](/theorems/2961) applies on the rectangle $Q_j$. Applying one-dimensional [integration by parts](/theorems/210) successively in each coordinate direction transfers exactly $\alpha_i$ derivatives in the $x_i$ direction from $\phi_j$ onto $u$. Every boundary term at $x_i=a_i$ and $x_i=b_i$ is zero because $\phi_j$ and its derivatives are compactly supported inside $Q_j$, so they vanish near the boundary hyperfaces. The total number of integrations by parts is $|\alpha|$, and therefore the accumulated sign is $(-1)^{|\alpha|}$:
\begin{align*}
\int_{Q_j} u(x)D^\alpha \phi_j(x)\,d\mathcal{L}^n(x)
=
(-1)^{|\alpha|}
\int_{Q_j} D^\alpha u(x)\phi_j(x)\,d\mathcal{L}^n(x).
\end{align*}
Since $\phi_j$ and $D^\alpha\phi_j$ vanish outside $Q_j$, the same identity may be written over $U$:
\begin{align*}
\int_U u(x)D^\alpha \phi_j(x)\,d\mathcal{L}^n(x)
=
(-1)^{|\alpha|}
\int_U D^\alpha u(x)\phi_j(x)\,d\mathcal{L}^n(x).
\end{align*}
Summing this identity over $j \in \{1,\dots,N\}$ and using linearity of the [Lebesgue integral](/page/Lebesgue%20Integral) gives
\begin{align*}
\int_U u(x)D^\alpha\left(\sum_{j=1}^N \phi_j\right)(x)\,d\mathcal{L}^n(x)
=
(-1)^{|\alpha|}
\int_U D^\alpha u(x)\left(\sum_{j=1}^N \phi_j(x)\right)\,d\mathcal{L}^n(x).
\end{align*}
Using $\sum_{j=1}^N \phi_j = \phi$ on $U$, we obtain
\begin{align*}
\int_U u(x)D^\alpha \phi(x)\,d\mathcal{L}^n(x)
=
(-1)^{|\alpha|}
\int_U D^\alpha u(x)\phi(x)\,d\mathcal{L}^n(x).
\end{align*}
This is the defining identity for $D^\alpha u$ to be the [weak derivative](/page/Weak%20Derivative) of $u$ of order $\alpha$.[/guided]