A small problem regarding compactness. Recently I saw a problem of compactness,it is as follows: 
Let $A$ be compact and $U$ be open in a metric space $X$ such that $A\subset U$.Show that for some $\epsilon>0$,$\{x\in X: d(x,A)<\epsilon\}\subset U$. 
I solved the problem in the following manner.For each $a\in A$,choose $r_a>0$ such that $B(a,r_a)\subset U$.Consider the open cover $\{B(a,r_a/2): a\in A\}$ of $A$.Since $A$ is compact,so it has a finite subcover,say $\{B(a_i,r_i/2):i=1,2,...,k\}$,Set $\epsilon=\min_i(r_i/2)$.Now,take any $x \in X$ such that $d(x,A)<\epsilon$,Since $A$ is compact $\exists a\in A$ such that $d(x,A)=d(x,a)$.Then $d(x,a)<\epsilon$.Now $a\in A$,so $a\in B(a_i,r_i/2)$ for some $i=1,2,...,k$.Now $d(x,a_i)\leq d(x,a)+d(a,a_i)<\min_i(r_i/2)+r_i/2<r_i$.So $x\in B(a_i,r_i)\subset U$ and we are done.Is this proof correct or it can be done in an easier way.What is the intuition behind this problem?
 A: Your proof is correct. An alternative aproach is to look at the function
$$f: X \rightarrow \mathbb{R}: x \mapsto d(x, U^c).$$
This function is continuous and hence it attains its minimum on compact sets. In particular there exists $x \in A$ such that $f(x) = \inf \{ d(x,U^c) \mid x \in A \} \geq 0$. We claim that $f(x) >0$. Because $x \in K \subset U$ and because $U$ is open there exists $\delta >0$ such that $B(x,\delta) \subset U$. However this means that $f(x) = d(x,U^c) \geq \delta$. In particular $\inf \{ d(x,U^c) \mid x \in A \} \geq \delta$, which we had to show.  
For the intuition: as you know, any closed set is not the intersection of finite open sets. This means in particular that there is no smallest open set around the closed set.
However for non-compact sets $A$ that are closed (for example $\mathbb{R} \subset \mathbb{C}$) we can find open sets containing  $A$ that approximately meet $A$ in the sense that the complement of an open gets arbitrary close to $A$. This is not possible for compact sets because there is always a non-zero minimum distance between the two.
