A question concerning Borel measurability and monotone functions

I came across the following exercise in my self-study:

If $f: \mathbb{R} \rightarrow \mathbb{R}$ is monotone, then $f$ is Borel measurable.

I am unsure about how to proceed from the hypothesis to give the requisite proof, in particular how sensitive I should be to proof by cases. Would anyone visiting have any suggestions, or be up for proving this interesting little result?

-

A function $f:\mathbb R\to\mathbb R$ is Borel if and only if for all $a\in\mathbb R$, the set $\{x\in\mathbb R:f(x)>a\}$ is a Borel subset of $\mathbb R$.

Suggestion: Think about what possible types of sets you can get for $\{x\in\mathbb R:f(x)>a\}$ when $f$ is a monotone function. You may want to conjecture with the aid of examples before trying to prove your conjecture. The sets you get should be easily confirmed to be Borel.

-

Proposition Let $X$ be a Borel subset of $\mathbb{R}$. Let $\mathfrak{B}$ the set of Borel subsets of $X$. $(X, \mathfrak{B})$ is a measurable space. Let $f\colon X \rightarrow [-\infty, \infty]$ be a monotone function. Then $f$ is measurable.

Proof: Without loss of generality, we can assume that $f$ is non-decreasing.

Let $a \in (-\infty, \infty)$. Let $E_a = \{x \in X; f(x) > a\}$. Let $c = \inf E_a$. It suffices to prove that $E_a$ is a Borel subset.

Case 1. $c \in E_a$.

Let $x \in X \cap [c, \infty)$ Since $c \le x$, $a < f(c) \le f(x)$. Hence $x \in E_a$.

Conversely suppose $x \in E_a$. Since $c \le x, x \in X \cap [c, \infty)$.

Therefore $E_a = X \cap [c, \infty)$.

Case 2. $c$ does not belong to $E_a$.

Let $x \in X \cap (c, \infty)$. There exists $y \in E_a$ such that $c < y < x$. Since $a < f(y) \le f(x), f(x) > a$. Hence $x \in E_a$.

Conversely suppose $x \in E_a$. Since $c \le x$ and $c$ does not belong to $E_a$, $x \in X \cap (c, \infty)$.

Therefore $E_a = X \cap (c, \infty)$.

QED

-