Need a help to show $g_S(x)=\operatorname{dist}(x,S)$ is uniformly continuous. $\newcommand{\dist}{\operatorname{dist}}$Suppose $ (X,\rho ) $ is a metric space and $ S $ is a non empty subset of $ X $. Then how to show the function $ g_S:X\rightarrow \mathbb{R} $ given by $ g_{S}(x)=\dist(x,S) $ where $\dist(x,S)=\inf\lbrace \rho (x,s)\mid s\in S\rbrace $ is uniformly continuous?
 A: $\newcommand{\dist}{\operatorname{dist}}$Let $ \varepsilon >0 $. Put $ \delta = \varepsilon $. Then $ \delta >0 $.
Now let $x_1,x_2\in S $ be such that $ \rho (x_1,x_2)<\delta $ and let $s\in S$.
Observe that $ \rho (s,x_1)\leq \rho (s,x_2)+\rho (x_2,x_1) $.
Hence $ \dist(x_1,S)\leq \rho (s,x_1)\leq \rho (s,x_2)+\rho (x_1,x_2) $.
Therefore $ \dist(x_1,S)-\rho (x_1,x_2)\leq \rho (s,x_2) $.
Hence $ \dist(x_1,S)-\rho (x_1,x_2)\leq \dist(x_2,S) $.
Then $ \dist(x_1,S)-\dist(x_2,S)\leq \rho (x_1,x_2) $.
By symmetry $ \dist(x_2,S)-\dist(x_1,S)\leq \rho (x_1,x_2) $.
Hence $ |\dist(x_1,S)-\dist(x_{2},S)|\leq \rho (x_1,x_2) $.
Since $ \rho (x_1,x_2)<\varepsilon $ we have $ |\dist(x_{1},S)-\dist(x_{2},S)|\leq \varepsilon $.
Then $ |g_S(x_1)-g_S(x_2)|\leq \varepsilon $.
Therefore $ g_S $ is uniformly continuous on $ X $.
A: Hint: Use the triangle inequality for two arbitrary argument values $x_1, x_2$ that are close to each other.
A: $\newcommand{\dist}{\operatorname{dist}}$Let $x,y \in X$ Observe that $\dist(y,S) \leq \rho(x,y) + \dist(x,S)$. Similarly, $\dist(x,S) \leq \rho(x,y) + \dist(y,S)$. Hence, $|g_S(x) - g_S(y)| \leq \rho(x,y)$. Uniform continuity follows.
