if $A,B \subseteq \Bbb R^n, A \cap B = \emptyset$ , $A$ compact and $B$ closed then the distance is achieved. For 2 sets $A,B \subseteq \Bbb R^n$ such that $A \cap B$ = $\emptyset$, denote: $d(A,B):=$ inf$\{||x-y|| : x\in A, y \in B    \}$.
Show that if $A$ is compact and $B$ is closed, then there exists $a^* \in A, b^* \in B$ such that $||a^*-b^*|| = d(A,B).$
I'm trying to prove it using extreme value theorem. I thought about something like
defining $f:A \to B, f(a)= \inf\{||a-b|| : b \in B \}$, but I don't know whether this function is even continous. Any ideas? other options of proof are great too.
 A: Show the function $\phi(a) = \inf_{b \in B} \|a-b\|$ is continuous.
$\|a'-b\| \le \|a-b\| + \|a'-a\|$, so
$\phi(a') \le \|a-b\| + \|a'-a\|$ and then
$\phi(a') \le \phi(a) + \|a'-a\|$. Reversing the rôles of $a,a'$ shows
that $\phi$ is Lipschitz of rank 1.
Hence there is some $a^*$ such that $\phi(a^*) = \min_{a \in A} \phi(a)$ and so $\inf_{b' \in B} \|a^*-b'\| \le \|a-b\|$ for all
$a \in A, b \in B$.
Now choose any $\tilde{b} \in B$ and let $R = \|a^*- \tilde{b}\|$, then we have
$\inf_{b \in B} \|a^*-b\| = \inf_{b' \in B \cap \overline{B}(a^*, L)} \|a^*-b'\|
 $ and since $B \cap \overline{B}(a^*,L) \subset \mathbb{R}^n$ is compact (because it is closed & bounded) we see that there is some $b^*\in B$ such that
$\|a^*-b^*\| = \phi(a^*) \le \|a-b\|$ for all
$a \in A, b \in B$.
Aside:
The result relies on the fact that a closed bounded set in $\mathbb{R}^n$ is compact which is not always true in a Banach space.
See Ex. 4 in Ch. 5 of Rudin's "Real & Complex Analysis". It
describes a closed convex set which has no point of minimal norm (so you would take $A = \{0\}$).
A: Remark that since $A$ is compact, $d_A:A\times A\rightarrow \mathbb{R}$ is bounded, we denote by $diam(A)=sup d(x,y),x,y\in A$.
Let $x_0\in A, y_0\in B$. Let $B_1\subset B$ defined by $B_1=\{y\in B$ such that $\inf(d(y,A)\leq d(x_0,y_0)\}$. $B_1$ is bounded, if not there exist $x_n\in A,y_n\in B$ such that $d(x_n,y_n)\leq d(x_0,y_0)$ and $d(y_0,y_n)>n$. we have $d(y_0,y_n)\leq d(y_0,x_0)+d(x_0,x_n)+d(x_n,y_n)\leq 2d(x_0,y_0)+d(x_0,x_n)\leq 2d(x_0,y_0)+diam(A)$. Contradiction.
This implies that $B_1$ is closed and bounded thus compact.
Let $d_1:A\times B_1\rightarrow \mathbb{R}$ by the restriction of the distance, it is continuous, since $A\times B_1$ is compact, there exists $x_1\in A, y_1\in B_1$ such that $d(x_1,y_1)=inf d(x,y), x\in A, y\in B_1$. $d(x_1,y_1)=d(A,B)$.
