Let (X,d) be a metric space, A and B be subsets of X so that d(A,B)>0 where
d(A,B)=inf{d(a,b):a∈A,b∈B}.
Show that,
if A and B are compact, then dist(A,B)=d(a,b) where a and b are elements of A and B sets respectively
How can I proove this? Can someone provide me a reference to this proof?
Actually a weaker assumption that $A$ is compact and $B$ is closed gives the same conclusion. By the definition of infimum you can find sequences $\{a_n\}$ in $A$ and $\{b_n\}$ in $B$ such that $$d(a_n,b_n)\to d(A,B)$$ Since $A$ is compact, there is a subsequence $\{a_{n_k}\}$ converging to some $a\in A$. And we have $$d(a,b_{n_k})\leq d(a_{n_k},b_{n_k})+d(a,a_{n_k})\to d(A,B)+0=d(A,B)\quad(k\to\infty)$$ meaning $\{b_{n_k}\}$ is a bounded set of points, and hence has a further convergent subsequence $\{b_{n_{k_j}}\}$ to some $b$. Since $B$ is closed, $b\in B$.
Combining the above we have $$d(a,b)\leq d(a,a_{n_{k_j}})+d(a_{n_{k_j}},b_{n_{k_j}})+d(b_{n_{k_j}},b)\to 0+d(A,B)+0=d(A,B)$$ Hence $d(a,b)\leq d(A,B)\leq d(a,b)\implies d(a,b)=d(A,B)$