In a lecture yesterday on the definition of integrals in terms of step functions, my lecturer mentioned an unusual function on the interval [0,1]. I am curious to wether my evaluation of the integral of this function is correct. First, defining the function:
$\text{Let }{\phi}=\{q_1,q_2,q_3,...\}={\bigcup}_{n=1}^{\infty}F_n,\text{ where }F_n\text{ is the }$Farey sequence $\text{bounded in }[0,1],\text{ and }q_1<q_2<q_3,...$
Now, we define two functions as follows: $$W:{\phi}\;{\to}\;{\mathbb{R}},\; W(r) =\begin{cases}\frac{1}{2^n},\; r{\in}{\phi}:r=q_n\\0,\;\;\;r{\notin}{\phi}\end{cases}$$ so $W(q_1)=\frac{1}{2}, W(q_2)=\frac{1}{4},W(q_3)=\frac{1}{8},\text{ etc}.$ Now we define another function based on W:
$$f:[0,1]\;{\to}\;\mathbb{R},\;f(x)=\sum_{r{\lt}x}W(r).$$ This is the function i am interested in. The function should be integrable, since it's set of discontinuities is $[0,1]{\backslash}{\mathbb{Q}},$ which is a countable set. Hence, i tried to manually evaluate the integral and came up with the following:
$$\int_0^1f(x)dx=\int_0^1\sum_{r{\lt}x}W(r)dx=\big[x\sum_{r{\lt}x}W(r)\big]_{x=0}^{x=1}=\sum_{r{\lt}1}W(r)-0\big(\sum_{r{\lt}0}W(r)\big)$$ $$=\sum_{r{\lt}1}W(r)=\sum_{r{\in}{\phi}}W(r)=\sum_{n=1}^{\infty}\frac{1}{2^n}=\frac{1}{1-\frac{1}{2}}=1$$ $${\therefore}\int_0^1f(x)dx=1$$.
This at first seemed contradictory, since ${\forall}x{\in}[0,1],\;f(x){\lt}1\;{\Rightarrow}\;\int_{[0,1]}f(x)dx\;{\lt}\;1(1-0)=1.$
However, due to the fact that there are infinitely many rational numbers in the interval $[0,a]:a{\in}[0,1]$, it could also make sense that the function $f$ boils down to $f(x)=1$.
This is why i am questioning my answer, besides the unusual integration method. Could someone please let me know whether my evaluation of the integral is correct, and if not, how to evaluate the integral?