Continuous functions are differentiable on a measurable set? I came across the following challenging problem in my self-study:
Let $f: \mathbb{R} \rightarrow \mathbb{R}$ be continuous. Then the set of points where $f$ is differentiable is a measurable set.
I am having trouble thinking of where to begin in proving this result, and wanted to see if anyone visiting had some suggestions on how to proceed.
 A: You can write the set of points where $f$ is differentiable as the set of points where a particular limit exists (namely, the one that defines the derivative). You can codify a limit (using the $\epsilon,\delta$ definition) in terms of intersections/unions of measurable sets.
What you want to say is that the function $f$ is differentiable at $x$ (with value $y$) if for all $\epsilon$ there exists a $\delta$ such that the difference quotient with parameter $\delta$ is $\epsilon$-close to $y$. First fix an $\epsilon$. Then the set of points where this is true for that particular $\epsilon$ is is the union (over the possible $\delta$) of the sets such that the difference quotient is $\epsilon$-close with that fixed $\delta$. This must be true for all $\epsilon$, so we take the intersection of those sets over all $\epsilon$. 
The net result is that we are taking 
$$\cap_\epsilon \cup_\delta V(\epsilon, \delta)$$
where $V(\epsilon, \delta)$ is the set of points such that the difference quotient is less than $\epsilon$ from $y$. Of course, this was just for one possible value of the derivative, so we need to take the union over all $y$ as well, giving us
$$\cup_y \cap_\epsilon \cup_\delta V(\epsilon, \delta).$$
For everything involved to be countable, you'd want to choose the $y$, $\epsilon$, $\delta$ to be rational, which is fine because the rationals are dense in $\mathbb{R}$.
A: Here's an attempt to salvage Matthew Pancia's solution, which unfortunately depended on an uncountable union over all possible derivatives.
Given $f$ we can define, in the obvious way, a continuous function $F:\mathbb R\times(\mathbb R\setminus 0)\to \mathbb R$ such that $f$ is differentiable at $x$ exactly when $\lim_{h\to 0} F(x,h)$ exists.
The usual formalization of this is
$$\exists y:\forall\varepsilon:\exists \delta:\forall h: |h|<\delta\Rightarrow |F(x,h)-y|<\varepsilon$$
Classically all of the variables here are real, but it is easy to see that we can restrict $\varepsilon$ and $\delta$ to $\mathbb Q$ without changing the meaning. We can also restrict $h$ to $\mathbb Q$ because $F$ is continuous. However, it is essential that $y$ can be an arbitrary real, because otherwise we would be looking for points where $f$ is differentiable with rational derivative, which is something quite different.
However, we can also formalize the existence of a limit like
$$\forall\varepsilon:\exists \delta:\exists Y:\forall h: |h|<\delta \Rightarrow |F(x,h)-Y|<\varepsilon$$
This works because $\mathbb R$ is complete; it is essentially the same as changing "has a limit" about a sequence to "is Cauchy". The arguments that $\varepsilon$, $\delta$ and $h$ can be restricted to the rationals work as before, but now $Y$ can also be taken to be a rational in each case.
For each particular choice of $\varepsilon$, $\delta$, $Y$, and $h$, the set of $x$ such that $|h|<\delta\Rightarrow |F(x,h)-Y|<\varepsilon$ is open and therefore Borel.
Now handle each of the quantifiers from the inside out: For each choice of $\varepsilon$, $\delta$, and $Y$, the set of $x$ such that
$$\forall h: |h|<\delta \Rightarrow |F(x,h)-Y|<\varepsilon$$
is a countable intersection of Borel sets and therefore Borel. For each choice of $\varepsilon$ and $\delta$ the set of $x$ such that
$$\exists Y:\forall h: |h|<\delta \Rightarrow |F(x,h)-Y|<\varepsilon$$
is a countable union of Borel sets and therefore Borel. And so forth. At the top we find that the set of points of differentiability is Borel and thus in particular measurable.
A: Theorem 1
Let $f$ be a measurable function on $(a,b)$. Then the function
$$
g_n(x)=\sup\left\{f(x+h):h\in(0,\frac{1}{n})\cap(0,b-x)\right\}
$$
is measurable.
Proof
Fix $c\in\mathbb{R}$. We want to prove that the set $A=\{x\in(a,b):g_n(x)>c\}$ is measurable, then $g_n$ will be measurable. Let $x_0\in A$, then there exist $h_0\in(0,\frac{1}{n})\cap(0,b-x_0)$ such that $f(x_0+h_0)>c$. Define 
$$
\delta_1=\frac{1}{2}\left(\min\left(\frac{1}{n},b-x_0\right)-h_0\right)\qquad
\delta_2=\frac{1}{2}\left(\min\left(\frac{1}{n},b-x_0\right)+h_0\right)
$$
then for all $x\in(x_0-\delta_1, x_0+\delta_2)$ we have $x_0+h_0\in\{x+h:h\in(0,\frac{1}{n})\cap(0,b-x)\}$. As the consequence $g_n(x)\geq f(x_0+h_0)>c$, so $x\in A$ for all $x\in(x_0-\delta_1, x_0+\delta_2)$. This means that $A$ is open, hence measurable.
Theorem 2
Let $f$ be a mesurable function on $(a,b)$ then the set
$$
A=\{x\in(a,b):\exists f'(x)\in\mathbb{R}\}
$$
is measurable.
Proof
Extend $f$ by equalities: $f(x)=f(a)$ for $x<a$ and $f(x)=f(b)$ for $x>b$. For each $c\in\mathbb{R}$ consider measurable function $\phi(x)=f(x)-cx$. From theorem 1 it follows that 
$$
\psi_n(x)=\sup\left\{\phi(x+h):h\in(0,\frac{1}{n})\cap(0,b-x)\right\}
$$
is measurable. Then we have measurable function
$$
\psi_n(x)-\phi(x)=\sup\left\{\phi(x+h)-\phi(x):h\in(0,\frac{1}{n})\cap(0,b-x)\right\}.
$$
Hence the set 
$$
B=\{x\in(a,b):\psi_n(x)-\phi(x)>0\}=
$$
$$
\left\{x\in(a,b):\sup\left\{\frac{f(x+h)-f(x)}{h}:h\in(0,\frac{1}{n})\cap(0,b-x)\right\}>c\right\}
$$
is measurable. Since $c\in\mathbb{R}$ is arbitrary then the functions
$$
f_n(x)=\sup\left\{\frac{f(x+h)-f(x)}{h}:h\in(0,\frac{1}{n})\cap(0,b-x)\right\}
$$
are measurable. So we conclude that the function
$$
\overline{f}'_+(x)=\overline{\lim\limits_{h\to 0+}}\frac{f(x+h)-f(x)}{h}=\lim\limits_{n\to\infty}f_n(x)
$$
is also measurable. Similarly, we can prove that functions
$$
\underline{f}'_+(x)=\underline{\lim\limits_{h\to 0+}}\frac{f(x+h)-f(x)}{h}=\lim\limits_{n\to\infty}f_n(x)
$$
$$
\overline{f}'_-(x)=\overline{\lim\limits_{h\to 0-}}\frac{f(x+h)-f(x)}{h}=\lim\limits_{n\to\infty}f_n(x)
$$
$$
\underline{f}'_-(x)=\underline{\lim\limits_{h\to 0-}}\frac{f(x+h)-f(x)}{h}=\lim\limits_{n\to\infty}f_n(x)
$$
are mesurable. Finally, the set $A=\{x\in(a,b):\exists f'(x)\in\mathbb{R}\}$ is measurable because
$$
A=\{x\in(a,b):\overline{f}'_+(x)=\underline{f}'_+(x)=\overline{f}'_-(x)=\underline{f}'_-(x)\in\mathbb{R}\}
$$
A: What follows is taken from a sci.math post of mine from 16 May 2006.
Let $f:{\mathbb R} \rightarrow {\mathbb R}$ be arbitrary. Then the set of points where $f$ does not have a finite derivative is a $G_{\delta \sigma}$ set. This is also true for the set of points where $f$ does not have a finite left derivative or the set of points where $f$ does not have a finite right derivative. A proof of this is given after the next paragraph.
Conversely, given any $G_{\delta}$ set $G_1$ and $G_{\delta \sigma}$ set $G_2$ such that $G_2$ has Lebesgue measure zero, then there exists a continuous function $f:{\mathbb R} \rightarrow {\mathbb R}$ whose non-differentiability set is precisely $G_1 \cup G_2.$ This was proved by Zygmunt Zahorski (1914-1998) in 1941 and re-published in French in 1946 (Zbl 61.11302; MR 9,231a). For the 1946 French paper, see http://tinyurl.com/3zwca22.
The first statement above for continuous $f$ follows from the fact that $f$ has a finite derivative at $x$ if and only if $x$ belongs to
$$\bigcap_{k=1}^{\infty} \;\bigcup_{n=1}^{\infty} \;\; \bigcap_{0 < |\eta| < \frac{1}{n}} \;\; \bigcap_{0 < |\delta| < \frac{1}{n}} \; \left\{x:\;\; \left| \frac{f(x + \eta) - f(x)}{\eta} \;\; - \;\;  \frac{f(x + \delta) - f(x)}{\delta} \right| \; \leq \frac{1}{k}\right\}$$
To see that this result holds for an arbitrary function $f$ (not necessarily continuous), we relativize the above decomposition to $C(f)$, the continuity set of $f$. That is, consider the sets $\{x \in C(f): |$ stuff $| \leq \frac{1}{k}\}.$ This will show that the set where $f$ has a finite derivative is an $F_{\sigma \delta}$ subset of the space $C(f),$ where $C(f)$ has the subspace topology from ${\mathbb R}.$ ("Subset", because every point at which a finite derivative exists is a point of continuity.) Hence, this set is the intersection of $C(f)$ with an $F_{\sigma \delta}$ set in ${\mathbb R}$ (subspace topology stuff), and therefore this set is $F_{\sigma \delta}$ in ${\mathbb R}$ (because $C(f)$ has a lower Borel class, being $G_{\delta}$ in ${\mathbb R}).$
