TITLE: Is the map sending a continuous function to its period measurable?
QUESTION [12 upvotes]: Let $C(\mathbb{R})$ be the space of continuous functions from $\mathbb{R}$ to $\mathbb{R}$ with the compact-open topology, and the associated Borel $\sigma$-algebra. Consider the function $p$ from $C(\mathbb{R})$ to $\mathbb{R}_{\geq 0} \cup \{\infty\}$ that maps a continuous function to its period, with the convention that non-periodic functions get mapped to $\infty$.
Is the function $p$ a measurable function on $C(\mathbb{R})$? The only way I know of constructing measurable functions is to realize them as iterated lim, limsup, or liminf of a sequence of continuous functions. It's not clear here what continuous functions approximate the period in any reasonable manner.
Questions:

Is there a way to approximate the period of $f \in C(\mathbb{R})$ using a
continuous map from $C(\mathbb{R})$ to $\mathbb{R}$, which on taking appropriate limits, converges to the described function $p$?
Is there some other way of showing that the map $p$ is measurable?

REPLY [21 votes]: Isn't the set $p^{-1}([0, T_0])$ closed for every finite $T_0$? Suppose that $f_n$ has period $T_n \leqslant T_0$ and it converges locally uniformly to $f$. By passing to a subsequence, we may assume that $T_n$ has a limit $T$. Uniform convergence of $f_n$ on $[x, x + T_0]$ implies that $$f(x + T) = \lim f_n(x + T_n) = \lim f_n(x) = f(x),$$ and hence $f$ has period at most $T$.