Confused by solution to Question 2 Part viii of Chapter 14 in Spivak's Calculus Question 2 of Chapter 14 in Spivak's Calculus reads as follows:

For each of the following $f$, if $F(x)=\int_0^xf$, at which points $x$ is $F'(x)=f(x)$?

Part (viii) of Question 2 uses the function:

$f(x)=1$ if $x=\frac{1}{n}$ for some $n$ in $\mathbb N$, $f(x)=0$ otherwise.

The solution manual for this problem reads as:

All $x$ not of the form $\frac{1}{n}$ for some natural number $n$ [...are points where $F'(x)=f(x)$]

From this proposed solution, Spivak suggests that $F'(0)=f(0)$ (more specifically, it should be $F'^+(0)=f(0)$...but for his problems, this is usually implicit).
However, I believe $f$ is discontinuous at $0$ (because there is no right limit) and, moreover, the intermediate value property is not upheld for any $\delta_n=\frac{1}{n} \gt 0$ on the interval $[0,\delta_n]$. Therefore, I do not think that $0$ should be included in the list of points that exhibit the feature of $F'(x)=f(x)$.
Is this correct?
 A: Having not read the book, I can't speak to what the "rules" are for integration, but it probably falls into one of the two camps below.
Riemann integral rules If the book is using Riemann integration then we can construct a series of step functions $(\phi_i,\psi_i)$ such that for every $x$
\begin{align}
   \phi_i(z) \leq f(z) \leq \psi_i(z) \text{ for all } z \in [0,x] \\
   \lim_{i \rightarrow \infty} \int_0^x\psi_i(z)-\phi(z) dz = 0 \\
   \lim_{i\rightarrow \infty} \int_0^x\psi_i(z)dz = \lim_{i\rightarrow \infty} \int_0^x\phi_i(z)dz = 0
\end{align}
This will show that $F(x) = \int_0^x f(z) dz = 0$ for every $x$, and therefore since $F$ is constant the derivative of $F$ is $F'(x) = 0$ for every $x$, in particular for $x = 0$ we have $F'(0) = 0 = f(0)$.
I'll construct the series now, its a bit messy to do this and a good exercise to try for yourself first.
If $x \leq 0$ then just set $\phi_i = \psi_i = 0$ and all of the properties are satisfied.
So let $x > 0$ and let $n_0$ be the smallest positive integer such that $1/n_0 \leq x$. Set $\phi_i = 0$ for every $i$. Set
\begin{equation}
    \psi_i(x) = \mathbb{1}\left [x \leq \frac{1}{n_0+i+1}\right ] + \sum_{k = n_0}^{n_0+i} \mathbb{1}\left[\frac{1}{k} - \frac{1/k -1/(k+1)}{2i} \leq x \leq 1/k \right]
\end{equation}
This function may look like a beast but there is an intuition to its construction. The $n_0$ trick makes it so we can ignore the bad points of $f$ which are outside of $[0,x]$. After that each term in the sum handles exactly one point $1/(n_0 + k) \in [0,x]$ where $f$ is badly behaved. The leading term handles all the points near the origin with bad behavior. Incrementing $i$ does two things. First it moves one point from the catch-all interval near the origin into the finite sum. Second, it makes the intervals around the bad points even tighter.
One can check that $\psi$ is an appropriate upper bound on $f$ and also
\begin{align}
   \int_0^x \psi_i(z) &= \frac{1}{n_0+i+1}+ \sum_{k=n_0}^{n_0+i} \frac{1}{k} - \left ( \frac{1}{k} - \frac{1/k -1/(k+1)}{2i} \right ) \\
    &=\frac{1}{n_0 + i + 1} + \frac{1}{2i}\sum_{k=n_0}^{n_0 + i} \frac{1}{k(k+1)} \\
    &\leq \frac{1}{n_0 + i + 1} + \frac{1}{2i}\sum_{k=1}^\infty \frac{1}{k^2}  \\
   &= \frac{1}{n_0 + i + 1} + \frac{C}{2i}
