Every point takes local maximum value If $f:\mathbb{R}\to\mathbb{R}$ and every point takes a local maximum value, it's a fact that the local maximum values of a real function can only have countable, so if we assume $f$ is continuous we have $f$ must be constant. My question is, if $f$ isn't continuous, can we prove there must be some interval that $f$ is constant on it?
 A: I think your conclusion is right. I've written a proof, please help me check if it's right.
Since "local maximum values can only be countable", we assume they are $\{a_n\}_n$. And let $F_n=\{f=a_n\}$. Then $\mathbb{R}=\bigcup_{n\geq1}F_n$.
Due to Baire's theorem, there is a $n_0$ such that $F_{n_0}$ is dense in an open interval (expressed as $U$).
Because $\{f=a_{n_0}\}$ is dense in $U$, it's easy to prove that $f(x)\geq a_{n_0}$ in $U$.
Assume that $x_0\in\{f=a_{n_0}\}$ is not an interior point of $\{f=a_{n_0}\}$ in $U$. In other words, $ \exists\{x_n\}_n\bigcap\{f=a_{n_0}\}=\emptyset$ such that $x_n\to x_0$. However, it can't be correct because $x_0$ is a local maximum.
Then we know $\{f=a_{n_0}\}$ has an interior point $x_0$ and we arrive at your conclusion. What's more, since $x_0$ is arbitrary, we know that $F_{n_0}\cap U$ is open too.
A: Suppose that $ f\colon {\mathbb R}\to{\mathbb R}$ is a function such that it has a local maximum at each point of $[a,b]$ but it is not constant on any interval.
By induction we can construct a sequence of points $x_i$ and closed intervals with the properties:


*

*$x_i$ is a local maximum on $I_i$;

*$f(x_{i+1})<f(x_i)$;

*$I_{i+1}\subseteq I_i$;

*$\operatorname{diam} (I_i)\searrow 0$.


Inductive step: Since $f$ is not constant on $I_i$, there is a point $x_{i+1}\in I_i$ such that $f(x_{i+1})<f(x_i)$. Since $f$ has a local maximum at $x_{i+1}$, there is a neighborhood of $x_{i+1}$ on which the values are at most $f(x_{i+1})$. We can take a smaller closed interval $I_{i+1}$ in this neighborhood such that, at the same time, $I_{i+1}\subseteq I_i$ and $\operatorname{diam} (I_i) \le 2^{-i}$.
By Cantor Intersection Theorem there is a unique point $x\in\bigcap\limits_{i\in\mathbb N} I_i$. Clearly, $\lim\limits_{i\to\infty} x_i=x$. We also have $f(x)<f(x_i)$ for each $i\in\mathbb N$ (since $x\le f(x_{i+1})<f(x_i)$). So $x$ is not a local maximum, which is a contradiction.

This is the approach I have taken when trying to solve Exercise 10.S from the book van Rooij, Schikhof: A Second Course on Real Functions. See also here.
