# Continuity of function defined with infimum

I am trying to prove the following.

Let $F \subseteq \mathbb{R}$ be nonempty and closed. Show that $$f(x) = \text{inf} \{ \left|x-a\right| : a \in F \}$$ is continuous and that $f(x) \neq 0$ if $x \notin F$.

So far, I have tried fixing a point $c \in \mathbb{R}$ and proposing an arbitrary $\epsilon > 0$, and tried to determine a $\delta > 0$ for which $$\left| x-c \right| < \delta \Longrightarrow \left| f(x) - f(c) \right| < \epsilon.$$ Unfortunately, I have not had much success. Could you guys give me any suggestions of how to start?

• Did you mean to say that $f(x) \neq 0$ if $x \not \in F$?
– user169852
Nov 9 '15 at 18:51
• Ah, yes. I have fixed that mistake. Nov 9 '15 at 18:55
• R here are the real numbers? Nov 9 '15 at 18:55
• Indeed. I have updated the symbols in the main post. Nov 9 '15 at 18:57
• The first part of your question is a duplicate of Distance is (uniformly) continuous Nov 9 '15 at 22:43

We can in fact show that $f$ is uniformly continuous (even better, Lipschitz continuous) as follows. Let $a \in F$. Then by the triangle inequality, we have $$|x-a| \leq |x-y| + |y-a|$$ Taking the infimum over $a \in F$ gives us $$f(x) \leq |x-y| + f(y)$$ Similarly, $$f(y) \leq |x-y| + f(x)$$ and so $$|f(x) - f(y)| \leq |x-y|$$ which gives the desired result.

Now if $x \not\in F$, then $x$ is contained in the open set $F^c$, so there is some neighborhood $(x-\delta, x+\delta)$ contained in $F^c$, where $\delta > 0$. Therefore, every point $y$ satisfying $|x-y| < \delta$ is contained in $F^c$, which means that $f(x) \geq \delta > 0$.

Edit to respond to the question raised in the comment.

Here is more detail on how we obtain $f(x) \leq |x-y| + f(y)$.

For any $a\in F$ we have $f(x) \leq |x-a|$, since $f(x)$ is the infimum of all such $|x-a|$. By the triangle inequality, we have $|x-a| \leq |x-y| + |y-a|$. Combining these inequalities gives us $$f(x) \leq |x-y| + |y-a|$$ Therefore the left hand side is a lower bound for the set $\{|x-y| + |y-a| : a \in F\}$, so it cannot be larger than the greatest lower bound (infimum) of that set: \begin{aligned} f(x) & \leq \inf\{|x-y| + |y-a| : a \in F\} \\ &= |x-y| + \inf\{|y-a| : a \in F\} \\ & = |x-y| + f(y)\\ \end{aligned} Note that the term $|x-y|$ does not depend on $a$, so we can treat it as a constant when we take the infimum over $a \in F$.

• Your answer seems valid. I do have one question though. Why is it valid to say that $f(y) \leq |x−y|+f(x)$ after taking the infimum over $a \in F$? In other words, why is $|x-y|$ not affected by it? Nov 9 '15 at 19:18