Proof verification: At most countably many local maxima

I'd appreciate a second pair of eyes on a proof. I want to prove that a function $$f:\mathbb{R}\to\mathbb{R}$$ can have at most countably many strict local maxima. The question has been asked elsewhere on Stack Exchange, but my question is about the validity of the following argument, which isn't discussed.

Assume for contradiction that $$f$$ has uncountably many strict local maxima. For each $$n\in\mathbb{N}$$, define $$E_n=\Big\{x\in \mathbb{R}: f(x)>f(y) \hspace{2mm}\text{for all y such that 0<|x-y|<\frac{1}{n}} \Big\}.$$ For example, if $$x\in E_3$$, then $$x$$ provides a strict local maximum on at least an open interval of radius $$\frac{1}{3}$$. If each $$E_n$$ was at most countable, then $$\bigcup^{\infty}_{n=1}E_n$$ would be countable as well, contrary to assumption. Hence, some set, say $$E_{n_0}$$, is uncountable. Being uncountable, the set $$E_{n_0}$$ has a limit point, $$\xi$$.

But now this gives a contradiction. Let $$\{x_k\}_{k=1}^{\infty}$$ be a sequence in $$E_{n_0}$$ converging to $$\xi$$. Let $$x_i$$ and $$x_j$$ be terms satisfying $$|x_i-\xi|<\frac{1}{2n_0}$$ and $$|x_j-\xi|<\frac{1}{2n_0}$$. Then $$|x_i-x_j|<\frac{1}{n_0}$$ by the triangle inequality. Since $$f(x_i)$$ is a strict local maximum on an interval about $$x_i$$ of radius $$\frac{1}{n_0}$$, we have $$f(x_i)>f(x_j)$$. But for the same reason we must have $$f(x_j)>f(x_i)$$, which is a contradiction.

• For $x\in E_n$ let $U(x)=(x-1/2n,x+1/2n).$ If $x,x' \in E_n$ with $x\ne x'$ then $U(x), U(x')$ are disjoint. So if $E_n$ was uncountable then $\{U(x): x\in E_n\}$ would be an uncountable set of pair-wise disjoint open intervals. – DanielWainfleet May 20 at 5:25
• Your argument is quite sound. As in my previous comment, if $x,x'$ are distinct members of $E_n$ then $|x-x'|\ge 1/n$. This implies that $E_n$ has no limit points so $E_n$ is countable. – DanielWainfleet May 20 at 5:31
The argument is pretty much fine, but what you're really relying on (without mentioning explicitly) is the fact that an uncountable set in $$\mathbb{R}$$ must contain a convergent sequence. This property is essentially just the fact that $$\mathbb{R}$$ cannot contain uncountably many disjoint intervals, which gives you a simpler proof. Your set $$E_{n_0}$$ would be such an uncountable union, giving a contradiction already.
• So in short: it depends on what's in your toolbox already. If you're focusing on sequences, then your argument is the simplest way to go, I think. If you're more focused on the topology of $\mathbb{R}$, then the open interval argument is more natural. – user296602 May 20 at 5:34