I want to prove the following result, I know it is correct:
If $X$ is a Banach Space, $G \subset X$ is a closed linear subspace, $f \in X^*$ is a linear functional, then we have: \begin{equation*} \text{dist}(f,G^\perp) = \sup_{\|x\| \leq 1, x \in G}\left<f,x \right> \end{equation*}
How should we do this? Is $G$ necessarily a closed subspace?
It is clear that $$\text{dist}(f,G^\perp)=\inf_{g\in G^\perp}\sup_{\lVert x \rVert \leq 1}\lvert f(x)-g(x)\rvert\geq \inf_{g\in G^\perp}\sup_{x\in G, \lVert x \rVert \leq 1}\lvert f(x)-g(x)\rvert=\sup_{x\in G, \lVert x \rVert \leq 1}\lvert f(x)\rvert.$$ On the other hand consider $f\rvert_{G}$. By Hahn-Banach extension theorem, there exist an extension of $f$, $\tilde{f}$, such that $\lVert \tilde{f} \rVert=\sup_{x\in G, \lVert x \rVert \leq 1 } \lvert f(x) \rvert$. Notice now that $f-\tilde{f}\in G^\perp$. Thus we also have $$\text{dist}(f,G^\perp)=\inf_{g\in G^\perp}\sup_{\lVert x \rVert \leq 1}\lvert f(x)-g(x)\rvert\leq \sup_{\lVert x \rVert \leq 1}\lvert f(x)-f(x)+\tilde{f}(x)\rvert=\sup_{x\in G, \lVert x \rVert \leq 1} \lvert f(x) \rvert.$$ Which proves the claim.