Lebesgue's number lemma

If the metric space $(X,d)$ is compact and an open cover of $X$ is given, then there exists a number $\delta >0$ such that every subset of $X$ having diameter less than $\delta$ is contained in some member of the cover.
Such a number $\delta$ is called a Lebesgue number of this cover. The notion of a Lebesgue number itself is useful in other applications as well.
Let ${\mathcal {U}}$ be an open cover of $X$ . Since $X$ is compact we can extract a finite subcover $\{A_{1},\dots ,A_{n}\}\subseteq {\mathcal {U}}$ . If any one of the $A_{i}$ 's equals $X$ then any $\delta >0$ will serve as a Lebesgue number. Otherwise for each $i\in \{1,\dots ,n\}$ , let $C_{i}:=X\setminus A_{i}$ , note that $C_{i}$ is not empty, and define a function $f:X\rightarrow \mathbb {R}$ by $f(x):={\frac {1}{n}}\sum _{i=1}^{n}d(x,C_{i})$ .
Since $f$ is continuous on a compact set, it attains a minimum $\delta$ . The key observation is that, since every $x$ is not contained in some $A_{i}$ , the extreme value theorem shows $\delta >0$ . Now we can verify that this $\delta$ is the desired Lebesgue number. If $Y$ is a subset of $X$ of diameter less than $\delta$ , then there exists $x_{0}\in X$ such that $Y\subseteq B_{\delta }(x_{0})$ , where $B_{\delta }(x_{0})$ denotes the ball of radius $\delta$ centered at $x_{0}$ (namely, one can choose as $x_{0}$ any point in $Y$ ). Since $f(x_{0})\geq \delta$ there must exist at least one $i$ such that $d(x_{0},C_{i})\geq \delta$ . But this means that $B_{\delta }(x_{0})\subseteq A_{i}$ and so, in particular, $Y\subseteq A_{i}$ .