Let $A,B$ be two compact subsets of $X$ where $(X,d)$ is a metric space.
1.Show that $\exists a\in A; b\in B$ such that $d(a,b)=d(A,B)$
where $d(A,B)=\sup\{d(a,b):a \in A;b\in B\}$
2.Show that $\exists a\in A$ such that $d(a,B)=d(A,B)$
3.Show that $\exists a,b\in A$ such that $d(a,b)=diam (A)$ where $diam(A)=\sup\{d(a,b):a ,b\in A\}$
I can compute for 2 by considering the function $f:X\to \mathbb R$ by $f(x)=d(x,B)$ and then considering its restriction to the set $A$ which is compact and hence the function $f$ will attain its bounds.So there exists $a\in A$ such that $f(a)=d(A,B)\implies d(a,B)=d(A,B)$
Is this correct?
Similarly I can proceed for $3$
But I can't do it for 1 .Any help on how to consider the continuous function
Consider the metric space $(A \times B, D)$, where $D$ is the metric on $A\times B$ defined by $$D((x,y),(a,b)) := d(x,a) + d(y,b)$$
The function $f : (A \times B,D) \to \Bbb R$ given by $f(a,b) = d(a,b)$, for all $(a,b) \in A \times B$, is continuous. For
$$|f(x,y) - f(a,b)| \le D((x,y),(a,b))$$
for all $x,a\in A$ and $y,b\in B$. Since $f$ is a continuous map from a compact metric space, it attains it's supremum, i.e., there exists $(a_0,b_0) \in A \times B$ such that $$f(a_0,b_0) = \sup\{f(a,b): (a,b)\in A \times B\}.$$ That is, $d(a_0,b_0) = d(A,B)$.