If $X$ is compact and $Y$ is closed. Show that there exists $x_0 \in X$, and $y_0 \in Y$ such that $|x_0-y_0| \leq |x-y|$ for all $x \in X$, $y \in Y$ Let $X$, $Y$ be subsets of $\Bbb{R}$, with $X$ compact and $Y$ closed. Show that there exists $x_0 \in X$, and $y_0 \in Y$ such that $|x_0-y_0| \leq |x-y|$ for all $x \in X$, $y \in Y$.
If $Z = \{|x-y| : x\in X, y\in Y\}$, then $0$ is a lower bound of $Z$ so there exists $\alpha = \inf Z$. So there is a sequence of elements in $Z$ such that it converges to $\alpha$, this means that there are sequences $(x_n)$ in $X$ and $(y_n)$ in $Y$ such that $\lim |x_n-y_n| = \alpha$. Now, because $X$ is compact, then there is a convergent subsequence of $(x_n)$, $(x_{n_k})$ and it could converge to an $x_0$ in $X$ (because $X$ is closed). But I am stuck here, I think what I need is $(x_n)$ to be convergent but that does not necessarily happen here.

A slightly different solution which avoids sequences altogether:
Define $d(\cdot, Y) : X \to \mathbb{R}$ as $d(x,Y) = \inf_{y \in Y} |x-y|$ for all $x \in X$.
$d(\cdot, Y)$ is continuous on $X$. Indeed, for $x, x' \in X$ and $y \in Y$ we have
$$|x-y| \le |x-x'| + |x'-y|$$
$$|x'-y| \le |x-x'| + |x-y|$$
Taking the infimum over $y \in Y$ yields
$$d(x,Y) \le |x-x'| + d(x', Y)$$
$$d(x',Y) \le |x-x'| + d(x, Y)$$
so $$|d(x',Y) - d(x,Y)| \le |x-x'|$$
so we can conclude that $d(\cdot, Y)$ is continuous on $X$. Since $X$ is compact, there exists $x_0 \in X$ such that $d(x_0, Y) \le d(x,Y)$ for all $x \in X$.
There exists $r > 0$ such that $$d(x_0, Y) = d(x_0, Y \cap B(x_0, r)) = \inf_{y \in Y \cap B(x_0, r)} |x_0 - y|$$ $Y \cap B(x_0, r)$ is now a compact set and the function $y \mapsto |x_0 - y| $ is continuous on $Y \cap B(x_0, r)$ so there exists $y_0 \in Y \cap B(x_0, r)$ such that $|x_0 - y_0| \le |x_0 - y|$ for all $y \in Y \cap B(x_0, r)$.
In particular, $|x_0 - y_0| \le d(x_0, Y \cap B(x_0, r)) = d(x_0, Y)$ so we in fact conclude $|x_0 - y_0| = d(x_0, Y)$.
Therefore, $$|x_0 - y_0| \le |x-y|, \forall x\in X, y \in Y$$
