# Prove that $f$ is a convex function if $f=d(x,C)$ and $C$ is convex.

Question: Suppose $V$ is a normed space and $f:V \rightarrow \mathbb R$ defined as $f(x)=d(x,C)=\inf_{c \in C}||x-c||_V$ where $C$ is a convex subset of $V$. Prove $f$ is a convex function.

Attempt at a solution: (I would like to know if it is correct to say the first line equals the second line.)

For some $\lambda \in [0,1]$ we have $$f(\lambda x+(1-\lambda )y)=d(\lambda x+(1-\lambda )y,C)=\inf_{c \in C} ||\lambda x+(1-\lambda )y-c||_V=$$ $$\inf_{a, b \in C}||\lambda x+(1-\lambda )y-\lambda a-(1-\lambda )b||_V =$$ $$\inf_{a, b \in C}||\lambda x-\lambda a+(1-\lambda )y-(1-\lambda )b||_V$$ $$\leq \lambda \inf_{a\in C}||x-a||_V+(1-\lambda)\inf_{b \in C}||y-b||_V=\lambda f(x)+(1-\lambda )f(y)$$ So we can conclude $f$ is convex.

Since $C = \{\lambda a + (1-\lambda)b : a,b \in C\}$ ($C$ is convex), it follows that: $$\inf_{c \in C} \|\lambda x+(1-\lambda)y-c\|_V = \inf_{a,b\in C}\|\lambda x +(1-\lambda)y-(\lambda a + (1-\lambda)b)\|_V$$
However, one can argue that your approach is needlessly complicated: just take $a = b = c$ -- since $c = \lambda c+(1-\lambda)c$, the conclusion isn't altered.
$$\inf_{c \in C} g(c)+h(c) = \inf_{c \in C} g(c)+\inf_{c\in C} h(c)$$
which is definitely false in general. (I was brought to this by considering non-convex $C$, where $x,y \in C,\lambda x+(1-\lambda)y \notin C$ clearly invalidates the result.)