Let $A\subset \mathbb{R}^n$ be a convex set. Show that $f:\mathbb{R}^n\to\mathbb{R}$ defined by $f(x) = d(x,A)$ is convex 
Let $A\subset \mathbb{R}^n$ be a convex set. Show that
  $f:\mathbb{R}^n\to\mathbb{R}$ defined by $f(x) = d(x,A)$ is convex

All I need to prove is that:
$$f((1-t)x+ty) = d((1-t)x+ty, A) \le (1-t)f(x)+tf(y) = (1-t)d(x,A)+td(y,A)$$
*for all $t\in[0,1]$ and $x,y\in \mathbb{R}^n$
By using the fact that $A$ is convex. A convex set is defined as:

A set $C$ in $S$(vector space) is said to be convex if, for all $x$
  and $y$ in $C$ and all $t$ in the interval $[0, 1]$, the point $(1 −
 t)x + ty$ also belongs to $C$

and the distance from $x$ to a set $A$ is: 
$$d(x,A) = \inf \{d(x,a), a\in A\}$$
To begin I'd choose a generic $a\in A$ and try to work with it to show that
$$d((1-t)x+ty, a) \le (1-t)d(x,a)+td(y,a)\tag{1}$$
I'm tempted to think something related to the triangular inequality $d(x,y)\le d(x,a) + d(a,y)$ by doing something like:
$$d((1-t)x+ty, a)\le d((1-t)x+ty, b) + d(b,a)\tag{2}$$
for some $b\in \mathbb{R}^n$, but the right side of $(2)$ is already bigger than the right side of $(1)$. Also, I'm not even using the fact that $A$ is convex yet. 
Could somebody help me? 
 A: Let $\epsilon > 0$. There exist $a,b \in A$ such that $d(x,a) - d(x,A) < \epsilon$ and $d(y,b) - d(y,A) < \epsilon$. As $a,b \in A$ and $A$ is convex, $(1-t)a + t b \in A$, so:
$$d((1-t)x + ty, A) \le d((1-t)x + ty, (1-t)a + tb) = \|(1-t)(x-a) + t(y-b)\| \le (1-t) d(x,a) + t d(y,b) < (1-t) (d(x,A) + \epsilon) + t(d(y,A) + \epsilon) = (1-t)d(x,A) + td(y,A) + \epsilon$$
This is true for all $\epsilon >0$. Therefore,
$$d((1-t)x+ty,A) \le (1-t)d(x,A) + td(y,A)$$
A: You can assume without loss of generality that $A$ is closed, since $d(x,A) = d(x,\overline A)$ for all $x \in \mathbb R^n$ and the closure of a convex set is convex.
Let $x,y \in \mathbb R^n$. Then there exist points $a_x,a_y \in A$ with $|x-a_x| = d(x,A)$ and $|y-a_y| = d(y,A)$. 
Let $0 < t < 1$.  Since $A$ is convex you have $ta_x + (1-t)a_y \in A$, so that $$d(tx + (1-t)y,A) \le |(tx + (1-t)y) - (ta_x + (1-t)a_y)| \le t|x-a_x| + (1-t)|y - a_y|$$
where the last expression equals $td(x,A) + (1-t) d(y,A)$.
A: Let $E = \{(x,t) | \exists a \in A \text{ such that } t \ge \|x-a\| \}$. Since $\|\cdot\|$ is convex, it is straightforward to check that $E$ is
convex.
Let $l(x) = \inf_{(x,t) \in E} t $ and notice that $d(x,A) = l(x)$.
Suppose $\lambda \in [0,1]$ and
 $(x_k,t_k) \in E$ for $k=1,2$, then we have
$\lambda (x_1,t_1)+(1-\lambda)(x_2,t_2) \in E$ and
hence
$l(\lambda x_1 + (1-\lambda) x_2) \le \lambda t_1 + (1-\lambda) t_2$.
Now take the $\inf$ on the right hand side over $(x_k,t_k) \in E$ to get $l(\lambda x_1 + (1-\lambda) x_2) \le \lambda l(x_1) + (1-\lambda) l(x_2)$.
