Suppose that , then so , because we've found an open set around which doesn't intersect . For the other direction we assume that then by the definition there is an open set containing that doesn't intersect , which is equivalent to some existing where we have so we can deduce that
We'll now prove that if is compact then .
Recall that we've proven the distance function continuous, given define the function which is also continuous. Now since was a compact set then by the extreme value theorem we obtain some such that is the minimum value on , that is for any in otherwords this is the infiumum so we conclude that as needed.
We now prove that is the union of all balls whose centers lie in . Let therefore we know that , therefore there must be an such that or else the infimum could not be less than which implies that , therefore .
Now suppose that is in the union, ie there is some such that so then we know that so therefore showing the other inclusion, therefore
If is compact and is open, then there exists some such that . Since is open and then for any we know that ther is some so that thus we may construct the open cover of , since it is compact then we obtain a finite subcover of the form . If we set to be the lebesgue number for this covering, then by considering , then any ball of the form has a diameter less than so we obtain some such that so we have that , since we just proved that , then we are done.
Note that the above is not necessarily true if is not compact, as if we consider the closed set which fails to be compact as it is not bounded, and consider which is open in but if we consider any then there is a such that , to see this for any epsilon ball as we slide up we get aribtrariliy close to the line and thus we eventually break out of the box. Thus we've shown that there is no epsilon neighborhood of which is entirely contained within as needed.