Let $(X,d)$ be an infinite metric space satisfying H1 or H2 or both.
H1: (All continuous functions on X to $\mathbb{R}$ are bounded.)
If $f: X\to\mathbb{R}$ is continuous on $X$, then $f(x)$ is bounded.
H2: (All continuous functions on $X$ to $\mathbb{R}$ attain a maximum.)
If $f: X\to\mathbb{R}$ is continuous on $X$, then there exists at least one point $p \in X $ such that $f(p) \geq f(x)$ for every $x \in X. $
Question
Does H1 only or does H2 only imply $X$ is compact?
Do H1 and H2 together imply $X$ is compact?
Note:
I know " If $X$ is compact then all continuous functions on $X$ to $\mathbb{R}$ are bounded " and " If $X$ is compact then all continuous functions on $X$ to $\mathbb{R}$ attain a maximum ". I am just curious about whether or not the converse still hold.
Properties H1 and H2 are defined for arbitrary toplogical spaces $X$. If $X$ satisfies H1, it is called pseudocompact. See https://en.wikipedia.org/wiki/Pseudocompact_space.
Clearly H2 implies H1. The converse holds for Tychonoff-spaces (= completely regular spaces). See Theorem 27 in
Hewitt, Edwin. "Rings of real-valued continuous functions. I." Transactions of the American Mathematical Society 64.1 (1948): 45-99
Theorem 30 in this paper states that a normal space is pseudocompact if and only if it is compact.
This gives a complete answer to your question.