[proofplan]
We prove the result one coordinate direction at a time. For a fixed direction $e_k$, we pair the difference quotients $D_{k,h}u$ against a compactly supported smooth [test function](/page/Test%20Function) and shift variables to move the difference quotient from $u$ onto the test function, producing the [distributional derivative](/page/Distributional%20Derivative) identity in the limit. The uniform $L^2$ bound gives a weakly convergent subsequence of difference quotients, and the limiting identity identifies the weak limit as $\partial_{x_k}u$. Weak lower semicontinuity of the $L^2$ norm then gives the estimate, and doing this for every coordinate proves $u \in H^1(W)$.
[/proofplan]
[step:Fix one coordinate direction and choose admissible difference quotients]
Fix $k \in \{1,\dots,n\}$. Let $h_{0,k} > 0$ and $M_k > 0$ be the constants from the hypothesis for this value of $k$. Since $u \in L^2(U)$ and $W \subset U$, the restriction $u|_W$ belongs to $L^2(W)$.
Choose a sequence $(h_j)_{j=1}^{\infty} \subset \mathbb{R}\setminus\{0\}$ such that
\begin{align*}
0 < |h_j| < h_{0,k} \quad \text{for every } j \in \mathbb{N}, \qquad h_j \to 0.
\end{align*}
Define
\begin{align*}
q_j: W \to \mathbb{R}, \qquad x \mapsto D_{k,h_j}u(x).
\end{align*}
The hypothesis gives
\begin{align*}
\|q_j\|_{L^2(W)} \leq M_k
\end{align*}
for every $j \in \mathbb{N}$.
[/step]
[step:Move the difference quotient from $u$ onto a test function]
Let $\varphi \in C_c^\infty(W)$ be a test function, and let $K := \operatorname{supp}\varphi \subset W$. Since $K$ is compact and $W$ is open, there exists $\rho > 0$ such that $K + t e_k \subset W$ for every $t \in \mathbb{R}$ with $|t| < \rho$. For every $h \in \mathbb{R}$ with $0 < |h| < \min\{h_{0,k},\rho\}$, the change of variables $y = x + h e_k$ in the first term gives
\begin{align*}
\int_W D_{k,h}u(x)\,\varphi(x)\,d\mathcal{L}^n(x) = \int_W u(y)\,\frac{\varphi(y - h e_k) - \varphi(y)}{h}\,d\mathcal{L}^n(y).
\end{align*}
By the definition of the backward difference quotient of $\varphi$,
\begin{align*}
D_{k,-h}\varphi: W \to \mathbb{R}, \qquad y \mapsto \frac{\varphi(y - h e_k) - \varphi(y)}{-h},
\end{align*}
this identity becomes
\begin{align*}
\int_W D_{k,h}u(x)\,\varphi(x)\,d\mathcal{L}^n(x) = -\int_W u(y)\,D_{k,-h}\varphi(y)\,d\mathcal{L}^n(y).
\end{align*}
[guided]
The point of this step is to put the difference quotient on the smooth test function, where we can pass to the limit strongly. Fix $\varphi \in C_c^\infty(W)$ and set $K := \operatorname{supp}\varphi$. Because $K$ is compactly contained in the [open set](/page/Open%20Set) $W$, there is a number $\rho > 0$ such that translating $K$ by any vector $t e_k$ with $|t| < \rho$ keeps it inside $W$:
\begin{align*}
K + t e_k \subset W \quad \text{whenever } |t| < \rho.
\end{align*}
Now take $h \in \mathbb{R}$ with $0 < |h| < \min\{h_{0,k},\rho\}$. Since $W \subset U_{k,h}$ by hypothesis, $D_{k,h}u$ is defined on all of $W$. Starting from the pairing with the test function, we have
\begin{align*}
\int_W D_{k,h}u(x)\,\varphi(x)\,d\mathcal{L}^n(x) = \frac{1}{h}\int_W u(x + h e_k)\varphi(x)\,d\mathcal{L}^n(x) - \frac{1}{h}\int_W u(x)\varphi(x)\,d\mathcal{L}^n(x).
\end{align*}
In the first integral we use the translation change of variables $y = x + h e_k$. Translation preserves [Lebesgue measure](/page/Lebesgue%20Measure), so $d\mathcal{L}^n(y) = d\mathcal{L}^n(x)$, and the domain $W$ is translated to $W + h e_k$. Thus
\begin{align*}
\frac{1}{h}\int_W u(x + h e_k)\varphi(x)\,d\mathcal{L}^n(x) = \frac{1}{h}\int_{W + h e_k} u(y)\varphi(y - h e_k)\,d\mathcal{L}^n(y).
\end{align*}
The function $y \mapsto \varphi(y - h e_k)$ is supported in $K + h e_k$, which is contained in $W$ by the choice of $\rho$. Therefore extending the domain of this integral from $W + h e_k$ to $W$ does not change its value. Combining the two terms gives
\begin{align*}
\int_W D_{k,h}u(x)\,\varphi(x)\,d\mathcal{L}^n(x) = \int_W u(y)\,\frac{\varphi(y - h e_k) - \varphi(y)}{h}\,d\mathcal{L}^n(y).
\end{align*}
Finally define the backward difference quotient of the test function by
\begin{align*}
D_{k,-h}\varphi: W \to \mathbb{R}, \qquad y \mapsto \frac{\varphi(y - h e_k) - \varphi(y)}{-h}.
\end{align*}
Substituting this definition yields the adjoint-difference identity
\begin{align*}
\int_W D_{k,h}u(x)\,\varphi(x)\,d\mathcal{L}^n(x) = -\int_W u(y)\,D_{k,-h}\varphi(y)\,d\mathcal{L}^n(y).
\end{align*}
[/guided]
[/step]
[step:Pass to a weak limit and identify it as the weak partial derivative]
The sequence $(q_j)_{j=1}^{\infty}$ is bounded in the [Hilbert space](/page/Hilbert%20Space) $L^2(W)$. By the standard Hilbert-space weak [compactness theorem](/theorems/2748) (citing a result not yet in the wiki: bounded sequences in Hilbert spaces have weakly convergent subsequences), there exist a subsequence $(q_{j_m})_{m=1}^{\infty}$ and a function $v_k \in L^2(W)$ such that
\begin{align*}
q_{j_m} \rightharpoonup v_k \quad \text{weakly in } L^2(W).
\end{align*}
Fix $\varphi \in C_c^\infty(W)$. From the previous step, for all sufficiently large $m$,
\begin{align*}
\int_W q_{j_m}(x)\,\varphi(x)\,d\mathcal{L}^n(x) = -\int_W u(y)\,D_{k,-h_{j_m}}\varphi(y)\,d\mathcal{L}^n(y).
\end{align*}
Since $\varphi \in C_c^\infty(W)$, the difference quotients $D_{k,-h_{j_m}}\varphi$ converge to $\partial_{x_k}\varphi$ uniformly on a compact subset of $W$, and hence strongly in $L^2(W)$. Because $u \in L^2(W)$, the [Cauchy-Schwarz inequality](/theorems/432) gives
\begin{align*}
\left|\int_W u(y)\bigl(D_{k,-h_{j_m}}\varphi(y)-\partial_{x_k}\varphi(y)\bigr)\,d\mathcal{L}^n(y)\right| \leq \|u\|_{L^2(W)}\|D_{k,-h_{j_m}}\varphi-\partial_{x_k}\varphi\|_{L^2(W)} \to 0.
\end{align*}
Taking limits in the identity above and using [weak convergence](/page/Weak%20Convergence) on the left gives
\begin{align*}
\int_W v_k(x)\varphi(x)\,d\mathcal{L}^n(x) = -\int_W u(x)\partial_{x_k}\varphi(x)\,d\mathcal{L}^n(x).
\end{align*}
Thus $v_k$ is the weak partial derivative $\partial_{x_k}u$ on $W$.
[/step]
[step:Use weak lower semicontinuity to obtain the derivative bound]
Since $q_{j_m} \rightharpoonup v_k$ weakly in $L^2(W)$, the $L^2$ norm is weakly lower semicontinuous (citing a result not yet in the wiki: weak [lower semicontinuity of the norm](/theorems/215) in a Hilbert space). Therefore
\begin{align*}
\|v_k\|_{L^2(W)} \leq \liminf_{m \to \infty}\|q_{j_m}\|_{L^2(W)} \leq M_k.
\end{align*}
Because $v_k = \partial_{x_k}u$ as a [weak derivative](/page/Weak%20Derivative), this gives
\begin{align*}
\|\partial_{x_k}u\|_{L^2(W)} \leq M_k.
\end{align*}
[/step]
[step:Repeat the argument in every coordinate direction]
The argument above applies to each $k \in \{1,\dots,n\}$ with its corresponding constants $h_{0,k}$ and $M_k$. Hence every weak partial derivative $\partial_{x_k}u$ exists on $W$ and belongs to $L^2(W)$. Since also $u \in L^2(W)$, we conclude that $u \in H^1(W)$. The estimate
\begin{align*}
\|\partial_{x_k}u\|_{L^2(W)} \leq M_k
\end{align*}
holds for every $k \in \{1,\dots,n\}$, which is the desired conclusion.
[/step]