# Proving a function takes a countable amount of values.

Question: If every point is a local maximum point of $$f$$, prove that $$f$$ takes on only a countable set of values.

Attempt: I tried attributing to each point $$x$$, $$2$$ rational numbers $$a_x,b_x$$ such that $$f(x)$$ is the maximum value on $$(a_x,b_x)$$, and since there are is a countable set of rational numbers, there's only a countable set of such intervals and so a countable set of values of $$f(x)$$. However, I can't prove that I can make it so $$a_x\neq a_y$$ or $$b_x \neq b_y$$ for $$x \neq y$$, so I can't remove multiplicities and assume the set of all the intervals is countable. This is where I'm stuck and would love some help.

So for each $$x\in\Bbb R$$, there are $$a_x such that $$f(y)\ge f(x)$$ for all $$y\in (a_x,b_x)$$. By density of $$\Bbb Q$$, wlog $$a_x,b_x\in\Bbb Q$$. If $$a_x=a_\xi$$ and $$b_x=b_\xi$$, then $$f(y)\ge f(x)$$ and $$f(y)\ge f(\xi)$$ for all $$y\in (a_x,b_x)$$, so by considereing $$y=x$$ and $$y=\xi$$, we find $$f(x)\ge f(\xi)$$ and $$f(\xi)\ge f(x)$$, i.e., $$f(x)=f(\xi)$$. But if $$f(x)$$ depends only on $$\langle a_x,b_x\rangle\in\Bbb Q^2$$, $$f$$ can take only $$|\Bbb Q^2|$$-many values.