Example for $\operatorname{dist}(x_0,Y)<1$ in Riesz' lemma Let $$X:=\left\{f\in C([0,1]):f(1)=0\right\}$$ be equipped with the supremum norm and $$Y:=\left\{f\in X:\int_0^1f(t)\:{\rm d}t=0\right\}.$$

I want to show that if $f_0\in X$ with $\left\|f_0\right\|_\infty=1$, then $$\operatorname{dist}(f_0,Y)<1\tag1.$$ How can we do that?

Note that, since $0\in Y$, $$\operatorname{dist}(f,Y)\le\left\|f\right\|_\infty\tag2\;\;\;\text{for all }f\in X.$$
 A: Define the functional $x^* : X \to \mathbb R$ via $x^*(f)= \int_0^1 f$. Clearly $||x^*|| \leq 1$. In fact, $||x^*|| =1$. To see this, consider the functions $f_n \in X$ defined by $f_n(t)=1 $ on $[0,1-1/n]$ and $f_n(t) =\frac 1n (1-t)$ on $(1-1/n,1]$. Evidently $ x^*(f_n)=1-\frac{1}{2n}$ and so $||x^*|| \geq 1 - \frac{1}{2n} $ for all $n$.
Notice that $Y = \ker x^*$. It is  well known that $dist(f,\ker x^*) = \frac{|x^*(f)|}{||x^*||} = |x^*(f)|$. Assume that there exists $f$ with norm one such that $|x^*(f)|=|\int_0^1 f |=1$. Since
$$ 1= | \int_0^1 f | \leq \int_0^1 |f| \leq 1$$
we see that $ \int_0^1 |f| =1$ or equivalenty that $ \int_0^1( 1- |f|)=0$. However, $1- |f| \geq 0 $ and so $|f|\equiv 1$. This is impossible since $f(1)=0$.
A nice byproduct of this is that X is not reflexive. Indeed, as we showed $x^*$ does not attain its norm and so by James's theorem we infer that X is not reflexive.
$\textbf{Edit:}$ Generally, if $X$ is a non reflexive space, then by James theorem there exists $x^* \in X^*$ that is not norm attaining. The above shows that $ dist(x, \ker x^*) <1$ for all $x \in  X$ with norm one.
