Let $(X,d)$ be a compact metric space. Prove that there exists a number $K$ such that $d(x,y)\leq K$ for each $x,y\in X$.

I'm reading Intro to Topology by Mendelson.

The problem statement is in the title.

My attempt at the proof is:

Since $X$ is a compact metric space, for each $n\in\mathbb{N}$, there exists $\{x_1^n,\dots,x_p^n\}$ such that $X\subset\bigcup\limits_{i=1}^p B(x_i^n;\frac{1}{n})$. Let $K=\frac{2p}{n}$. Then for each $x,y\in X$, $x\in B(x_i^n;\frac{1}{n})$ and $y\in B(x_j^n;\frac{1}{n})$ for some $i,j=1,\dots,p$. Thus, $d(x,y)\leq\frac{2p}{n}$.

The approach I was taking is taking $K$ to be the addition of the diameters of each open ball in the covering for $X$, that way, for any two elements in $X$, the distance between them must be less than the overall length of the covering. Did I say this mathematically or are there holes I need to fill in?

Thanks for any help or feedback!

-
The quantor "for each n" is wrong / does not fit to the argument. – Martin Brandenburg Aug 14 '13 at 10:49
I took that part from a lemma that was proved in the book. I think I should have chosen a particular $n$, since it is a for all statement, but I left it arbitrary. Is that what you're referring to? – Shant Danielian Aug 14 '13 at 10:50
Choose $x_0\in X$, and note that $\bigcup_{n=1}^\infty B(x_0,n)\supset X$. – Frank Science Aug 14 '13 at 10:53
Okay. But what should I consider then? I mean, since $X$ is compact there's a finite subcovering and I'm back to what I have above. – Shant Danielian Aug 14 '13 at 10:57

To round off the solutions, you can notice that $X\times X$ is compact, and $d:X\times X\to\mathbb{R}$ is continuous, and so obtains its max.

-
Boom. +1 ${} {} {}$ – Neal Aug 14 '13 at 22:16
This is really nice and clean, thank you. – Shant Danielian Aug 15 '13 at 1:57
But since $X\times X$ is compact and $\mathbb{R}$ a metric space, $d$ is really uniformly continuous right? – Shant Danielian Aug 15 '13 at 1:59
@ShantDanielian That's true. But, of course, as you know, that is stronger than continuity. – Alex Youcis Aug 15 '13 at 5:06

Suppose no such $K$ exists. Let $x$ be in $X$. Then for all $n\geq 1$, there exists an $N$ such that $B_N(x)\setminus B_n(x)\neq\emptyset$. let $\Lambda=\{B_n(x)\mid n\in\mathbb{N}\}$. $\Lambda$ is an open cover of $X$ but no finite subset of $\Lambda$ will cover $X$ because a finite subset has as union its largest ball, which we already know does not contain some element in some larger ball.

-

Suppose $X$ consists of two points a distance of $100$ apart. Take $n=1$ and $p=2$. Your proof implies the two points are a distance of $4$ apart.

-
So is what your saying, I can find a tighter upper bound? Or am I overseeing something? I don't quite understand how the triangle inequality comes into play. – Shant Danielian Aug 14 '13 at 10:52
Your proof does not work, because the $K$ you construct does not work. You are not considering the possibility that the balls might not overlap, but rather might be far apart. – Isaac Solomon Aug 14 '13 at 10:54
I see. So what you're saying is if many of them do overlap, but some are very far way from one another, the upper bound I constructed wouldn't necessarily hold, since the distance between two elements can be greater than all those additions? – Shant Danielian Aug 14 '13 at 10:55
That's exactly what I'm saying. – Isaac Solomon Aug 14 '13 at 14:17

Fix $p\in X$, then the function $f:X\to\mathbb{R}_+:x\mapsto d(x,p)$ is a continous function on a compact space $X$. Hence it is bounded, i.e. there exist $K>0$ such that for all $x\in X$ holds $d(x,p)\leq K/2$. Now take arbitrary $x,y\in X$, then $$d(x,y)\leq d(x,p)+d(p,y)\leq K$$

-
When you say 'Hence it is bounded...', are you implicitly using the results 'The continuous image of a compact space is compact' and 'every compact subset of $\mathbb{R}$ is bounded'? – Dan Rust Aug 14 '13 at 12:55
@DanielRust yes this is standard result from baby Rudin – Norbert Aug 14 '13 at 12:56
Ok, just wanted to make sure as it wasn't clear how you got straight to the function being bounded. – Dan Rust Aug 14 '13 at 13:09

By compactness, there are finitely many points $x_1, x_2, \ldots, x_n$ such that $$X = \cup_{i=1}^n B(x_i, 1)$$ Now for any two points $x, y \in X$, choose $x_i$ and $x_j$ such that $$d(x, x_i) < 1 \qquad d(y,x_j) < 1$$ Then $$d(x,y) \leq d(x,x_i) + d(x_i, x_j) + d(x_j, y) < 2 + d(x_i, x_j)$$ So choose $$K = 2 + \max\{d(x_i,x_j) : 1\leq i, j \leq n\}$$

-
Where does the middle term $d(x_i,x_j)$ come from though? – Shant Danielian Aug 14 '13 at 11:05
@ShantDanielian Triangle inequality: $d(x,y) \leq d(x,x_j) + d(x_j,y) \leq d(x,x_i) + d(x_i,x_j) + d(x_j,y)$. Breaking the trip from $x$ to $y$ down into a zig-zag. – Neal Aug 14 '13 at 12:18
I see, thanks for clearing that up Neal. – Shant Danielian Aug 15 '13 at 2:01