How to prove that $(u-v)^+\in W_0^{1,2}(\Omega)$, if $u\in W_0^{1,2}(\Omega)$, $v\geq 0$. Let $\Omega$ denote a open subset of $\mathbb{R}^n$, and $W^{1,p}(\Omega)$ the Sobolev space of weakly differentiable functions $u\in L^p(\Omega)$ (that is, for which $D_iu$ exists and belongs to $L^p(\Omega)$ as well, for every $i\in\left\{1,\ldots,n\right\}$).
I'm studying boundary regularity of a solution of the Dirichlet problem for the circle $D\subseteq\mathbb{R}^2$, and the weak maximum principle is needed. For that, we need to give a proper meaning for $u\leq v$ in $\partial\Omega$ (the boundary of $\Omega$), where $u,v\in W^{1,2}(\Omega)$. The definition is:
$u\leq v$ in $\partial\Omega$ iff $(u-v)^+\in W_0^{1,2}(\Omega)$, where:


*

*$w^+=\max(w,0)$ denotes the positive part of $w$; and

*$W_0^{1,2}(\Omega)$ is the closure (in Sobolev norm) of $C_0^\infty(\Omega)=\left\{w\in C^\infty(\Omega):\text{supp}(w)\text{ is compact}\right\}$


Now, a lot of statements relating to that concept need the following lemma (or something similar), which I'm unable to prove:

Lemma: Let $u\in W_0^{1,2}(\Omega)$, $v\in W^{1,2}(\Omega)$ such that $v\geq 0$ pointwise. Show that $(u-v)^+\in W_0^{1,2}(\Omega)$.

Intuitively, that should be true. If we think of continuous functions $u$ and $v$ such that $u\in C_0(\Omega)$, then $(u-v)^+\in C_0(\Omega)$, since $|(u-v)^+|\leq|u|$ (where $C_0(\Omega)$ denotes the set o compactly supported continuous functions from $\Omega$ to $\mathbb{R}$). Using mollifiers, it's easy to see that $C_0(\Omega)\subseteq W_0^{1,2}(\Omega)$, and the lemma is true in that case. I tried to give the following proof:
The case $u\in C_0^\infty(\Omega)$ is easy enough. Now, let $\left\{u_n\right\}_{n\in\mathbb{N}}\subseteq C_0^\infty(\Omega)$ be a sequence converging in $W^{1,2}(\Omega)$ to $u$. Taking subsequences if necessary, I tried making pointwise convergence (almost everywhere in $\Omega$) of $(u_n-v)^+$ and $D_i(u_n-v)^+$ to $(u-v)^+$ and $D_i(u-v)^+$, respectively, so I'd apply Lebesgue's Dominated Convergence Theorem, and conclude convergence in $W^{1,2}(\Omega)$, hence proving the lemma. The problem is exactly with the derivatives:
Since $Dw^+(x)=0$ if $w(x)\leq 0$ and $Dw^+(x)=Dw(x)$ if $w(x)>0$ ($\forall w\in W^{1,2}(\Omega)$: this follows from the weak chain rule), we cannot garantee pointwise convergence if $u(x)=v(x)$.
Any idea would be of great value. Even if one must assume $\Omega$ bounded and/or $v\in C^\infty(\Omega)\cap C^0(\overline{\Omega})$, it would suffice for what I need.
Thank you in advance.
 A: I found a nice elementary proof for this: All the equalities are meant to hold a.e..

Lemma: Let $u\in W^{1,p}(\Omega)$ and $N=\left\{x\in\Omega:u(x)=0\right\}$. Then $D_iu=0$ a.e. in $N$.

