[proofplan]
We prove both directions of the equivalence. For (i), given a PDE solution $u$, we expand $I[w] - I[u]$ for arbitrary $w \in \mathcal{A}$, apply Green's first identity to eliminate the cross term (using $-\Delta u = f$ and $w - u = 0$ on $\partial U$), and obtain $I[w] - I[u] = \frac{1}{2}\int_U |\nabla(w - u)|^2 \, d\mathcal{L}^n \ge 0$. For (ii), given a minimizer $u$, we compute the first variation along compactly supported perturbations $v \in C_c^\infty(U)$, set it to zero, and invoke the [Fundamental Lemma of Calculus of Variations](/theorems/45) to recover $-\Delta u = f$ pointwise.
[/proofplan]
[step:Direction (i): Expand $I[w] - I[u]$ for arbitrary $w \in \mathcal{A}$]
Fix $w \in \mathcal{A}$ and set $\varphi := w - u \in C^2(U) \cap C(\overline{U})$, which satisfies $\varphi = 0$ on $\partial U$ (since both $w$ and $u$ equal $g$ there). Expanding the [energy](/page/Calculus%20of%20Variations%20%28PDEs%29) difference:
\begin{align*}
I[w] - I[u] &= \int_U \left( \tfrac{1}{2}|\nabla(u + \varphi)|^2 - f(u + \varphi) - \tfrac{1}{2}|\nabla u|^2 + fu \right) d\mathcal{L}^n \\
&= \int_U \left( \nabla u \cdot \nabla \varphi + \tfrac{1}{2}|\nabla \varphi|^2 - f\varphi \right) d\mathcal{L}^n.
\end{align*}
[/step]
[step:Eliminate the cross term via Green's first identity and the PDE]
Since $u$ solves $-\Delta u = f$ in $U$ and $\varphi = 0$ on $\partial U$, [Green's first identity](/theorems/30) on the $C^1$ domain $U$ gives
\begin{align*}
\int_U \nabla u \cdot \nabla \varphi \, d\mathcal{L}^n = -\int_U (\Delta u)\, \varphi \, d\mathcal{L}^n + \int_{\partial U} \varphi\, \partial_\nu u \, d\mathcal{H}^{n-1} = \int_U f\, \varphi \, d\mathcal{L}^n,
\end{align*}
where the boundary integral vanishes because $\varphi = 0$ on $\partial U$, and $-\Delta u = f$ gives $-(\Delta u)\varphi = f\varphi$. Substituting into the energy difference:
\begin{align*}
I[w] - I[u] = \int_U f\varphi \, d\mathcal{L}^n + \tfrac{1}{2}\int_U |\nabla \varphi|^2 \, d\mathcal{L}^n - \int_U f\varphi \, d\mathcal{L}^n = \tfrac{1}{2}\int_U |\nabla \varphi|^2 \, d\mathcal{L}^n \ge 0.
\end{align*}
Since $w \in \mathcal{A}$ was arbitrary, $I[u] \le I[w]$ for all $w \in \mathcal{A}$, so $u$ minimises $I$.
[guided]
The key calculation is eliminating the "cross term" $\int_U (\nabla u \cdot \nabla \varphi - f\varphi) \, d\mathcal{L}^n$. Why does it vanish? Green's first identity converts $\int_U \nabla u \cdot \nabla \varphi \, d\mathcal{L}^n$ into a volume term $-\int_U (\Delta u)\varphi \, d\mathcal{L}^n$ plus a boundary term $\int_{\partial U} \varphi\, \partial_\nu u \, d\mathcal{H}^{n-1}$. The boundary term vanishes because $\varphi = w - u = g - g = 0$ on $\partial U$. The volume term equals $\int_U f\varphi \, d\mathcal{L}^n$ because $-\Delta u = f$. So
\begin{align*}
\int_U \nabla u \cdot \nabla \varphi \, d\mathcal{L}^n = \int_U f\varphi \, d\mathcal{L}^n.
\end{align*}
Substituting back:
\begin{align*}
I[w] - I[u] = \int_U f\varphi \, d\mathcal{L}^n + \tfrac{1}{2}\int_U |\nabla \varphi|^2 \, d\mathcal{L}^n - \int_U f\varphi \, d\mathcal{L}^n = \tfrac{1}{2}\int_U |\nabla \varphi|^2 \, d\mathcal{L}^n \ge 0.
\end{align*}
This is the strict convexity of the Dirichlet energy at work: the energy difference is a perfect square (up to a factor of $1/2$), so every PDE solution is an energy minimiser. The inequality is strict unless $\nabla \varphi \equiv 0$, i.e., unless $w = u + \text{const}$; combined with the boundary condition this forces $w = u$, recovering uniqueness as a byproduct.
[/guided]
[/step]
[step:Direction (ii): Compute the first variation of $I$ at a minimiser $u$]
Assume $u \in \mathcal{A}$ minimises $I$ over $\mathcal{A}$. Fix $v \in C_c^\infty(U)$ and define
\begin{align*}
i: \mathbb{R} &\to \mathbb{R} \\
\tau &\mapsto I[u + \tau v].
\end{align*}
Since $v$ has compact support in $U$, the function $u + \tau v$ equals $g$ on $\partial U$ for all $\tau$, so $u + \tau v \in \mathcal{A}$ and $\tau = 0$ is a minimiser of $i$. The integrand of $I[u + \tau v]$ is a polynomial in $\tau$:
\begin{align*}
\tfrac{1}{2}|\nabla u + \tau \nabla v|^2 - f(u + \tau v) = \tfrac{1}{2}|\nabla u|^2 + \tau\, \nabla u \cdot \nabla v + \tfrac{1}{2}\tau^2|\nabla v|^2 - fu - \tau fv.
\end{align*}
Differentiating under the integral sign (justified because the $\tau$-derivative is continuous and integrable over the bounded domain $U$):
\begin{align*}
i'(\tau) = \int_U \bigl( \nabla u \cdot \nabla v + \tau|\nabla v|^2 - fv \bigr) \, d\mathcal{L}^n.
\end{align*}
Setting $i'(0) = 0$ (necessary condition for a minimum) yields
\begin{align*}
\int_U \nabla u \cdot \nabla v \, d\mathcal{L}^n = \int_U f\, v \, d\mathcal{L}^n \qquad \text{for all } v \in C_c^\infty(U).
\end{align*}
[/step]
[step:Recover the PDE $-\Delta u = f$ from the Euler--Lagrange equation]
Since $u \in C^2(U)$, integration by parts on the left-hand side gives
\begin{align*}
\int_U \nabla u \cdot \nabla v \, d\mathcal{L}^n = -\int_U (\Delta u)\, v \, d\mathcal{L}^n
\end{align*}
(the boundary term vanishes because $v \in C_c^\infty(U)$ has support away from $\partial U$). Therefore
\begin{align*}
\int_U (-\Delta u - f)\, v \, d\mathcal{L}^n = 0 \qquad \text{for all } v \in C_c^\infty(U).
\end{align*}
The function $-\Delta u - f$ is continuous on $U$ (since $u \in C^2(U)$ and $f \in C(\overline{U})$). By the [Fundamental Lemma of Calculus of Variations](/theorems/45), $-\Delta u - f = 0$ a.e. in $U$; continuity upgrades this to $-\Delta u = f$ everywhere in $U$. Together with $u = g$ on $\partial U$ (since $u \in \mathcal{A}$), $u$ solves (DP).
[/step]