Show that a compact set of real numbers contains its greatest lower bound and its least upper bound.

Show that a compact set of real numbers contains its greatest lower bound and its least upper bound. Can this occur for a set of real numbers that is not compact?

My attempt:

By Hein-borel theorem, compact set is closed and bounded, hence glb and lub exists in the set. Am I correct?

Is it true for non compact subset?

• For non-compact set consider $(0,1)$. Niether the glb nor the lub belong to the set. – Sahiba Arora Aug 1 '17 at 16:19

You are correct for the compact set and for non compact set is not true for example $[0,1[$ is bounded, non compact and it does not contain his upper bound 1
Your reasoning is fine. However, this can also hold for non-compact sets; consider: $$[-2,-1) \cup (0,1]$$
Let be $K$ a compact subset of $\mathbb R$. Heine-Borel yields that $K$ is bounded hence it has a greatest lower bound $R$ and a least upper bound $r$.
Since $R$ is the least upper bound, there exists a sequence $(x_n)_n\subset K$ such that $x_n\to R$. Since $K$ is closed by Heine-Borel we conclude $R\in K$. Analogous we get $r\in K$.