\end{align}
where $C = \sum_{k=1}^\infty 1/k^2$ is a finite constant. From this last bound we see that indeed
\begin{equation}
    0 \leq \lim_{i\rightarrow \infty} \int_0^x \psi_i(z)dz \leq \lim_{i \rightarrow \infty} \frac{1}{n_0 + i + 1} + \frac{C}{2i} = 0
\end{equation}
Measure theory rules If the book is using measure theory to define integrals and we're talking about Lebesgue integration then we have, letting $S = \{1/n : n\in \mathbb{N}\}$ and $L$ be the Lebesgue measure, that
\begin{align}
    F(x) = \int_0^x f dL &= \int_{S} fdL + \int_{[0,x] \setminus S} fdL \\
    &= \int_S 1 dL + \int_{[0,x] \setminus S} 0dL \\
    &= 1 \cdot L[S] + 0 \cdot L[[0,x] \setminus S] \\
    & = 1\cdot 0 + 0 \cdot x = 0
\end{align}
which shows that $F(x) = 0$ and since this holds for all $x$ we have $F'(x) = 0$ for all $x$, in particular $F'(0) = 0 = f(0)$.
A: Here is another approach using the Darboux Integral definition.

Consider the function that is defined by the formula:
$f(x)= \begin{cases}1\quad &\text {if $x=\frac{1}{n}$ for some $n \in \mathbb N$} \\0 \quad &\text{otherwise} \end{cases}$
We will show that $\displaystyle \int_a^b f$ is integrable for any $a \leq b \in \mathbb R$. Further, for any $a \leq b$, we have that $\displaystyle \int_a^b f=0$. This shows that $F$ is the constant $0$ and allows one to conclude that $F(0)=f(0)$.

Firstly, for any $a \leq 0$ and any $b\geq 1$, we obviously have that $\displaystyle \int_a^0f=0$ and $\displaystyle \int_1^bf=0$, respectively.
Consider when $a=0$ and $b=1$. Next, consider an arbitrary $\varepsilon \gt 0$. Our objective is to construct a partition $P$ of $[0,1]$ such that: $U(f,P) - L(f,P) \lt \varepsilon$, which is equivalent to showing that $f|_{[0,1]}$ is integrable. If we can show that this is true, we next note that the set of irrational numbers is dense in $\mathbb R$. Making use of the following set  $S=\left\{s \ |\ \exists n \in \mathbb N: s=\frac{1}{n}\right\}\subset \mathbb Q$, it is clear that $S \cap (\mathbb R \setminus \mathbb Q)=\emptyset$, which means that for any $[t_{i-1},t_i]$, we know that there is an $x \in [t_{i-1},t_i]: f(x)=0$. Therefore, for any $[t_{i-1},t_i]$ described by any partition $P$ of $[0,1]$, we know that the corresponding subinterval infimum of $f$, denoted as $m_i $, is equal to $0$, which implies that for any partition $P$ of $[a,b]$, we have that $L(f,P)=0$. This would then mean that $\displaystyle \int_0^1 f=0$ because the integrability of $f$ on $[0,1]$ implies that $\displaystyle \sup \{L(f,P):\ P \text{ is a partition of $[a,b]$}\}=\inf \{U(f,P):\ P \text{ is a partition of $[a,b]$}\}$. Finally, if $\displaystyle \int_0^1 f$ exists, then any subset is integrable, meaning that $\displaystyle \int_0^bf$ for $0 \leq b \lt 1$ is integrable. Using the exact logic as before regarding $m_i$'s value, we know that for any partition $S$ of $[0,b]$, all subintervals $[t_{i-1},t_i]$ defined by $S$ will have $f|_{[t_{i-1},t_i]}$'s infimum as $0$. This means that $\displaystyle \int_0^bf = 0$. Therefore, we know that $\displaystyle F(x)= \int_0^x f = 0$ for any $x \geq 0$. Thus, $F$ is a constant and its derivative is $0$ everywhere...note that its full derivative (not just right-derivative) is defined at $x=0$ because $\displaystyle \int_a^0 =0$ for any $a \lt 0$.

