Characterization of real functions which have limit at each point The following problem is Exercise 7.K from the book van Rooij-Schikhof: A Second Course on Real Functions and it is very close to a question which was recently discussed in chat.
So I thought that sharing this interesting problem with other MSE users could be useful. Here's the problem:

Let $L$ be the set of all functions $f\colon [0,1]\to\mathbb R$ that have the property that $\lim\limits_{x\to a} f(x)$ exists for all $a \in [0, 1]$.
  Show that:
  (i) $L$ is a vector space. Each $f \in L$ is bounded.
  (ii) For each $f \in L$, define $f^c(x): = \lim\limits_{y\to x} f(y)$ ($x \in [0, 1]$). $f^c$ is continuous.
  (iii) '$f^c =0$' is equivalent to 'there exist $x_1, x_2, \dots$ in $[0,1]$ and $a_1, a_2,\dots$ in $U$ with
  $\lim\limits_{n\to\infty} a_n = 0$, such that $f(x_n) = a_n$ for every $n$, and $f=0$ elsewhere'.
  (iv) Describe the general form of an element of $L$. Show that every $f\in L$ is Riemann integrable.

The original question in the chat was about functions $\mathbb R\to\mathbb R$, but it does not change much in the parts (iii) and (iv). 
 A: I'll post my solution, too.

(i) It is obvious that $L$ is a vector space. 
If we fix some $\varepsilon>0$ then we have for each $a\in[0,1]$ an open neighborhood $U_a$ such that $\operatorname{diam} U_a<\varepsilon$. The sets $U_a$ form an open cover of the compact set $[0,1]$, so we have a finite subcover. Therefore the range of $f$ is covered by finitely many bounded sets and it is bounded itself.

(ii) Let us try to show the continuity of the function $f^c$ defined by $f^c(x)=\lim\limits_{y\to x} f(y)$.
Suppose that $f^c$ is not continuous at some point $a$. Let us denote $b:=f^c(a)$. Then there exists a sequence $x_n$ such that $x_n\to a$, $x_n\ne a$ and $f^c(x_n)$ does not converge to $b$. 
By definition of $f^c$ we can find for each $x_n$ a point $y_n$ such that $|y_n-x_n|<1/2^n$ and $|f(y_n)-g(x_n)|<1/2^n$. We can assume that, in addition to this, $y_n\ne a$. 
For such sequence we have $y_n\to a$ and $f(y_n)\not\to b=f^c(a)$, which contradicts the definition of $f^c$.

(iii) We want to show $f^c=0$ $\Leftrightarrow$ $f$ has the form described in the part (iii).
The implication $\boxed{\Leftarrow}$ is easy: We have $f^c(x)=\lim\limits_{n\to\infty} f(x_n)$ for any sequence $x_n\to x$, $x_n\ne x$. If we choose any $\varepsilon$, there are only finitely many $n$'s such that $|f(x_n)|>\varepsilon$. This implies that the limit must be zero.
$\boxed{\Rightarrow}$ If suffices to show that the set $M_\varepsilon:=\{x\in\mathbb R; |f(x)|>\varepsilon\}$ is finite for each $\varepsilon>0$. (Once we have shown this, we can get all non-zero points as the union $\bigcup\limits_{n=1}^\infty M_{1/n}$, so there is only countably many of them. And they can also be ordered in the required way.)
Suppose that for some $\varepsilon>0$ the set $M_\varepsilon:=\{x\in\mathbb R; |f(x)|>\varepsilon\}$ is infinite. Then this set has an accumulation point $a\in[0,1]$. We have $|f_c(a)|\ge\varepsilon$, contradicting the assumption that $f^c$ is zero.

