How to show this is a Borel function? Let $f: [0,1]\to \mathbb R$ be a continuous function. For all $y\in\mathbb R$, let $N(y)\in\bar{\mathbb R}$ be the number of solutions of the equation $f(x)=y$. Show that N is a Borel funtion.
My thought: I believe I need to show $N^{-1}(A) =B$ where $A$ is open and $B$ is a borel set. Since $N(x)$ only gives integer output (and infinity), so  it doesn't matter if $A$ is open or not..... (what's next?)
 A: Here's a kind of roundabout way.  Probably there is something slicker.
Let's consider instead the same question for continuous $f : C \to \mathbb{R}$, where $C$ is the Cantor set.  For any given $n$, we can partition $C$ into $2^n$ disjoint compact sets $C_{n,1}, \dots, C_{n,2^n}$, each of which has diameter $3^{-n}$.  Now $f(C_{n,i})$ is compact, so $1_{f(C_{n,i})}$ is Borel, and so is
$$N_n := \sum_{i=1}^{2^n} 1_{f(C_{n,i})}.$$
That is, $N_n(y)$ is the number of sets from $\{C_{n,1}, \dots, C_{n,2^n}\}$ such that $y \in f(C_{n,i})$, or in other words such that $f^{-1}(y)$ intersects $C_{n,i}$.  It is clear that $N_n \le N$.  I claim $N = \sup_{n} N_n$, and hence that $N$ is Borel.
Suppose that $y$ and $k$ are such that $N(y) = |f^{-1}(y)| \ge k$.  Choose $k$ distinct points $x_1, \dots, x_k$ from $f^{-1}(y)$.  Then we can find $n$ so that for all $j \ne l'$ we have $|x_j - x_{l}| > 3^{-n}$.  In particular, no set $C_{n,i}$ contains more than one of the points $x_j$, so there must be at least $k$ of the sets $C_{n,i}$ which intersect $f^{-1}(y)$.  Thus $N_n(y) \ge k$.  
It follows that $\sup_n N_n \ge N$, and this completes the proof that $N$ is Borel.
Now suppose that $f : [0,1] \to \mathbb{R}$ is continuous, and let $N(y) = |f^{-1}(y)|$.  Let $g : C \to [0,1]$ be the Cantor staircase function, which is continuous and surjective.  Also, if we let $C' = \{ k/3^m \}$ be the (countable) set of triadic rationals (the "endpoints" of $C$), then $g$ is injective on $C \setminus C'$.  Let $N'(y) = |(f \circ g)^{-1}(y)|$.  Since $f \circ g : C \to \mathbb{R}$ is continuous, we have shown that $N'$ is Borel.  Also, if $y \notin f(g(C'))$, then since $g$ is a bijection from $C \setminus C'$ to $[0,1] \setminus g(C')$, we have $N'(y) = N(y)$.  So we have that $N = N'$ except on the countable set $f(g(C'))$, and hence $N$ is also Borel.
(If this is homework, and you use any of these ideas, I ask that you include a reference to this post in your writeup.)
