Prove that a metric space $M$ is compact iff for every continuous function $f:M \rightarrow \mathbb{R}$... Prove that a metric space $M$ is compact if, and only if, for every continuous function $f:M \rightarrow \mathbb{R}$, such that $f(x) > 0$ for all $x \in M$, we have $\inf\limits_{x\in M} f(x) >0$
The proof I made is in accordance with the corollary that says: Let $M$ be a compact metric space, and let $f:M\rightarrow \mathbb{R}$ be continuous. Then $f[M]$ is delimited, and there is $x \in M$ such that $f(x) =\inf\limits_{x\in M}f(x)>0$.
$\textbf{If anyone can give me a feedback on my demo. I would be very grateful.}$
Proof: $f[M]$ is a compact subset of $\mathbb{R}$, hence closed and bounded. Now, any bounded set $A\subseteq \mathbb{R}$ has a least upper bound $\sup$ $A$ and a greatest lower bound $\inf A$,
and these two points belong to the closure $\overline{A}$ (why?). But applying this to $A = f[M]$, which
is closed, we conclude that $\sup$ $f[M]$ and $\inf$ $f[M]$ belong to $f[M]$ itself, which is exactly what is being claimed (why?). \
$\square$
 A: If $A$ is a bounded subset of $\Bbb R$, and if $s=\sup A$ then for each $\varepsilon>0$, $s-\varepsilon$ is not an upper bound of $A$ (since $s$ is the least upper bound of $A$) and thereore, there is some $a\in A$ such that $a>s-\varepsilon$. But, since $s$ is an upper bound of $A$, $a\leqslant s$. So, $|s-a|<\varepsilon$. Since this occurs for every $\varepsilon>0$, $s\in\overline A$. For a similar reason, $\inf A\in\overline A$.
And, since $\inf f(M)\in f(M)\subset(0,\infty)$, there is some $m\in M$ such that $f(m)=\inf f(M)$ and, since $f(m)>0$, this proves that $\inf f(M)>0$.
Not this only proves that if $M$ is compact, then $\inf f(M)>0$; it doesn't prove the reverse implication. In order to prove it, suppose that $M$ is not compact. Then there is an unbounded continuous function from $M$ into $\Bbb R$ (you will find a proof here). Let $f$ be such a function. If $f$ has no lower bound, the $\exp\circ f$ is a continuous function from $M$ into $(0,\infty)$ whise infimum is $0$. And if has has a lower bound then,since $f$ is unbounded, you can apply the same argument to $-f$.
