Distance of compact sets- Proof without subsequence convergence and continuity There are many examples of this question in this platform, but what I am looking is a proof that uses open neighborhoods i.e., topological properties.

Let $X$ be metric space $A,B$ compact and define
  $$dist(A,B)=\inf\{ d(x,y):x\in A,y\in B \}
$$
  Prove that there exists $a\in A$ and $b\in B$ such that $dist(A,B)=d(a,b)$

As I said I am aware one can prove this by using every sequence in a compatc set has a convergent subsequence in the set, or by using continuity of the distance functions. However, I tried to prove by using open sets. Here is what I attempt:
Suppose $A\cap B=\emptyset$ otherwise the result is trivial. Now for each $y\in B$ there exist open neighborhood $U_y$ such that $U_y\cap A=\emptyset$. If not some $y\in B$ will be limit point of $A$ which implies $y\in A$ due to compactness, but this contradicts $A\cap B=\emptyset$. Similarly, for each $x\in A$ there exists $V_x$ such that $V_x\cap B=\emptyset$. We can cover $A$ with $\{V_x\}$ and $B$ with $\{U_y\}$. By compactness
$$
A\subset \bigcup_{i=1}^n V_i=\mathcal{V} \text{ and } B\subset\bigcup_{j=1}^mU_j=\mathcal{U} 
$$ 
Plainly $A\cap \mathcal{U}=\emptyset$ and $B\cap\mathcal{V}=\emptyset$. From here I tried various things without any success. So any help from here or the proof without using previously mentioned methods are greatly appreciated. Thanks!
 A: Let $d(A,B)=:\rho$. If there is no  pair of points $(a,b)\in A\times B$ with $d(a,b)=\rho$ then for each pair $(x,y)\in A\times B$ there is an $\epsilon>0$ (depending on $x$ and $y$) such that $d(x,y)\geq\rho+3\epsilon$. The triangle inequality allows to conclude that $d(x',y')\geq\rho+\epsilon$ for all $(x',y')\in U_\epsilon(x)\times U_\epsilon(y)$.
Since $A\times B$ is compact finitely many "boxes" $U_{\epsilon_k}(x_k)\times U_{\epsilon_k}(y_k)$ will cover $A\times B$. Put $\epsilon_*:=\min_k \epsilon_k$. Then $$d(x,y)\geq\rho+\epsilon_*\qquad\forall x\in A,\quad\forall y\in B\ ,$$
contradicting the definition of $\rho$.
A: It is nonsense to only use general properties: this statement only makes sense in the context of a metric space, so we have to use something specific involving the metric $d$.
The standard proof I know, which does use a mix of general principles and the metric $d$:
As usual: define $d(x,B) = \inf \{d(x,b) : b \in B\}$.
For any metric $d$, and any subset $B$, the function $d_B: X \to \mathbb{R}$ defined by $x \to d(x,B)$ is continuous.  (The usual proofs involve some triangle inequalities so are metric-specific, and show the stronger statement that $|d_B(x) - d_B(y)| \le d(x,y)$ ; a Lipschitz condition). 
So $d_B$ assumes a minimum on the compact $A$. Say for $a_0 \in A$.
(This is generally true for a continuous map from a compact space into an ordered space, and can be proved using the open cover definition). 
But also $d_{\{a_0\}}(x)=d(a_0, x)$ defined as above, is continuous and assumes a minimum on the compact $B$, say in $b_0$. 
But then for any $a \in A, b \in B$ we have $d(a_0, b_0) \le d(a_0,b) \le d_B(a_0) \le d_B(a) \le d(a,b)$, showing $d(a_0, b_0)$ is the required minimum.
So it follows from certain functions defined from the metric being continuous and then applying the minimum principle for maps on compact spaces twice. This approach avoids using the product topology.
If that's no problem: we can just use simply that $d: X \times X \to \mathbb{R}$ is a continuous map on $X \times X$ and $A \times B$ is compact, and so $d$ assumes the minimum in $d(a_0, b_0)$. But often the above is an exercise before product topologies are treated, e.g.
The subsequence argument is another way to go, which seems to be a popular idea (mostly from analysis-oriented people).
A: You may observe that $d$ as a function from $X × X$ to $\mathbb{R}$ is continuous, and so it attains its minimum on the compact set $A × B$.
Note that this proof even doesn't choose which definition of compactness to use. It moves the work to the proof of the latter theorem.
