[proofplan]
We use the direct method in the [calculus of variations](/page/Calculus%20of%20Variations). First we check that the admissible set is convex and stable under weak limits in $H^1(U)$. Then a minimizing sequence is shown to be bounded in $H^1(U)$ by applying the [Poincare Inequality with Zero Trace](/theorems/76) to the zero-boundary part $u-g$. [Weak sequential compactness](/theorems/214) in the [Hilbert space](/page/Hilbert%20Space) $H^1(U)$ gives a candidate minimizer, weak closedness of norm-closed linear subspaces preserves the boundary condition, a direct lower-semicontinuity argument for the gradient norm proves existence, and the parallelogram identity plus the [Poincare Inequality with Zero Trace](/theorems/76) proves uniqueness.
[/proofplan]
[step:Verify that the obstacle class is convex]
Let $u, v \in \mathcal K_{g,\psi}$ and let $\theta \in [0,1]$. Define
\begin{align*}
z := \theta u + (1-\theta)v \in H^1(U).
\end{align*}
Since $u-g \in H^1_0(U)$ and $v-g \in H^1_0(U)$, and since $H^1_0(U)$ is a vector subspace of $H^1(U)$, we have
\begin{align*}
z-g = \theta(u-g) + (1-\theta)(v-g) \in H^1_0(U).
\end{align*}
Moreover, because $u \geq \psi$ and $v \geq \psi$ $\mathcal L^n$-a.e. in $U$,
\begin{align*}
z = \theta u + (1-\theta)v \geq \theta\psi + (1-\theta)\psi = \psi
\end{align*}
$\mathcal L^n$-a.e. in $U$. Hence $z \in \mathcal K_{g,\psi}$, so $\mathcal K_{g,\psi}$ is convex.
[/step]
[step:Obtain an $H^1$ bound for every minimizing sequence]
Set
\begin{align*}
m := \inf_{v \in \mathcal K_{g,\psi}} \mathcal E[v].
\end{align*}
Since $\mathcal K_{g,\psi} \neq \varnothing$, choose $v_0 \in \mathcal K_{g,\psi}$. Then
\begin{align*}
0 \leq m \leq \mathcal E[v_0] < \infty.
\end{align*}
Let $(u_k)_{k=1}^{\infty}$ be a minimizing sequence in $\mathcal K_{g,\psi}$, so $\mathcal E[u_k] \to m$. Passing to a tail if necessary, assume
\begin{align*}
\mathcal E[u_k] \leq \mathcal E[v_0] + 1
\end{align*}
for every positive integer $k$. Define
\begin{align*}
M := \left(2\mathcal E[v_0] + 2\right)^{1/2}.
\end{align*}
Then
\begin{align*}
\|\nabla u_k\|_{L^2(U)} \leq M
\end{align*}
for every positive integer $k$.
For each positive integer $k$, define
\begin{align*}
w_k := u_k - g \in H^1_0(U).
\end{align*}
Using the triangle inequality in $L^2(U;\mathbb R^n)$,
\begin{align*}
\|\nabla w_k\|_{L^2(U)} \leq \|\nabla u_k\|_{L^2(U)} + \|\nabla g\|_{L^2(U)} \leq M + \|\nabla g\|_{L^2(U)}.
\end{align*}
By the [Poincare Inequality with Zero Trace](/theorems/76) applied with $p=2$ to the bounded [open set](/page/Open%20Set) $U$ and the function $w_k \in H^1_0(U)$, there exists a constant $C_U > 0$, depending only on $U$, such that
\begin{align*}
\|w_k\|_{L^2(U)} \leq C_U\|\nabla w_k\|_{L^2(U)}.
\end{align*}
Therefore
\begin{align*}
\|w_k\|_{H^1(U)} \leq (1+C_U)\left(M+\|\nabla g\|_{L^2(U)}\right).
\end{align*}
Since $u_k = w_k + g$, the sequence $(u_k)_{k=1}^{\infty}$ is bounded in $H^1(U)$.
[guided]
The purpose of this step is to prevent a minimizing sequence from escaping to infinity in $H^1(U)$. The energy controls only the gradient of $u_k$, not the full $H^1$ norm. The boundary condition fixes this missing constant mode through the condition $u_k-g \in H^1_0(U)$.
Define the infimum of the energy by
\begin{align*}
m := \inf_{v \in \mathcal K_{g,\psi}} \mathcal E[v].
\end{align*}
Because $\mathcal K_{g,\psi}$ is nonempty, we may choose $v_0 \in \mathcal K_{g,\psi}$. Since $\mathcal E[v_0]$ is finite, the infimum satisfies
\begin{align*}
0 \leq m \leq \mathcal E[v_0] < \infty.
\end{align*}
Let $(u_k)_{k=1}^{\infty}$ be a minimizing sequence, meaning that $u_k \in \mathcal K_{g,\psi}$ for every $k$ and $\mathcal E[u_k] \to m$. After discarding finitely many terms, we may assume
\begin{align*}
\mathcal E[u_k] \leq \mathcal E[v_0] + 1
\end{align*}
for every positive integer $k$. With
\begin{align*}
M := \left(2\mathcal E[v_0] + 2\right)^{1/2},
\end{align*}
the definition of $\mathcal E$ gives
\begin{align*}
\|\nabla u_k\|_{L^2(U)} \leq M.
\end{align*}
Now isolate the zero-boundary part of $u_k$. Define
\begin{align*}
w_k := u_k - g \in H^1_0(U).
\end{align*}
The gradient satisfies $\nabla w_k = \nabla u_k - \nabla g$ in $L^2(U;\mathbb R^n)$, so the triangle inequality gives
\begin{align*}
\|\nabla w_k\|_{L^2(U)} \leq \|\nabla u_k\|_{L^2(U)} + \|\nabla g\|_{L^2(U)} \leq M + \|\nabla g\|_{L^2(U)}.
\end{align*}
This is where the boundary condition is used. Since $w_k \in H^1_0(U)$ and $U$ is bounded, the [Poincare Inequality with Zero Trace](/theorems/76) applies with $p=2$. It gives a constant $C_U > 0$, depending only on $U$, such that
\begin{align*}
\|w_k\|_{L^2(U)} \leq C_U\|\nabla w_k\|_{L^2(U)}.
\end{align*}
Combining the $L^2$ estimate with the gradient estimate yields
\begin{align*}
\|w_k\|_{H^1(U)} \leq (1+C_U)\left(M+\|\nabla g\|_{L^2(U)}\right).
\end{align*}
Finally, $u_k = w_k + g$, and $g$ is fixed in $H^1(U)$, so $(u_k)_{k=1}^{\infty}$ is bounded in $H^1(U)$.
[/guided]
[/step]
[step:Pass to a weak limit that remains admissible]
Since $H^1(U)$ is a Hilbert space and $(u_k)_{k=1}^{\infty}$ is bounded in $H^1(U)$, the weak [sequential compactness](/page/Sequential%20Compactness) theorem for bounded sequences in Hilbert spaces gives a subsequence, still denoted $(u_k)_{k=1}^{\infty}$, and an element $u \in H^1(U)$ such that
\begin{align*}
u_k \rightharpoonup u \quad \text{weakly in } H^1(U).
\end{align*}
Because $u_k-g \in H^1_0(U)$ for every $k$, and because every norm-closed linear subspace of a Hilbert space is weakly closed, the norm-closed linear subspace $H^1_0(U) \subset H^1(U)$ is weakly closed. Hence
\begin{align*}
u-g \in H^1_0(U).
\end{align*}
It remains to check the obstacle inequality. Define
\begin{align*}
r_k := u_k-\psi \in L^2(U)
\end{align*}
and
\begin{align*}
r := u-\psi \in L^2(U).
\end{align*}
Since $u_k \rightharpoonup u$ weakly in $H^1(U)$, the continuity of the embedding $H^1(U) \hookrightarrow L^2(U)$ implies
\begin{align*}
r_k \rightharpoonup r \quad \text{weakly in } L^2(U).
\end{align*}
For every $k$, $r_k \geq 0$ $\mathcal L^n$-a.e. in $U$. Suppose, for contradiction, that $r < 0$ on a set of positive $\mathcal L^n$-measure. Since
\begin{align*}
\{x \in U : r(x) < 0\} = \bigcup_{j=1}^{\infty}\{x \in U : r(x) \leq -1/j\},
\end{align*}
[countable subadditivity](/theorems/1108) implies that at least one set in this union has positive $\mathcal L^n$-measure. Thus there exists $\varepsilon > 0$ such that the measurable set
\begin{align*}
A_\varepsilon := \{x \in U : r(x) \leq -\varepsilon\}
\end{align*}
satisfies $\mathcal L^n(A_\varepsilon) > 0$. Since $U$ is bounded, $\mathbb 1_{A_\varepsilon} \in L^2(U)$. [Weak convergence](/page/Weak%20Convergence) in $L^2(U)$ gives
\begin{align*}
\int_U r_k \mathbb 1_{A_\varepsilon} \, d\mathcal L^n(x) \to \int_U r \mathbb 1_{A_\varepsilon} \, d\mathcal L^n(x).
\end{align*}
The left-hand integrals are nonnegative, while
\begin{align*}
\int_U r \mathbb 1_{A_\varepsilon} \, d\mathcal L^n(x) \leq -\varepsilon \mathcal L^n(A_\varepsilon) < 0.
\end{align*}
This contradiction proves $r \geq 0$ $\mathcal L^n$-a.e. in $U$. Hence $u \geq \psi$ $\mathcal L^n$-a.e. in $U$, and therefore $u \in \mathcal K_{g,\psi}$.
[guided]
This step has two separate closure requirements: the boundary condition must survive weak convergence, and the obstacle inequality must survive weak convergence. The first is a Hilbert-space fact: every norm-closed linear subspace of a Hilbert space is weakly closed. Here $H^1_0(U)$ is a norm-closed linear subspace of $H^1(U)$, so it is weakly closed. Therefore, from $u_k-g \in H^1_0(U)$ for every $k$ and $u_k \rightharpoonup u$ weakly in $H^1(U)$, we obtain
\begin{align*}
u-g \in H^1_0(U).
\end{align*}
For the obstacle condition, define
\begin{align*}
r_k := u_k-\psi \in L^2(U)
\end{align*}
and
\begin{align*}
r := u-\psi \in L^2(U).
\end{align*}
Because the embedding $H^1(U) \hookrightarrow L^2(U)$ is continuous, weak convergence in $H^1(U)$ implies weak convergence after applying this embedding. Hence
\begin{align*}
r_k \rightharpoonup r \quad \text{weakly in } L^2(U).
\end{align*}
Each $r_k$ is nonnegative $\mathcal L^n$-a.e. in $U$, because each $u_k$ belongs to $\mathcal K_{g,\psi}$. We prove that the weak limit is also nonnegative by testing against the indicator of a negative-level set.
Assume for contradiction that $r<0$ on a set of positive $\mathcal L^n$-measure. Since
\begin{align*}
\{x \in U : r(x) < 0\} = \bigcup_{j=1}^{\infty}\{x \in U : r(x) \leq -1/j\},
\end{align*}
countable subadditivity implies that one of the sets on the right has positive measure. Thus there is $\varepsilon>0$ such that
\begin{align*}
A_\varepsilon := \{x \in U : r(x) \leq -\varepsilon\}
\end{align*}
satisfies $\mathcal L^n(A_\varepsilon)>0$. Since $U$ is bounded, $\mathcal L^n(A_\varepsilon)<\infty$, so the indicator function $\mathbb 1_{A_\varepsilon}$ belongs to $L^2(U)$. Testing the weak convergence $r_k \rightharpoonup r$ against $\mathbb 1_{A_\varepsilon}$ gives
\begin{align*}
\int_U r_k \mathbb 1_{A_\varepsilon} \, d\mathcal L^n(x) \to \int_U r \mathbb 1_{A_\varepsilon} \, d\mathcal L^n(x).
\end{align*}
The left-hand side is nonnegative for every $k$, because $r_k\geq 0$ $\mathcal L^n$-a.e. in $U$. But on $A_\varepsilon$ we have $r\leq -\varepsilon$, so
\begin{align*}
\int_U r \mathbb 1_{A_\varepsilon} \, d\mathcal L^n(x) \leq -\varepsilon \mathcal L^n(A_\varepsilon) < 0.
\end{align*}
This contradicts convergence of nonnegative numbers to a negative number. Therefore $r\geq 0$ $\mathcal L^n$-a.e. in $U$, which means $u\geq \psi$ $\mathcal L^n$-a.e. in $U$. Combining this with $u-g\in H^1_0(U)$ proves $u\in \mathcal K_{g,\psi}$.
[/guided]
[/step]
[step:Derive lower semicontinuity of the gradient norm to prove existence]
The weak convergence $u_k \rightharpoonup u$ in $H^1(U)$ implies
\begin{align*}
\nabla u_k \rightharpoonup \nabla u \quad \text{weakly in } L^2(U;\mathbb R^n).
\end{align*}
If $\nabla u \neq 0$ in $L^2(U;\mathbb R^n)$, define
\begin{align*}
F := \frac{\nabla u}{\|\nabla u\|_{L^2(U)}} \in L^2(U;\mathbb R^n).
\end{align*}
Weak convergence tested against $F$ gives
\begin{align*}
\|\nabla u\|_{L^2(U)} = \int_U \nabla u \cdot F \, d\mathcal L^n(x) = \lim_{k \to \infty}\int_U \nabla u_k \cdot F \, d\mathcal L^n(x).
\end{align*}
For every positive integer $k$, the [Cauchy-Schwarz inequality](/theorems/432) in $L^2(U;\mathbb R^n)$ gives
\begin{align*}
\left|\int_U \nabla u_k \cdot F \, d\mathcal L^n(x)\right| \leq \|\nabla u_k\|_{L^2(U)}\|F\|_{L^2(U)} = \|\nabla u_k\|_{L^2(U)}.
\end{align*}
Taking the limit inferior yields
\begin{align*}
\|\nabla u\|_{L^2(U)} \leq \liminf_{k \to \infty}\|\nabla u_k\|_{L^2(U)}.
\end{align*}
If $\nabla u=0$ in $L^2(U;\mathbb R^n)$, the same inequality is immediate because the left-hand side is $0$. Define the nonnegative real sequence $a_k := \|\nabla u_k\|_{L^2(U)}$ and the nonnegative number $a := \|\nabla u\|_{L^2(U)}$. The previous inequality says $a \leq \liminf_{k \to \infty} a_k$. Since $t \mapsto t^2$ is increasing and continuous on $[0,\infty)$, and since $\liminf_{k \to \infty} a_k^2 = (\liminf_{k \to \infty} a_k)^2$ for nonnegative real sequences, we have
\begin{align*}
\|\nabla u\|_{L^2(U)}^2 \leq \liminf_{k \to \infty}\|\nabla u_k\|_{L^2(U)}^2.
\end{align*}
Using the definition of the Dirichlet energy, this gives
\begin{align*}
\mathcal E[u] \leq \liminf_{k \to \infty}\mathcal E[u_k] = m.
\end{align*}
Since $u \in \mathcal K_{g,\psi}$, the definition of $m$ also gives $m \leq \mathcal E[u]$. Therefore $\mathcal E[u]=m$, so $u$ is a minimizer of $\mathcal E$ over $\mathcal K_{g,\psi}$.
[guided]
The minimizing sequence has now produced an admissible weak limit $u$. The remaining question is whether the energy can increase or decrease under this weak convergence. For existence, we need weak lower semicontinuity: the energy of the weak limit must be no larger than the limiting infimum of the energies.
The weak convergence $u_k \rightharpoonup u$ in $H^1(U)$ implies weak convergence of gradients in $L^2(U;\mathbb R^n)$:
\begin{align*}
\nabla u_k \rightharpoonup \nabla u \quad \text{weakly in } L^2(U;\mathbb R^n).
\end{align*}
If $\nabla u \neq 0$ in $L^2(U;\mathbb R^n)$, define the test vector field
\begin{align*}
F := \frac{\nabla u}{\|\nabla u\|_{L^2(U)}} \in L^2(U;\mathbb R^n).
\end{align*}
Then $\|F\|_{L^2(U)}=1$, and testing weak convergence against $F$ gives
\begin{align*}
\|\nabla u\|_{L^2(U)} = \int_U \nabla u \cdot F \, d\mathcal L^n(x) = \lim_{k \to \infty}\int_U \nabla u_k \cdot F \, d\mathcal L^n(x).
\end{align*}
For each $k$, the Cauchy-Schwarz inequality in the Hilbert space $L^2(U;\mathbb R^n)$ gives
\begin{align*}
\left|\int_U \nabla u_k \cdot F \, d\mathcal L^n(x)\right| \leq \|\nabla u_k\|_{L^2(U)}\|F\|_{L^2(U)} = \|\nabla u_k\|_{L^2(U)}.
\end{align*}
Taking the limit inferior yields
\begin{align*}
\|\nabla u\|_{L^2(U)} \leq \liminf_{k \to \infty}\|\nabla u_k\|_{L^2(U)}.
\end{align*}
If $\nabla u=0$ in $L^2(U;\mathbb R^n)$, the same inequality holds because its left-hand side is zero. Define $a_k := \|\nabla u_k\|_{L^2(U)}$ and $a := \|\nabla u\|_{L^2(U)}$. These are nonnegative [real numbers](/page/Real%20Numbers), and the inequality just proved is $a \leq \liminf_{k \to \infty} a_k$. Because $t\mapsto t^2$ is increasing and continuous on $[0,\infty)$, and because $\liminf_{k \to \infty} a_k^2 = (\liminf_{k \to \infty} a_k)^2$ for nonnegative real sequences, we obtain
\begin{align*}
\|\nabla u\|_{L^2(U)}^2 \leq \liminf_{k \to \infty}\|\nabla u_k\|_{L^2(U)}^2.
\end{align*}
By the definition of the Dirichlet energy, this is exactly
\begin{align*}
\mathcal E[u] \leq \liminf_{k \to \infty}\mathcal E[u_k] = m.
\end{align*}
The opposite inequality $m\leq \mathcal E[u]$ follows from the definition of $m$ as the infimum over $\mathcal K_{g,\psi}$ and from the already-proved fact that $u\in \mathcal K_{g,\psi}$. Therefore $\mathcal E[u]=m$, and $u$ is a minimizer.
[/guided]
[/step]
[step:Use strict convexity on the zero-boundary difference to prove uniqueness]
Let $u, v \in \mathcal K_{g,\psi}$ be minimizers. Since $\mathcal K_{g,\psi}$ is convex,
\begin{align*}
z := \frac{u+v}{2} \in \mathcal K_{g,\psi}.
\end{align*}
The parallelogram identity in the Hilbert space $L^2(U;\mathbb R^n)$ gives
\begin{align*}
\int_U |\nabla z|^2 \, d\mathcal L^n(x) = \frac{1}{2}\int_U |\nabla u|^2 \, d\mathcal L^n(x) + \frac{1}{2}\int_U |\nabla v|^2 \, d\mathcal L^n(x) - \frac{1}{4}\int_U |\nabla(u-v)|^2 \, d\mathcal L^n(x).
\end{align*}
Since $u$ and $v$ are both minimizers, $\mathcal E[u]=\mathcal E[v]=m$. Since $z \in \mathcal K_{g,\psi}$, $\mathcal E[z]\geq m$. Substituting the identity above gives
\begin{align*}
m \leq \mathcal E[z] = m - \frac{1}{8}\int_U |\nabla(u-v)|^2 \, d\mathcal L^n(x).
\end{align*}
Hence
\begin{align*}
\int_U |\nabla(u-v)|^2 \, d\mathcal L^n(x)=0.
\end{align*}
Define
\begin{align*}
h := u-v.
\end{align*}
Because $u-g \in H^1_0(U)$ and $v-g \in H^1_0(U)$, we have $h \in H^1_0(U)$. Applying the [Poincare Inequality with Zero Trace](/theorems/76) with $p=2$ to $h \in H^1_0(U)$ gives
\begin{align*}
\|h\|_{L^2(U)} \leq C_U\|\nabla h\|_{L^2(U)} = 0.
\end{align*}
Thus $h=0$ in $L^2(U)$, so $u=v$ as elements of $H^1(U)$. Therefore the minimizer is unique.
[guided]
The energy is only a gradient norm, so equality of gradients would not usually force equality of functions: two functions could differ by a constant. The fixed boundary class removes exactly this ambiguity. Let $u, v \in \mathcal K_{g,\psi}$ be minimizers. Since the obstacle class was proved convex, the midpoint
\begin{align*}
z := \frac{u+v}{2}
\end{align*}
belongs to $\mathcal K_{g,\psi}$. The parallelogram identity in the Hilbert space $L^2(U;\mathbb R^n)$ gives
\begin{align*}
\int_U |\nabla z|^2 \, d\mathcal L^n(x) = \frac{1}{2}\int_U |\nabla u|^2 \, d\mathcal L^n(x) + \frac{1}{2}\int_U |\nabla v|^2 \, d\mathcal L^n(x) - \frac{1}{4}\int_U |\nabla(u-v)|^2 \, d\mathcal L^n(x).
\end{align*}
Since $u$ and $v$ are minimizers, $\mathcal E[u]=\mathcal E[v]=m$. Since $z$ is admissible, the definition of $m$ gives $\mathcal E[z]\geq m$. Substituting the parallelogram identity into the energy therefore yields
\begin{align*}
m \leq \mathcal E[z] = m - \frac{1}{8}\int_U |\nabla(u-v)|^2 \, d\mathcal L^n(x).
\end{align*}
The only way this inequality can hold is if
\begin{align*}
\int_U |\nabla(u-v)|^2 \, d\mathcal L^n(x)=0.
\end{align*}
Define
\begin{align*}
h := u-v.
\end{align*}
Because $u-g \in H^1_0(U)$ and $v-g \in H^1_0(U)$, subtracting these two zero-trace functions gives
\begin{align*}
h = (u-g)-(v-g) \in H^1_0(U).
\end{align*}
Now the boundedness of $U$ and the membership $h\in H^1_0(U)$ allow us to apply the [Poincare Inequality with Zero Trace](/theorems/76) with $p=2$. Hence
\begin{align*}
\|h\|_{L^2(U)} \leq C_U\|\nabla h\|_{L^2(U)} = 0.
\end{align*}
Thus $h=0$ in $L^2(U)$, so $u=v$ as elements of $H^1(U)$. This proves uniqueness of the minimizer.
[/guided]
[/step]