compact set always contains its supremum and infimum
Let $K$ be a compact subset of $\mathbb R$. Prove that $\sup K$ and $\inf K$ exist and are in $K$.
My approach: As $K$ is compact, it is bounded. So $\sup K$ and $\inf K$ exists. The reason is that:
Since $K$ is compact, there exist $k_1, \cdots , k_n \in \mathbb R$ such that
$$K \subset \bigcup_{j=1}^n (-k_j,k_j)$$
If $N = \max\{k_1,\cdots, k_n\}$, then $K$ is a subset of $(-N,N)$. Hence $K$ is bounded. since $K$ is bounded by $-N$ and $N$, $\sup K$ and $\inf K$ exists.
Is this good enough? Is boundedness guaranteed the existence of supremum and infimum?
Generally, it's easier to work with open sets than with closed sets. Open sets have less structure: all their points are interior. Closed sets may have two kinds of points: interior and boundary.
So, I would rather look at $\mathbb R\setminus K$. If $\sup K\in \mathbb R\setminus K$, then by openness, there is an interval $(a,b)$ contained in $\mathbb R\setminus K$ and containing $\sup K$. Show that $a$ is an upper bound for $K$, and you have a contradiction.
Is closed condition necessary for $\inf$ and $\sup$ [to be contained in the set]?
It's essential for the proof (i.e., we can't just drop it), but it's not necessary in the sense that some sets contain their $\inf$ and $\sup$ without being closed. For example, $[-2,1) \cup (1,2]$.
As $K$ is compact, we have that $K$ is bounded. So $\sup K$ and $\inf K$ exists. By definition $\sup K$, for every $n \in N$ exists $x_n \in K$ such that $\sup K- x_n<1/n$ then $\sup K = \lim x_n$ with $x_n \in K$, as K is closed follows that $\sup K \in K$. To inf is analogous. Ps: Compact ⇒ closed and bounded.