Proving Continuity On A Particular Function I'm working on a problem where $S \subset \mathbb{R}$ arbitrary and I
have a function $f(x) = \inf\{|x-s| : s \in S\}.$ I want to show that
$f$ is uniformly continuous for all $x \in \mathbb{R}.$ I am having issues
figuring out which theorems to use here, since many of the theorems I know
in the topology of functions tend to be related to assuming continuity in
functions. I would like to attempt to do this proof through a set of
bound-based lemmas. For example, if we consider
$$\inf\{|x-s| : s \in S\} \leq |x-t|$$
for any $t \in S,$ then I may be able to say that for all $s,t$ such that
$|s-t| < \delta$,
$$|f(s)-f(t)| \leq |f(s)|+|f(t)| \leq |s-q|+|t-q|$$
for some $q \in S.$ I am having issues moving forward after this.
I think it would
be good to get some help on this since proving continuity will be pretty
important for me in analysis.
 A: I would suggest first of all trying to get an intuitive picture of what $f(x)$ means: you can think of it as the distance from $x$ to the closest point in $\overline{S}$, the closure of $S$ (i.e. $S$ plus all its limit points). Then fix your $\delta$, consider any $x, y$ with $|x - y| \leq \delta$, and let $s$ be one of the closest points in $\overline{S}$ to $x$ (there are at most two, one to the left and one to the right of $x$). Using this $s$, you can show that $y$'s distance to $s$ can't be more than $f(x) + \delta$, and that there can't be any $s' \in S$ less than $f(x) - \delta$ away from $y$, without contradicting the assumption that $s$ was one of the closest $\overline{S}$ members to $x$. Hope this helps.
A: Pick $\varepsilon>0$ and $x,y$. $$\begin{align}
&\exists s\in S:f(x)>|x-s|-\varepsilon\\
&\implies f(x)-f(y)>|x-s|-|y-s|-\varepsilon\quad(\because f(y)\le|y-t|\forall t\in S)\\
&\implies f(y)-f(x)<|y-s|-|x-s|+\varepsilon\\
&\implies|f(y)-f(x)|<|y-x|+\varepsilon\quad(\because||a|-|b||<|a-b|)
\end{align}$$
As $\varepsilon$ is arbitrary, $|f(y)-f(x)|\le|y-x|$.
