proof about distance between two sets [duplicate]

Possible Duplicate:
If $A$ is compact and $B$ is closed, show $d(A,B)$ is achieved

Define the distance between two nonempty subsets $A$ and $B$ of $R^n$ by

$dist(A,B):=inf${$||x-y||:x∈A$ and $y∈B$}. Prove that if $A$ and $B$ are compact sets which satisfy $A∩B=∅$, then $dist(A,B)>0$.

(Is it obvious since $A∩B=∅$, then $inf${$||x-y||:x∈A$ and $y∈B$} must$>0$ since $x≠y$?)

-

marked as duplicate by Jonas Meyer, 5PM, Nate Eldredge, Micah, Brian M. ScottJan 28 '13 at 5:40

This question was marked as an exact duplicate of an existing question.

It isn't enough that $A\cap B=\emptyset$ - for instance $A=(0,1)$ and $B=(1,2)$ are disjoint and would have $\text{dist}(A,B)=0$. So you'll need to incorporate compactness in some way. – icurays1 Jan 28 '13 at 4:15

It is not obvious in general, only as they are compact. Look at the easy example of $\left[-1, 0\right), \left(0, 1\right]$: the intervals don't interesect, but are at $0$ distance. Note they are not compact.
OP says we're in ${\bf R}^n$, presumaby with the usual metric topology, so, Hausdorff, for sure. But maybe that's overkill. – Gerry Myerson Jan 28 '13 at 4:54
@Gerry Myerson: Good point. As you know, proof is (or can be made to look) the same in the general setting, and that of $\mathbb{R^n}. However, I will add an edit reflecting your true observation. – gnometorule Jan 28 '13 at 4:59 Define$f:A\times B \to \mathbb{R}$by setting$(x,y) \to \lVert x-y \rVert$. As$f$is continuous and$A\times B$is compact, then there must be$(x,y) \in A\times B$such that$\operatorname{inf}f(A\times B)=dist(A,B)=f(x,y)$. So if$dist(A,B)=0$then$f(x,y)=0$. But$f(x,y)=\lVert x-y\rVert=0$means that$x \in cl(B)=B$, a contradiction. - what is$cl(B)$? – i_a_n Jan 28 '13 at 5:31 @i_a_n : That's the closure of$B$in$\mathbb{R}\$. – Sayantan Jan 28 '13 at 5:44