# Compact and closed sets.

Let $X, Y \subset \mathbb{R}$ be non empty sets, $X$ is compact and $Y$ is closed. Show that there exists $x_0 \in X, y_0 \in Y$ such that $|x_0-y_0| \le |x-y|$ for all $x \in X$ and $y \in Y$

I was thinking to prove this with sequences and I have this, I take $\alpha = inf \{|x-y| ; x\in X, y \in Y\}$ then there exist sequences of points $x_n \in X, y_n \in Y$ such that $\lim(x_n - y_n)=\alpha$, what I can do next? And, I think that it is necessary that the sets $X, Y$ be disjoints, this is true?

• It's not necessary $X,Y$ be disjoint --- if they aren't, choose $x_0 = y_0$, and the identity holds. I think your idea makes sense, note that $X,Y$ are both closed (compact $\implies$ closed), so contain all their limit points. – Mark Oct 23 '17 at 5:50
• – user 170039 Oct 23 '17 at 5:55

Let $x \in X$. Exists $r \gt 0$ s.t. $B_r(x) \cap Y \ne \emptyset$ and $X \subset B_r(x)$ (this because $X$ is bounded).
The function $f:X \times cl(B_r(x))\cap Y \rightarrow \mathbb R$ defined as $f(x,y)=|x-y|$ is continuous and its domain is compact. So there exists $(x_0,y_0) \in X \times cl(B_r(x))\cap Y$ s.t. $f(x_0,y_0) \le f(x,y)$ for all $(x,y)$ in the domain of $f$. What can you say about $(x_0,y_0)$?
Hint: You may assume $x_n$ is convergent (by passing to a suitable subsequence if needed ) then it makes $y_n$ be convergent and consider their limit points...