[guided]We prove both parts of the projection claim directly. The data are a nonempty closed convex set $K \subseteq L$ and a point $q \in L \setminus K$, where $L$ is a finite-dimensional inner product space with Euclidean norm $|\cdot|$. The target is first to construct a nearest point $p \in K$ satisfying
\begin{align*}
|q-p| = \inf_{w \in K} |q-w|.
\end{align*}
After that, the same point must satisfy the variational inequality
\begin{align*}
(q-p) \cdot (w-p) \leq 0
\end{align*}
for every $w \in K$.
Because $K$ is nonempty, choose $w_0 \in K$. Define the positive radius
\begin{align*}
r := |q-w_0| + 1.
\end{align*}
Also define the closed ball in $L$
\begin{align*}
\overline{B}(q,r) := \{u \in L : |u-q| \leq r\}.
\end{align*}
Why is it legitimate to restrict the minimization problem to this ball? If $w \in K$ and $|q-w| > r$, then
\begin{align*}
|q-w| > |q-w_0| + 1 > |q-w_0|.
\end{align*}
Such a point cannot improve on the distance already obtained at $w_0$. Therefore
\begin{align*}
\inf_{w \in K} |q-w| = \inf_{w \in K \cap \overline{B}(q,r)} |q-w|.
\end{align*}
The set $K \cap \overline{B}(q,r)$ is nonempty because it contains $w_0$. It is closed because $K$ is closed in $L$ and $\overline{B}(q,r)$ is closed in $L$. It is bounded because it is contained in $\overline{B}(q,r)$. Since $L$ is finite-dimensional, the [Heine-Borel theorem](/theorems/309) in finite-dimensional Euclidean spaces gives that $K \cap \overline{B}(q,r)$ is compact.
Define the continuous map $\psi: K \cap \overline{B}(q,r) \to \mathbb{R}$ by
\begin{align*}
\psi(w) := |q-w|^2.
\end{align*}
The map $\psi$ is continuous because the map $w \mapsto q-w$ is continuous on $L$ and the squared Euclidean norm is continuous. By the extreme value theorem applied on the compact set $K \cap \overline{B}(q,r)$, there exists $p \in K \cap \overline{B}(q,r)$ such that
\begin{align*}
\psi(p) \leq \psi(w)
\end{align*}
for every $w \in K \cap \overline{B}(q,r)$. Equivalently,
\begin{align*}
|q-p|^2 \leq |q-w|^2
\end{align*}
for every $w \in K \cap \overline{B}(q,r)$. Since the infimum over $K$ equals the infimum over $K \cap \overline{B}(q,r)$, this same point $p$ satisfies
\begin{align*}
|q-p| = \inf_{w \in K} |q-w|.
\end{align*}
Now fix an arbitrary point $w \in K$. The point $p$ is a minimizer, so we test minimality along the line segment from $p$ to $w$. Convexity of $K$ gives
\begin{align*}
p + t(w-p) \in K
\end{align*}
for every $t \in [0,1]$. Minimality of $p$ over $K$ gives
\begin{align*}
|q-p|^2 \leq |q-(p+t(w-p))|^2.
\end{align*}
Since
\begin{align*}
q-(p+t(w-p)) = q-p-t(w-p),
\end{align*}
we have
\begin{align*}
|q-p|^2 \leq |q-p-t(w-p)|^2.
\end{align*}
Expanding the square in the Euclidean inner product on $L$ gives
\begin{align*}
|q-p-t(w-p)|^2 = |q-p|^2 - 2t(q-p)\cdot(w-p) + t^2 |w-p|^2.
\end{align*}
Substituting this expansion into the previous inequality and subtracting $|q-p|^2$ from both sides yields
\begin{align*}
0 \leq -2t(q-p)\cdot(w-p) + t^2 |w-p|^2.
\end{align*}
For $t>0$, divide by $t$ to obtain
\begin{align*}
0 \leq -2(q-p)\cdot(w-p) + t |w-p|^2.
\end{align*}
Letting $t \downarrow 0$ gives
\begin{align*}
0 \leq -2(q-p)\cdot(w-p).
\end{align*}
Thus
\begin{align*}
(q-p)\cdot(w-p) \leq 0.
\end{align*}
Because $w \in K$ was arbitrary, the projection inequality holds for every $w \in K$.
The same step will next use this projection inequality for a closed convex set
\begin{align*}
K \subseteq L,
\end{align*}
with boundary data
\begin{align*}
0 \in K
\end{align*}
and
\begin{align*}
0 \notin \operatorname{relint}(K).
\end{align*}
For each $m \in \mathbb{N}$ we choose $q_m \in L \setminus K$ with
\begin{align*}
|q_m| < \frac{1}{m},
\end{align*}
then take a nearest point $p_m \in K$ and define
\begin{align*}
v_m := q_m-p_m,
\end{align*}
and
\begin{align*}
b_m := \frac{v_m}{|v_m|}.
\end{align*}
The projection inequality gives
\begin{align*}
b_m\cdot(w-p_m)\leq 0,
\end{align*}
hence
\begin{align*}
b_m\cdot w\leq b_m\cdot p_m
\end{align*}
for every $w \in K$.[/guided]