# Compact iff the set is closed and bounded

My real analysis textbook says that the set $$[0,1] \cup (2,3]$$ has maximum and minimum, but it is not compact. At the same time, the Heine-Borel Theorem says that

A subset $$S$$ of $$\mathbb R$$ is compact iff $$S$$ is closed and bounded.

To my inexperienced eyes, the set $$[0,1] \cup (2,3]$$ is bounded, hence its maximum and minimum, and is also closed $$-$$ therefore according to the theorem it should be compact. Please let me know why I get so wrong $$-$$ thank you.

• $[0,1]\cup(2,3]$ is not closed, why do you think it is? – SmileyCraft Dec 20 '18 at 18:12
• That is exactly the reason I would like to get help. All I know is that a set is closed if its complement is open. Let me know how to show that it is not closed. Thank you. – Amanda.M Dec 20 '18 at 18:14
• $2$ is in the complement, but for any ball of radius $\varepsilon>0$ around $2$, you can find an element not in the complement. Hence the complement is not open. – SmileyCraft Dec 20 '18 at 18:16
• Thank you, that makes sense. – Amanda.M Dec 20 '18 at 18:25

Yes, your set is bounded. But its not closed, since its complement is $$(-\infty,0)\cup(1,2]\cup(3,+\infty)$$, which is not open: $$2$$ belongs to it, but no open interval centered at $$2$$ is contained in it.
• Do you think that henceforth intuitively, I may look at the set as union of two sets, $[0,1]$ as a closed set and $(2,3]$ as open set, and therefore the union is open? Thank you again. – Amanda.M Dec 20 '18 at 18:35
• Ok, I think I got it. But let me make my question a bit more precise: Do you think that henceforth intuitively, I may look at the problem as union of two sets, $[0,1]$ as a closed set and $(2,3]$ as open set, and therefore their union "can not be said as closed"? Thank you again. – Amanda.M Dec 20 '18 at 18:40