Prove that f is continuous Let F a set non-empty and closed. Give $x$∈$\mathbb{R}$ and let f(x)=inf{|x-y|, y∈F }.Prove that f is continuous and {$x$∈$\mathbb{R}$, f(x)=0} = F.
 A: If $x\in F$, then $f(x) \le |x - x| = 0$, so $f(x) = 0$. Conversely, if $f(x) = 0$, then for every $\epsilon > 0$, there exists $y\in F$ such that $|x - y| < \epsilon$. So every $\epsilon$-neighborhood of $x$ intersects $F$, which implies $x\in \text{cl}(F)$. Since $F$ is closed, $\text{cl}(F) = F$. Hence $x\in F$.
A: Let $x \in \mathbb R$ and $(x_n)$ be a real sequence converging to $x.$ Set $z_n:= f(z_n)$ and $z = f(x).$ Given $\epsilon >0,$ there is a $N \in \mathbb N$ such that $\forall n \geq N, |x_n - x|< \epsilon/3.$ From this we get, $\forall n \geq N, \forall y \in F, ||x_n-y|-|x-y|| < \epsilon/3.$ By definition, there is a subset $F' \subseteq F$ such that $|z_n -|x_n-y||<\epsilon/3, \forall y \in F',$ and $|z - |x-y||< \epsilon/3, \forall y \in F'.$ Now $$|z_n-z|=|(z_n-|x_n-y|)+(|x_n-y|-|x-y|)-(z-|x-y|)|. $$ Thus $\forall n \geq N, \forall y \in F'$ we have $|z_n-z|< \epsilon.$
A: There are a couple of easy examples of this form, say for instance $f(x) = |x|$ which corresponds to the compact set $\{0\}$. Also $$f(x) = \left\{ \begin{array}{cc} 0 & |x| < 1\\ x-1 & x \ge 1\\ -x-1 & x \le -1 \end{array} \right.$$ which corresponds to $[-1,1]$.
We can demonstrate that $f$ is continuous by using the triangle inequality. Let $x_0 \in \mathbb{R}$. Take $\epsilon > 0$. If $y \in \mathbb{R}$ such that $|x-y| < \epsilon/2$.
Let $w \in F$ be such that $|w-x| < f(x) + \epsilon/2$. Then $$|w-y| < |w-x| + |x-y| < f(x) + \epsilon.$$
Thus we see that $f(y) \le f(x) + \epsilon$ by the infimum.
We need to show that $f(y) \ge f(x) - \epsilon$ as well.
Take $w' \in F$ such that $|w' - y| < f(y) + \epsilon/2$.
Then we see that $$|w'-x| \le |w'-y| + |x-y| < f(y) + \epsilon.$$
Again this means that $f(x) < f(y)+\epsilon$ by the infimum.
Therefore $$f(x) - \epsilon < f(y) < f(x) + \epsilon$$ which means
$$-\epsilon < f(y) - f(x) < \epsilon$$
Therefore we can conclude that $|f(x)-f(y)| < \epsilon$ when $|x-y| < \epsilon/2$.
Finally, if $f(x) = 0$ then there is a sequence $\{w_n\}$ in $F$ for which $|w_n - x| \to 0$. This means that $\{w_n\}$ converges to $x$ in the metric, and since $F$ is closed we have $x \in F$. Conversely if $x \in F$ then $|x-x| = 0$ and therefore $f(x) = 0$.
