Compact iff the set is closed and bounded

compactnessreal-analysis

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.

Best Answer

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.

Related Question