Let $X$ be a compact metric space and $f:X\to \mathbb{R}$ be continuous with $f(x)>0$ for each $x\in X$. Prove inf{$f(x):x\in X$}$>0$. 
Let $X$ be a compact metric space and $f:X\to \mathbb{R}$ be continuous with $f(x)>0$ for each $x\in X$. Proceeding directly from the definitions of continuity and
compactness, prove inf{$f(x):x\in X$}$>0$.


Give an example of a bounded set $X$ and a continuous function $f$ for which the above
property does not hold.

Actually, our class hasn't yet covered theorems related to continuity and compactness (this is the name of a little section in Baby Rudin Chapter 4). I believe that's the reason why the problem explicitly states this;

Proceeding directly from the definitions of continuity and
compactness

But, I have no idea how to use compactness to prove this.
 A: Take $\mathcal{O}_n=\big(\frac{1}{n},\infty\big)\subseteq\mathbb{R}$ and notice $\bigcup_{n=1}^{\infty}\mathcal{O}_n=(0,\infty)$. Hence $$X=f^{-1}(0,\infty)=f^{-1}\Bigg[\bigcup_{n=1}^{\infty}\mathcal{O}_n\Bigg]=\bigcup_{n=1}^{\infty}f^{-1}(\mathcal{O_n})$$ Since $f$ is continuous, $\big\{f^{-1}(\mathcal{O_n})\big\}_{n=1}^{\infty}$ is an open cover of $X$, and, with compactness, there is a finite subcover, namely $$\Big\{f^{-1}(\mathcal{O}_{n_1}),\dots,f^{-1}(\mathcal{O}_{n_k})\Big\}$$ Without any loss of generality assume $n_1<\dots<n_k$. Evidently $$f^{-1}(\mathcal{O}_{n_1})\subseteq \dots \subseteq f^{-1}(\mathcal{O}_{n_k})$$ which implies $$X=\bigcup_{j=1}^k f^{-1}(\mathcal{O_{n_j}})=f^{-1}(\mathcal{O_{n_k}})$$ So, if $x\in X$ is arbitrary, then $f(x)\in \mathcal{O}_{n_k}$ which means $f(x)>\frac{1}{n_k}$. This shows $\frac{1}{n_k}$ is a lower bound of $X$. Now since $\inf\{f(x):x\in X\}$ is defined as the greatest lower bound of $f(X)$ it follows that $$0<\frac{1}{n_k}\leq \inf\{f(x):x\in X\}$$ and the proof of $(a)$ is complete. For $(b),$ you make consider taking $$X=\{(x,y)\in \mathbb{R}^2:x^2+y^2<1\}\text{ and } f(x,y)=1-\sqrt{x^2+y^2}$$
A: $\def\N{\mathbb{N}}$
I assume you have seen the following definition for compactness on a metric space : $X$ is compact iff every sequence $ \in X^\N$ has a subsequence that converges in $X$.
So to use compactness with this, one must introduce so relevant sequence. With an infimum problem, a very relevant sequence is to take a sequence from the considered set that converges to this infimum. So here, we consider a sequence $(x_n)_{n \in \N} \in X^\N$ such that $f(x_n) \xrightarrow[n \to +\infty]{} \inf\{ f(x) \mid x \in X\}$.
By compactness of $X$, we can extract a subsequence $(x_{\varphi(n)})_{n \in \N}$ such that $x_{\varphi(n)} \xrightarrow[n \to +\infty]{} y$ for some $y \in X$. Then we have :

*

*As $f$ is continuous,  $$f(x_{\varphi(n)}) \xrightarrow[n \to +\infty]{} f(y) ;$$

*As $(f(x_{\varphi(n)}))_{n \in \N}$ is a subsequence of $(f(x_n))_{n \in \N}$, they share the same limit and therefore
$$f(x_{\varphi(n)}) \xrightarrow[n \to +\infty]{} \inf\{ f(x) \mid x \in X\}.$$
By unicity of the limit, we get
$$\inf\{ f(x) \mid x \in X\} = f(y).$$
AS $f(y)>0$ by assumption, we get $\inf\{ f(x) \mid x \in X\} >0$.
