[proofplan]
Given $\varepsilon > 0$, the preimages $f^{-1}(B(f(x), \varepsilon/2))$ form an open cover of the [compact space](/page/Compact%20Space) $X$. We apply the [Lebesgue Number Lemma](/theorems/952) to obtain a $\delta > 0$ such that every ball of radius $\delta$ in $X$ is contained in some member of this cover. The triangle inequality then shows that $d_X(x, y) < \delta$ implies $d_Y(f(x), f(y)) < \varepsilon$.
[/proofplan]
[step:Construct an open cover from the $\varepsilon$-balls in $Y$]
Fix $\varepsilon > 0$. For each $x \in X$, the set $B(f(x), \varepsilon/2) \subset Y$ is open, so by [continuity](/page/Continuity) of $f$, the preimage $f^{-1}(B(f(x), \varepsilon/2))$ is open in $X$. Since $x \in f^{-1}(B(f(x), \varepsilon/2))$ for every $x \in X$, the collection
\begin{align*}
\mathcal{U} := \bigl\{ f^{-1}(B(f(x), \varepsilon/2)) : x \in X \bigr\}
\end{align*}
is an open cover of $X$.
[guided]
The idea is to translate the $\varepsilon$-challenge in $Y$ back to the domain $X$ via continuity, and then use [compactness](/page/Compact%20Space) of $X$ to find a uniform $\delta$ that works for all points simultaneously.
Fix $\varepsilon > 0$. For each point $x \in X$, the open ball $B(f(x), \varepsilon/2)$ is an open neighbourhood of $f(x)$ in $Y$. Since $f: X \to Y$ is continuous, the preimage $f^{-1}(B(f(x), \varepsilon/2))$ is open in $X$.
Moreover, $x$ itself belongs to this preimage since $d_Y(f(x), f(x)) = 0 < \varepsilon/2$, so these preimages cover all of $X$:
\begin{align*}
X = \bigcup_{x \in X} f^{-1}(B(f(x), \varepsilon/2)).
\end{align*}
We use $\varepsilon/2$ rather than $\varepsilon$ to leave room for the triangle inequality argument that follows.
[/guided]
[/step]
[step:Apply the Lebesgue Number Lemma to obtain a uniform $\delta$]
The space $(X, d_X)$ is [compact](/page/Compact%20Space) and $\mathcal{U}$ is an open cover of $X$. By the [Lebesgue Number Lemma](/theorems/952), there exists $\delta > 0$ such that for every $a \in X$, the ball $B(a, \delta)$ is contained in some member of $\mathcal{U}$. That is, for every $a \in X$ there exists $x_a \in X$ with
\begin{align*}
B(a, \delta) \subset f^{-1}(B(f(x_a), \varepsilon/2)).
\end{align*}
[guided]
This is the step where compactness is consumed. The [Lebesgue Number Lemma](/theorems/952) requires two hypotheses: (i) $(X, d_X)$ is a compact [metric space](/page/Metric%20Space), and (ii) $\mathcal{U}$ is an open cover of $X$. Both are satisfied — (i) by hypothesis and (ii) by the construction in the previous step.
The conclusion of the Lebesgue Number Lemma provides a single $\delta > 0$ that works simultaneously for all points of $X$: for every $a \in X$, the ball $B(a, \delta)$ is contained in some member of $\mathcal{U}$. That is, for each $a \in X$ there exists $x_a \in X$ with $B(a, \delta) \subset f^{-1}(B(f(x_a), \varepsilon/2))$.
This uniform $\delta$ is precisely what distinguishes uniform [continuity](/page/Continuity) from pointwise continuity: it depends only on $\varepsilon$, not on the particular point.
[/guided]
[/step]
[step:Verify the uniform continuity estimate]
Let $a, b \in X$ with $d_X(a, b) < \delta$. Then $b \in B(a, \delta)$, so both $a$ and $b$ belong to $f^{-1}(B(f(x_a), \varepsilon/2))$. This means $f(a), f(b) \in B(f(x_a), \varepsilon/2)$, i.e., $d_Y(f(a), f(x_a)) < \varepsilon/2$ and $d_Y(f(b), f(x_a)) < \varepsilon/2$. By the triangle inequality,
\begin{align*}
d_Y(f(a), f(b)) \le d_Y(f(a), f(x_a)) + d_Y(f(x_a), f(b)) < \frac{\varepsilon}{2} + \frac{\varepsilon}{2} = \varepsilon.
\end{align*}
Since $\delta$ depends only on $\varepsilon$ (and not on the choice of $a$ or $b$), $f$ is uniformly [continuous](/page/Continuity).
[guided]
We now verify that $\delta$ satisfies the definition of uniform continuity. Take any two points $a, b \in X$ with $d_X(a, b) < \delta$.
Since $b \in B(a, \delta)$ and $B(a, \delta) \subset f^{-1}(B(f(x_a), \varepsilon/2))$, the point $b$ lies in $f^{-1}(B(f(x_a), \varepsilon/2))$. By definition of the preimage, $f(b) \in B(f(x_a), \varepsilon/2)$, so $d_Y(f(b), f(x_a)) < \varepsilon/2$.
The point $a$ also lies in $B(a, \delta)$ (since $d_X(a, a) = 0 < \delta$), so $a \in f^{-1}(B(f(x_a), \varepsilon/2))$ as well, giving $d_Y(f(a), f(x_a)) < \varepsilon/2$.
Now both $f(a)$ and $f(b)$ lie within distance $\varepsilon/2$ of the common point $f(x_a)$, so by the triangle inequality:
\begin{align*}
d_Y(f(a), f(b)) \le d_Y(f(a), f(x_a)) + d_Y(f(x_a), f(b)) < \frac{\varepsilon}{2} + \frac{\varepsilon}{2} = \varepsilon.
\end{align*}
This is why we chose $\varepsilon/2$ in the cover construction rather than $\varepsilon$: the triangle inequality introduces a factor of $2$, and splitting $\varepsilon$ in half absorbs it exactly.
The $\delta$ produced by the Lebesgue Number Lemma depends only on the cover $\mathcal{U}$, which in turn depends only on $\varepsilon$ (and $f$). It does not depend on the particular points $a, b$. This completes the proof that $f$ is uniformly continuous.
[/guided]
[/step]