prove that a function $f$ is uniformly continuous if and only if there exists a modulus of continuity for $f$ Consider two metric spaces $(X,d_X)$, $(Y,d_Y)$, and a function $f: X\to Y$, $f$ is uniformly continuous.
A function $w: [0,\infty)\to [0,\infty]$ is called a modulus of continuity for $f$, if:
$w(0)=0$
$lim_{s\to 0}w(s)=0$
for all $x,z\in X$, $d_{Y}(f(x),f(z))\leq w(d_{X}(x,z))$
Then prove that $f$ is uniformly continuous if and only if there exists a modulus of continuity for $f$.
I think I have an idea on how to prove one direction, suppose there exists a modulus of continuity $w$ for $f$, then fix $\varepsilon>0$, since $lim_{s\to 0}w(s)=0$, there exists $\delta>0$ such that for any $|s|<\delta$, we have $w(s)<\varepsilon$, then we have for any $x,z\in X$ such that $d_{X}(x,z)<\delta$, we have $d_{Y}(f(x),f(z))\leq w(d_{X}(x,z))<\varepsilon$, which means $f$ is uniformly continuous.
Could anyone give me some ideas on how to prove the reverse? Thank you!
 A: Here's a proof of the converse . . .

Suppose $f:(X,d_X)\to (Y,d_Y)$ is uniformly continuous.

Let $\delta_1 > 0$ be such that $d_X(a,b) < \delta_1$ implies $d_Y(f(a),f(b)) < 1$.

Define $w:[0,\infty)\to [0,\infty]$ by
$$
w(s)
=
\begin{cases}
\sup\,\{d_Y(f(a),f(b))\}{\,\large{\mid}\,} d_X(a,b)\le s\}&&\text{if}\;s \le \delta_1\\[4pt]
\infty&&\text{if}\;s > \delta_1
\end{cases}
$$
We'll show that $w$ is a modulus of continuity for $f$ . . .

By definition of $w$, it's immediate that $w(0)=0\;$and it's clear that
$$
d_Y(f(a),f(b))\le w(d_X(a,b))
$$
for all $a,b\in X$.

It remains to show $\lim_{\large{{s\to 0^+}}} w(s)=0$.

It's easily seen that $w$ is nonnegative and non-decreasing, hence
$\lim_{\large{{s\to 0^+}}}=L$ for some $L\ge 0$, where $L=\inf\;w((0,\infty))$.

Let $\epsilon > 0$.

By uniform continuity of $f$, there exists $\delta > 0$ such that $d_X(a,b) < \delta$ implies $d_Y(f(a),f(b)) < \epsilon$, hence by definition of $w$, we get $w(\delta)\le \epsilon$.

Thus $L\le \epsilon$ for all $\epsilon > 0$, hence $L=0$.

This completes the proof.
