Consider a compact topological space $X$ and a map $f:X\to\mathbb{R}$ such that each $x\in X$ has a neighborhood where $f$ attains its minimum. Show that $f$ attains its minimum on $X$.
My attempt:
I was thinking of covering $X$ with all the neighborhoods where $f$ attains a minimum, so something like $X\subseteq \bigcup_{x\in X} U_x$. Then, by compactness, there would be a finite subcover. I don't see how I can conclude that a minimum is attained from this information: I could possibly go over all sets of the subcover and take the overall minimum that $f$ attains (which exists, as the subcover is finite), but am I guaranteed that this minimum is the minimum of $f$ on $X$?
For each $x\in X$ we have open neighborhood $U_x$ of $x$ such that there is $t_x\in U_x$ such that $f(t_x)\leq f(t) \ \forall t\in U_x$.
By compactness of $X$, we have finite subcover $\{U_{x_1},...,U_{x_n}\}$ of $X$.
Hence ,$f(t_{x_i})\leq f(t) \ \forall t\in U_{x_i}$ for $i=1,2,...,n.$
$\min\{f(t_{x_i})\}_{i=1}^n =f(t_0)$ is required minimum.