Proof: Let $u^+=\max(u,0)$ and $u^-=\min(u,0)$. By the chain rule, $u^+,u^-\in W^{1,p}(\Omega)$ and $D_iu^+(x)=D_iu(x)$ if $u(x)>0$ and $D_i u^+(x)=0$ otherwise, and $D_i u^-(x)=D_iu(x)$ if $u(x)<0$ and $D_iu^-(x)=0$ otherwise. Since $D_iu(x)=D_i(u^++u^-)(x)=D_iu^+(x)=D_iu^-(x)$, the lemma holds.$\square$
Proof of the statement in the question: First suppose $u\in C_0^\infty(\Omega)$. Then $\text{supp}(u-v)^+\subseteq\text{supp}(u)$, and a sequence of mollificationsof $(u-v)^+$, converging to it in $W^{1,p}(\Omega)$ will eventually be in $C^\infty_0(\Omega)$, and the statement holds.
Now suppose $u\in W_0^{1,p}(\Omega)$. Let $\left\{u_n\right\}_{n\in\mathbb{N}}$ be a sequence of $C_0^\infty(\Omega)$ functions converging to $u$. Taking subsequences if needed, we can assume $u_n\rightarrow u$ and $D_iu_n\rightarrow D_iu$ a.e. in $\Omega$.
Then $(u_n-v)^+\rightarrow (u-v)^+$ a.e. pointwise (for $x\in\Omega$, consider the cases $u(x)>v(x)$, $u(x)<v(x)$ and $u(x)=v(x)$), and the dominated convergence theorem implies that $(u_n-v)^+$ converges to $(u-v)^+$ in $L^p(\Omega)$.
Now, let $x\in\Omega$ (such that $D_iu_n(x)\rightarrow D_iu(x)$). If $u(x)>v(x)$ or $u(x)<v(x)$, use the chain rule to see that $D_i(u_n-v)^+(x)\rightarrow D_i(u-v)^+(x)$. If $u(x)=v(x)$, by the lemma we can assume that $D_iu(x)=D_iv(x)$, and it's easily verified that $D_i(u_n-v)^+(x)\rightarrow D_i(u-v)^+(x)$. Again by dominated convergence, $D_i(u_n-v)^+\rightarrow D_i(u-v)^+$ in $L^p(\Omega)$. That means that $(u_n-v)^+\rightarrow(u-v)^+$ in $W^{1,p}(\Omega)$. Since $(u_n-v)^+\in W_0^{1,p}(\Omega)$, which is closed, the result follows.$\square$
A: Going through fine pointwise properties of Sobolev functions and associated nonlinear potential theory looks like doing it the hard way. Here is another approach.
Claim. Let $1< p<\infty$. If $u\in W_0^{1,p}(\Omega)$, $w\in W^{1,p}(\Omega)$, and $0\le w\le u$, then $w\in W_0^{1,p}(\Omega)$. 
We need a standard truncation lemma. Here $u^+=\max(u,0)$. 
Lemma 1 If $u \in W^{1,p}(\Omega)$, then $u^+ \in W^{1,p}(\Omega)$ and $|\nabla u^+|\le |\nabla u|$ almost everywhere. 
Proof. Use the ACL characterization of $W^{1,p}$. Note that 
$$|u^+(a)-u^+(b)|\le |u(a)-u(b)|,\qquad a,b\in \Omega \tag1$$ 
Since $u$ is absolutely continuous on almost every coordinate-parallel segment, so is $u^+$ —  just look at the definition of absolute continuity and at (1). Therefore, $u^+$ on such segments $u^+$ is differentiable a.e. Again, (1) implies that its partial derivatives cannot exceed the partial derivatives of $u$.  $\Box$
Corollary 2. If $u,v \in W^{1,p}(\Omega)$, then $\min(u,v) $ and $\max(u,v)$ are in $W^{1,p}(\Omega)$ and their gradients are bounded by $|\nabla u|+|\nabla v|$.
Proof. Apply Lemma 1 to $\dfrac{u+v}{2}\pm \dfrac{(u-v)^+}{2}$. $\Box$  
Proof of the Claim: Let $(w_n)$ and $(u_n)$ be smooth approximations to $w$ and $u$ in the Sobolev norm, with $u_n$ compactly supported in $\Omega$. Then $f_n:=\min(w_n^+,u_n)$ is a sequence of Lipschitz compactly supported functions. By construction, $f_n\to w$ a.e. 
From Lemma 1 and Corollary 2 we see that $(f_n)$ is a bounded sequence in $W^{1,p}$ norm. Therefore, it has a subsequence $f_{n_k}$ that converges to some $g\in W^{1,p}_0(\Omega)$ weakly in $W^{1,p}$ and strongly in $L^p$ (the latter by Rellich-Kondrachov). Recalling that $f_n\to w$ a.e., we conclude that $g=w$. Thus, $w\in W^{1,p}_0(\Omega)$. $\Box$
Notice how the "soft" tools of functional analysis save us the headache of dealing with boundary values. The set $W^{1,p}_0(\Omega)$ is closed in $W^{1,p}(\Omega)$ by definition, and is also convex. From functional analysis, it's weakly closed — and this is how we get $g\in W^{1,p}_0(\Omega)$, not from pointwise analysis of boundary values. 
A: There is a characterization of $W_0^{1,2}$ in terms of pointwise traces: a function $u \in W^{1,2}(\Omega)$ belongs to $W_0^{1,2}(\Omega)$ if and only if 
$$
\lim_{r \to 0^+} \int_{B(x,r) \cap \Omega} |u(y)| \, dy = 0
$$
for $(1,2)$-quasievery point $x \in \partial \Omega$. Since you assume $u \in W^{1,2}_0(\Omega)$ and point out that $|(u-v)^+| \le |u|$, you can conclude that $(u-v)^+ \in W^{1,2}_0(\Omega)$ also.