(iv) Now let $f$ be an arbitrary function from $L$.
It is relatively easy to see that if we denote $g:=f-f^c$, then $g^c$ is identically zero. (I.e., $\lim\limits_{x\to a} g(x)=0$ for each $a\in[0,1]$.) Note that $f=f^c+g$.
So we get that each function from $L$ is a sum of a continuous function and a function which has the form described in the part (iii) of this exercise.
Now to show that $f$ is Riemann integrable we could use Lebesgue's criterion for Riemann integrability and the fact that every countable set has Lebesgue measure zero.
But this can be also shown directly from the definition: For any given $\varepsilon>0$ we have only finitely many points such that $|f(x)|\ge\varepsilon$. If we cover them with small enough intervals, we will get that the Riemann sum over these intervals is in absolute value at most $\varepsilon$. For arbitrary partition containing the small intervals, the absolute value of the Riemann sum over the remaining intervals is at most $\varepsilon$. So we have $|R(f,\Delta)|\le 2\varepsilon$ whenever the norm of the partition is chosen small enough to ensure that the intervals around the "exceptional" points (the points with $|f(x)|\ge\varepsilon$) are small enough.
A: $\def\dts{\mathinner{\ldotp\ldotp}}$
First, we extend the domain $[0\dts1]$ into $\Bbb R$, say, $f(x_0)=\lim_{x\to0^+}f(x)$ whenever $x_0<0$, and $f(x_0)=\lim_{x\to1^-}f(x)$ whenever $x_0>1$, hence we can conclude that $\lim_{x\to a}f(x)$ exists for each real number $a$. Just like the notation in (ii), and for ease, let $g(x)=\lim_{y\to x}f(x)$, so $f^c(x)=g(x)$ on the interval $[0\dts1]$.
Next, we can say that $f$ is bounded.
By definition of limit of function, there exists $\delta_\epsilon(a)>0$ such that $|f(x)-g(a)|<\epsilon$ whenever $0<|x-a|<\delta_\epsilon(a)$, therefore $|f(x)|\le\max(|f(a)|,|g(a)|+\epsilon)=M_\epsilon(a)$ whenever $|x-a|<\delta_\epsilon(a)$.
Supposing that $\epsilon$ is a fixed positive real number, say $1$, and let $\Sigma$ is the set of open intervals $I(x)=(x-\delta_\epsilon(x)\dts x+\delta_\epsilon(x))$, where $0\le x\le1$. We have $\Sigma_\epsilon$ covers the closed set $[0\dts1]$, thus there exists finite subset of $\Sigma_\epsilon$, say $\Sigma_\epsilon^*$, which covers the closed set $[0\dts1]$, and let $\Sigma_\epsilon^*=\{I_\epsilon(a_1),\ldots,I_\epsilon(a_m)\}$, we have $|f(x)|\le M_\epsilon(a_k)$ on the open interval $I_\epsilon(a_k)$, so $f$ is bounded.
Now, let's prove that $g$ is continuous. For all $\epsilon>0$, we have $|f(x)-g(x_0)|<\epsilon$ where $x$ is an arbitrary point on the open interval $I_\epsilon(x_0)$. Let $y\in I_\epsilon(x_0)$, and let $x$ tends to $y$ but not equals $y$, we have $f(x)\to g(y)$, therefore $|g(y)-g(x_0)|\le\epsilon$, hence $g$ is continuous.
Then, supposing that $f^c(x)=0$ on the interval $[0\dts1]$, we have $g(x)=0$ for arbitrary real number $x$. For all $\epsilon>0$, we should remember that there's a corresponding finite cover $\Sigma_\epsilon^*$ of closed set $[0\dts1]$, and $\Sigma_\epsilon^*=\{I_\epsilon(a_1),\ldots,I_\epsilon(a_m)\}$. Now let's analyse this result closely. For $x\in I_\epsilon(a_k)$, and $x\neq a_k$, we have $|f(x)|=|f(x)-g(a_k)|<\epsilon$, so $|f(x)|\ge\epsilon\,\Longrightarrow\,x=a_k\textrm{ for some }k$. Thus we can sort all $x$ such that $f(x)\neq0$ in decreasing order of $|f(x)|$, and arrange them in a sequence.
Finally, we should prove that, if we can arrange all non-zero points on interval $[0\dts1]$ in a sequence $S$ such that the value converges to $0$, we have $f^c=0$. For any point $y$ in $[0\dts1]$ and arbitrary positive real number $\epsilon$, there's only finity many points in $S$ whose absolute value $\ge\epsilon$, thus $f(x)<\epsilon$ holds on some neighborhood of $y$ (if $y=0,1$, it's one sided neighborhood), so $f^c(y)=0$.
