While I'm taking an interruption from discussing compact sets, I want to pick up one more topic that I overlooked when I was talking about closure. This is the idea of connected sets. Connectedness has an intuitive meaning, but we want to define it formally so we can use it mathematically. And as often happens, it's easier to define it by defining the opposite.
Let's look at separated sets. If A and B are two sets in some metric space X, they are separated if they don't touch each other. Formally, what does "don't touch each other" look like? Two sets are separated if, for both pairs of sets, the intersection of one set with the closure of the other contains no points.
Here are some examples on the real number line. Suppose set A is all real numbers greater than or equal to 0, and set B is all real numbers less than or equal to 0. A and B are pretty clearly not separated. For one thing, they both contain the point 0. For another, the union of the two sets is the entire real number line, and if they were separated, you would expect to be able to say that there is a gap of some kind between them.
Let's keep A as the set of real numbers greater than or equal to 0, but exclude 0 from B, so B is now the set of real numbers strictly less than 0. Now the sets don't have any points in common (the intersection of the two sets is the null set), but the union of the two sets is still the entire number line. There's no gap. So, the closure of B includes the point 0, and the intersection of A and the closure of B now does contain a point, so the sets are not separated.
Note that the closure of A is A, so the intersection of the closure of A and B still does not contain any points. That's okay. Either A∩B contains a point, or A∩B contains a point. They do not both have to contain points in order for the sets to not be separated.
Finally, exclude 0 from A as well. Now A is the set of real numbers strictly greater than 0, and B is the set of real numbers strictly less than zero. The union of the two sets is not the real number line, and the point 0 is a gap between the two sets. The gap has a radius of 0, but mathematically, it still exists. Now A∩B includes the point 0, but that doesn't matter. Neither A∩B nor A∩B contain any points, so the sets are separated.
Really, this all makes intuitive sense, and it doesn't really get more complicated with more complicated spaces or more complicated sets. Two sets do not have to overlap in order to touch each other, but there can't be a gap between them. If two sets don't touch each other, then they are separated.
Now that we have defined separated, we can define connected. A set E, in some metric space X, is connected if it cannot be represented as the union of two separated sets. If some sets A and B exist, such that E = A∪B and A and B are separated, then E is not a connected set. If for any two sets A and B, such that E = A∪B, A and B are never separated, then E is a connected set.
This definition is obvious, but it's also useful, so it's good to go through the trouble of formally defining it now.