Let $X$ be a normed space and $Y$ a linear subspace of $X$. We define $$Y^{\perp}=\{f\in X^*: f(y)=0, \; \forall y\in Y\}$$ and $$\|f\|_Y=\sup\{|f(y)|: y\in Y, \; \|y\|=1\}.$$ Prove that $$\|f\|_Y=\inf\{\|f-g\|: g\in Y^{\perp}\}$$
First of all, given $f\in X^*\backslash Y^\perp$, then for any $g\in Y^\perp$ we get that \begin{equation*} \begin{split} \|f-g\|&=\sup\{|f(x)-g(x)|: x\in X, \; \|x\|=1\}\\ &\geq\sup\{|f(y)+g(y)|: y\in Y, \; \|y\|=1\} \\ &= \sup\{|f(y)|: y\in Y, \; \|y\|=1\}\\ &=\|f\|_Y \end{split} \end{equation*} As $g\in Y^\perp$ was arbitrary, we find that $$\|f\|_Y\leq\inf\{\|f-g\|: g\in Y^{\perp}\}$$ How can I prove the other inequality?
By the Hahn-Banach theorem, there is an extension of $f|_Y$ ($f$ restricted to $Y$), call it $h$, such that $\|h\|=\|f|_Y\|=\|f\|_Y$ and $h|_Y=f|_Y$. So $h-f=g\in Y^\perp$. Hence $\|f\|_Y=\|f+g\|$ and the infimum is attained.