Solution (source code)

= Solution

The <closest point theorem in a Hilbert space> states that every nonempty closed convex subset $C$ of a Hilbert space has a unique point nearest to any given $x$.

Let $d=\inf_{y\in C}\|x-y\|$ and choose $y_n\in C$ with $\|x-y_n\|\to d$. The parallelogram identity and convexity give
$$
\|y_n-y_m\|^2
=2\|x-y_n\|^2+2\|x-y_m\|^2
 -4\left\|x-\frac{y_n+y_m}{2}\right\|^2
\leq2\|x-y_n\|^2+2\|x-y_m\|^2-4d^2,
$$
so $(y_n)$ is Cauchy. Completeness and closedness give a <limit> $y\in C$ with $\|x-y\|=d$. If $y,z$ were both minimizers, the same identity with their midpoint would force $\|y-z\|=0$.

Apply the theorem to a closed subspace $F$. For $x\in H$, let $y\in F$ be closest and put $z=x-y$. For every $u\in F$, minimality of $\|z-tu\|^2$ at $t=0$ for real and imaginary $t$ gives $\langle z,u\rangle=0$. Hence
$$
x=y+z\in F+F^\perp.
$$
The intersection is zero, so $H=F\oplus F^\perp$.

If $T$ is a shift with orthonormal <basis> $(e_n)$, it is an isometry,
$$
(\operatorname{Im}T)^\perp=\operatorname{span}\{e_1\},
\qquad
\bigcap_{n\geq1}\operatorname{Im}(T^n)=\{0\}.
$$
Conversely, suppose these three properties hold. Choose a unit <vector> $e_1$ spanning $(\operatorname{Im}T)^\perp$ and set $e_n=T^{n-1}e_1$. Isometry makes this <sequence> orthonormal. Iterating the orthogonal decomposition
$$
H=\operatorname{span}\{e_1\}\oplus\operatorname{Im}T
$$
gives
$$
H=\operatorname{span}\{e_1,\ldots,e_n\}\oplus\operatorname{Im}(T^n).
$$
A <vector> orthogonal to every $e_n$ lies in every $\operatorname{Im}(T^n)$ and is therefore zero. Thus $(e_n)$ is an orthonormal <basis> and $Te_n=e_{n+1}$, so $T$ is a shift. This is the <wandering-vector characterization of a unilateral shift>.