Functions with finite right-hand limits are Borel measurable I'm studying for my exam in measure and integration theory and we got some exercises that we can do for preparation and I'm stuck on this one.

Every function $f:\Bbb R \rightarrow \Bbb R $ (from reals to reals) with the property that $\displaystyle\lim _{ h\to 0^{+}}{ f(x+h) } $ exists for all $x\in \Bbb R $ is Borel measurable.

I just proved that the pointwise limit of measurable functions is again measurable. So I thought about ways we could represent our $f$ as a limit of (Borel) measurable functions but I dont think it is in general possible to find such a sequence for an arbitrary $f$.
Further I feel like i don't understand the condition that $$\lim _{ h\to 0^+ }{ f(x+h) } $$ exists correctly. Is it possible to derive some form of continuity with this property? Could someone shed some light on this problem for me, thanks for any help.
 A: If we set $$\tilde{f}(x) := \lim_{h \downarrow 0} f(x+h),$$ then $\tilde{f}$ is (by assumption) well-defined. Moreover, straight-forward computations show that $\tilde{f}$ is right-continuous (see Lemma 3 below) and, hence, Borel measurable. If we can prove that the set
$$J:=\{x \in \mathbb{R}; \tilde{f}(x) \neq f(x)\} \tag{1}$$
is countable, then $g:=f-\tilde{f}$ is Borel measurable (see e.g. this proof). Consequently, $f=g+\tilde{f}$ is Borel measurable as sum of Borel measurable functions.
To prove that $J$ is countable we proceed as follows: For $x \in \mathbb{R}$ define the oscillations of $f$ at $x$ by
$$\omega(x) := \inf_{r>0} \omega_r(x) := \inf_{r>0} \left( \sup_{z \in B(x,r)} f(z) - \inf_{z \in B(x,r)} f(z) \right).$$
It is not difficult to see that $$\{\omega=0\} = \{x \in \mathbb{R}; \text{$x$ is a continuity point of $f$}\} \tag{2}$$
and therefore $J \subseteq \{\omega \neq 0\}$. Consequently, we are done if we can show that $\{\omega \neq 0\}$ is countable.

Lemma 1: For any $x \in \mathbb{R}$ and $n \in \mathbb{N}$ there exists $\delta(x)>0$ such that $\omega(y) \leq 1/n$ for all $y \in (x,x+\delta(x))$.

Proof: Fix $x \in \mathbb{R}$ and $n \in \mathbb{N}$. Since the limit $\tilde{f}(x) = \lim_{h \downarrow 0} f(x+h)$ exists, we have
$$\sup_{z \in (x,x+h)} f(z) \xrightarrow[]{h \to 0} \tilde{f}(x) \qquad \inf_{z \in (x,x+h)} f(z) \xrightarrow[]{h \to 0} \tilde{f}(x),$$
and so
$$\lim_{h \to 0} \left| \sup_{z \in (x,x+h)} f(z) - \inf_{z \in (x,x+h)} f(z) \right|=0;$$
in particular we can choose $\delta>0$ such that
$$\left| \sup_{z \in (x,x+\delta)} f(z) - \inf_{z \in (x,x+\delta)} f(z) \right| \leq \frac{1}{n}. \tag{3}$$
Now let $y \in (x,x+\delta)$. If we set $r := \min\{|y-x|,|y-(x+\delta)|\}$ then $B(y,r) \subseteq (x,x+\delta)$. In particular, we have
$$\sup_{z \in B(y,r)} f(z) \leq \sup_{z \in (x,x+\delta)} f(z) \qquad \inf_{z \in B(y,r)} f(z) \geq \inf_{z \in (x,x+\delta)} f(z) \tag{4}$$
which implies
$$\inf_{z \in (x,x+\delta)} f(z) \leq \inf_{z \in B(y,r)} f(z) \leq \sup_{z \in B(y,r)} f(z) \leq \sup_{z \in (x,x+\delta)} f(z).$$
On the other hand, we know from $(3)$ that
$$\sup_{z \in (x,x+\delta)} f(z) \leq \inf_{z \in (x,x+\delta)} f(z) + \frac{1}{n}.$$
Combining the two chains of inequalities we conclude that
$$\sup_{z \in B(y,r)} f(z) - \inf_{z \in B(y,r)} f(z) \leq \frac{1}{n},$$
i.e. $\omega_r(y) \leq 1/n$. In particular, $\omega(y) \leq 1/n$ which finishes the proof of the Lemma.

Lemma 2: $\{\omega \neq 0\}$ is countable.

Proof: Clearly, it suffices to show that $\{\omega > 1/n\}$ is countable for each $n \in \mathbb{N}$. For fixed $n \in \mathbb{N}$ denote by $\delta(x)$ the constant from the previous lemma. For each fixed $k \in \mathbb{N}$ and $N \in \mathbb{N}$ the set
$$B_{k,N} := \{x \in [-N,N] \cap \{\omega>1/n\}; \delta(x) \geq 1/k\}$$
is finite. Indeed: By the previous lemma, the distance between any two points in $B_{k,N}$ is at least $1/k$ and since the length of the interval $[-N,N]$ is $2N$, there can exist at most $2Nk+1$ points in $B_{k,N}$. This implies that
$$\{x \in \{\omega>1/n\}; \delta(x) \geq 1/k\} = \bigcup_{N \in \mathbb{N}} B_{k,N}$$
is countable which, in turn, implies that
$$\{\omega>1/n\} = \bigcup_{k \in \mathbb{N}} \{x \in \{\omega>1/n\}; \delta(x) \geq 1/k\}$$
is countable.

Edit: Following the comment to my answer, I add a proof for the right-continuity of $\tilde{f}$.

Lemma 3: $\tilde{f}$ is right-continuous.

Proof: Since $\tilde{f}(y) = \lim_{h \downarrow 0} f(y+h)$ we clearly have
$$\inf_{z \in (y,y+r)} f(z) \leq \tilde{f}(y) \leq \sup_{z \in (y,y+r)} f(z) \tag{5}$$
for any $y \in \mathbb{R}$ and $r>0$. For fixed $x \in \mathbb{R}$ and $\epsilon=1/n$ let $\delta=\delta(x)>0$ be as in (the proof of) Lemma 1. Using (5) for $y=x$ we find that
$$\inf_{z \in (x,x+\delta)} f(z) \leq \tilde{f}(x) \leq \sup_{z \in (x,x+\delta)} f(z).$$
On the other hand it follows from (4) and (5) that
$$\inf_{z \in (x,x+\delta)} f(z) \leq \inf_{z \in B(y,r)} f(z) \leq \tilde{f}(y) \leq \sup_{z \in B(y,r)} f(z) \leq \sup_{z \in (x,x+\delta)} f(z)$$
for any $y \in (x,x+\delta)$ where $r:=\min\{|y-x|,y-(x+\delta)|\}$. Combining both inequalities and using (3) we get
$$|\tilde{f}(x)-\tilde{f}(y)| \leq \left| \sup_{z \in (x,x+\delta)} f(z) - \inf_{z \in (x,x+\delta)} f(z) \right| \leq \frac{1}{n}$$
for all $y \in (x,x+\delta)$ which finishes the proof of the right-continuity of $\tilde{f}$.
