# If $F$ is closed and $g:\Bbb R\to\Bbb R$ show that $g(x)=\inf\{|x-a|:a\in F\}$ is continuous

First attempt: I want to show that because $g(x)$ is the composition of continuous functions then is continuous but I dont know how to show that if

$$\min\{d_1,d_2\}=\frac12(d_1+d_2-|d_1-d_2|),\text{ with }d_k=|x-a_k|: a_k\in F$$

is continuous, because is a composition of continuous functions (absolute value is continuous) and of course the iterated but finite version $\min\{d_1,...,d_n\}$ is continuous then the infinite countable version still is continuous i.e.

$$\text{If }\min\{d_1,...,d_n\}\text{ is continuous }\overset{??}{\implies}\min\{d_1,d_2,...\}\text{ is continuous }$$

and from here ending in the uncountable version that is what I want to prove. Can you help me?

Second attempt: I can try to proof the same by contradiction, i.e. if $g(x)$ is not continuous then and cause $\forall x\in\Bbb R\implies x\text{ is a limit point of }\Bbb R$ then for some $c\in\Bbb R$

$$\lim_{x\to c}g(x)\neq g(c)$$

then

$$\forall\varepsilon>0,\exists\delta>0:0<|x-c|<\delta\implies|f(x)-L|<\varepsilon \land L\neq f(c)$$

If I took $\varepsilon=1$ then

$$0<|x-c|<\delta\implies|d(x,F)-L|<1 \land L\neq d(c,F)$$

but Im lost, I dont know how to show the contradiction, can you help me or let me some hint? Thank you in advance.

• Try to prove more, that $\lvert g(x) - g(y)\rvert \leqslant \lvert x-y\rvert$. If you want to prove that stronger assertion, it's easier to see how to do it, I think. – Daniel Fischer May 29 '16 at 19:30
• This is true for an arbitrary metric space; that is, if $F$ is closed in $(X,d)$ then the map $g$ on $X$ defined by $x\mapsto \inf\{d(x,a):a\in F\}$ is continuous. To prove this, let $x_n$ be a sequence in $X$ which converges to $x$ and show that $g(x_n)\to g(x)$. – Math1000 May 29 '16 at 19:39

I did a different proof (weaker than these advised in the commentaries but enough), realizing that for any closed $F\subset\Bbb R$ I can reduce the question to a finite composition of continuous functions so I dont need to prove anything about infinite compositions.

If $c\in F^\circ$ then is obvious than $g(x)$ is continuous because $\forall c\in F^\circ,\exists V_\varepsilon(c)\subset F^\circ$ and $\inf\{|x-a|:a\in F\}=0,\forall x\in F$.

If $c\notin F$ then $c$ belongs to some open interval $A\subset F^c$ and is easy to see that

$$\forall c\in A,\inf\{|c-a|:a\in F\}=\min\{|c-a_1|,|c-a_2|\}$$

where $\{a_1,a_2\}=A'=\overline{A}\cap F$.

And if $c\in F\cap F^\circ$ then for enough small neighborhood of $c$ then $(x_n)\in F:(x_n)\to c$ OR $(x_n)\in A:(x_n)\to c$. The first is a constant sequence equal to zero and the second is a sequence that converges to zero.

In any case everything is reduced, at most, to a function of the kind $\min\{d(a_1,x),d(a_2,x)\}$ what is continuous because is a finite composition of continuous functions.