To construct a partition $P$ of $[0,1]$ such that $U(f,P)-L(f,P) \lt \varepsilon$, we will consider 2 different 'zones' each with the property that their upper-lower sums of $f$ (when restricted to the relevant subintervals comprising each zone) are less than $\frac{\varepsilon}{2}$, each. When all such upper-lower sum differences across the 2 zones are added together (while keeping track of each zone's corresponding subinterval partitioning), we will have the necessary partition to show that $U(f,P)-L(f,P) \lt \varepsilon$.
First Zone
For an arbitrary $\varepsilon \gt 0$, we know that there is an $n \in \mathbb N$ such that: $\frac{1}{n}\lt \frac{\varepsilon}{2}$. Consider any arbitrary partition of $[0,\frac{1}{n}]$: call it $P_1$. On this interval, we know that $U(f,P_1) \leq 1\cdot (\frac{1}{n}-0)$ because $1$ is an upper bound to $f$. Further, as noted earlier, $L(f,P_1)=0$ There $U(f,P_1)-L(f,P_1) \leq \frac{1}{n} \lt \frac{\varepsilon}{2}$
Second Zone
For our next zone, we will recall the $n$ used in the first zone. Because this a finite number, we know that there is a finite list of different $i \in \mathbb N$ such that $\frac{1}{n} \leq \frac{1}{i} \leq 1$. In particular, $i$ is any element in the set $\{1,2,3,\cdots,n\}$. Note, then that $\frac{1}{1}$ and $\frac{1}{n}$ are in this zone. Consider a closed neighborhood $[\frac{1}{i}-\delta,\frac{1}{i}+\delta]$ with $\delta \gt 0$ centered around each $\frac{1}{i}$. There will be $n$ such neighborhoods (two of which will end up only contributing half neighborhoods). We know that on each of these neighborhoods, $f$'s supremum will achieve the value of $M_i=1$. Therefore, the upper-lower sum difference across these closed neighborhoods is no greater than $1\cdot n \cdot 2\delta$, and we need this value to be $\lt \frac{\varepsilon}{2}$. Therefore, we compute that $\displaystyle\delta \lt \frac{\varepsilon}{4n}$. For convenience, we will further ensure that none of these neighborhoods overlap. To do this, we will impose an additional length constraint on $\delta$ such that $\delta$ is smaller than the distance between the closest points $\frac{1}{i}$ and $\frac{1}{j}$.
Because the derivative of the function $g(x)=\frac{1}{x}$ is $g'(x)=\frac{-1}{x^2}$, an application of the Mean Value Theorem (plus some inequality manipulations) will provide us with the following: for any $m \lt n \in \mathbb N$, we have that $\frac{1}{n-1}-\frac{1}{n} \lt \frac{1}{m-1}-\frac{1}{m}$. Therefore, let us stipulate that $\delta \lt \min\left(\frac{1}{n-1}-\frac{1}{n}, \frac{\varepsilon}{4n}\right)$. Now, union together all numbers that comprised the end points $\frac{1}{i}-\delta$ and $\frac{1}{i}+\delta$ for each $i \in \{1,2,\cdots,n\}$: you can disregard $\frac{1}{n}-\delta$ and $\frac{1}{1}+\delta$. Let this set equal $P_2$. Importantly, for the space between the neighborhoods, e.g. $[\frac{1}{i}+\delta,\frac{1}{i-1}-\delta]$, it should be obvious that there are no elements of the form $\frac{1}{j}$ in this interval. Therefore, on these subintervals, $f$'s supremum takes on the value $0$, so the upper-lower sum difference on these subintervals is always $0$. Thus, we must have that $U(f,P_2)-L(f,P_2) \lt \frac{\varepsilon}{2}$.
Conclusion
Noting that $P_1=\{0,\cdots,\frac{1}{n}\}$ and $P_2=\{\frac{1}{n},\cdots,1\}$, their union $P=P_1 \cup P_2$ is necessarily a partition of $[0,1]$. Therefore, we can conclude that $U(f,P)-L(f,P)=\left[U(f,P_1) - L(f,P_1)\right]+\left[U(f,P_2)-L(f,P_2)\right] \lt \frac{\varepsilon}{2}+\frac{\varepsilon}{2} = \varepsilon$, as desired. Our previously established logic then follows.
