Why the Dirichlet function is Lebesgue integrable?
In this post we try to answer this question, and also explain the basic definitions of measure theory and Lebesgue integration. In fact, what “moves” the Lebesgue integral is measure theory. In a somewhat vague sense, measure theory is the mathematical theory that generalizes geometrical measures like length, area, and volume.
A naive idea for defining a measure on $\mathbb{R}^3$, for example, is to define a set function $\mu$ that generalizes geometric volume by assigning to each subset $E \subseteq \mathbb{R}^3$ a value (an element of the extended real line) $\mu(E)$, called the measure of $E$, in such a way that all formulas for cubes, boxes, pyramids, cones, balls, etc., would remain valid, and we would also be able to calculate the volume of as many subsets of $\mathbb{R}^3$ as possible. We would like such a function to satisfy:
The empty set has measure $0$, and $[0, 1]^3$ has measure $1$.
If ${E_n}$ is a sequence of disjoint subsets of $\mathbb{R}^3$, then the set $E = \bigcup_{n \in \mathbb{N}} E_n$ has measure $\mu(E) = \sum_{n = 1}^{\infty} \mu(E_n)$.
If $E, E' \subseteq \mathbb{R}^3$ are equal up to rigid motions, then $E$ and $E'$ have the same measure.
Unfortunately, there is no function $\mu : 2^{\mathbb{R}^3 } \to [0, \infty]$ satisfying all these conditions. Even if we weaken the second condition to finite unions of sets $E$, the Banach-Tarski paradox shows that no finitely additive, rigid-motion invariant volume can exist on all subsets of $\mathbb{R}^3$.
Definition 01. Let $\Omega$ be a set. A $\sigma$-algebra on $\Omega$ is a non-empty collection $\mathcal{M} \subseteq 2^\Omega$ such that:
If a set $E \subseteq \Omega$ belongs to $\mathcal{M}$, then its complement $\Omega \setminus E$ also belongs to $\mathcal{M}$.
If $\{E_n\}$ is a sequence of elements of $\mathcal{M}$, then both $\bigcup_{n \in \mathbb{N}} E_n$ and $\bigcap_{n \in \mathbb{N}} E_n$ belong to $\mathcal{M}$.
With this, we can define a measure on $\Omega$ in the following way.
Definition 02. Let $\Omega$ be a set. A measure $\mu$ on $\Omega$ is a set function defined on a $\sigma$-algebra $\mathcal{M}$ of subsets of $\Omega$ with values in the extended real number line $[0, \infty]$, such that:
The empty set has measure zero: $\mu(\emptyset) = 0$.
All sets have non-negative measure: $\mu(E) \geq 0$ for all $E \in \mathcal{M}$.
Countable additivity: If ${ E_n }$ is a sequence of disjoint sets in $\mathcal{M}$ and $E = \bigcup_{n \in \mathbb{N}} E_n$, then $\mu(E) = \sum_{n \in \mathbb{N}} \mu(E_n)$.
In this context, the sets in $\mathcal{M}$ are called measurable subsets of $\Omega$, the value $\mu(E)$ is called the measure of $E$, and $\Omega$ equipped with $\mu$ is called a measure space.
The construction of a measure is a difficult task, which we won’t go into in this post. Instead, we assume that $\mathbb{R}$ is equipped with a measure called the Lebesgue measure, and we denote the Lebesgue measure of a measurable subset $E \subseteq \mathbb{R}$ by $|E|$. For our purposes, it suffices to know that all intervals are measurable, whether open or closed, and that $|[a,b]| = |(a,b)| = b-a$. From this, we can conclude that singleton sets have measure zero. Thus, if $\phi : \mathbb{N} \to \mathbb{Q}$ is a bijection, then $\mathbb{Q} = \phi(\mathbb{N}) = \bigcup_{n \in \mathbb{N}} { \phi(n) }$ is also measurable and has measure zero.
We now define the Lebesgue integral.
Definition 03. Let $\Omega, \Omega’$ be measure spaces.
A mapping $f : \Omega \to \Omega’$ is called measurable if $f^{-1}(E)$ is a measurable subset of $\Omega$ whenever $E$ is a measurable subset of $\Omega’$.
A mapping $f : \Omega \to \Omega’$ is called simple if $f(\Omega)$ is a finite subset of $\Omega’$.
The integral of a general non-negative measurable function $f : \Omega \to \mathbb{R}$ is defined as: $$ \int f = \sup_{\phi} \int \phi $$ where the supremum is taken over all simple measurable functions $\phi$ with $\phi(x) \leq f(x)$ for every $x \in \Omega$.
For a real-valued function $f : \Omega \to \mathbb{R}$ we define its positive part by $f^+(x) = \max\{0, f(x)\}$ and its negative part by $f^-(x) = \max\{0, -f(x)\}$. Then we say that $f$ is integrable if it is measurable and both $\int f^+$ and $\int f^-$ are finite. In that case: $$\int f = \int f^{+} - \int f^{-}.$$
Now let’s talk about the Dirichlet function. The Dirichlet function is the indicator function of the rational numbers, meaning it is the function $f: \mathbb{R} \to \mathbb{R}$ such that: $$f(x) = \begin{cases}0 &\text{if } x \text{ is an irrational number,} \\ 1 & \text{if } x \text{ is a rational number.}\end{cases}$$
The image of $f$ is $f(\mathbb{R}) = \{0, 1\}$, so $f$ is a simple non-negative function. Therefore, we can compute its integral: $$\int f = 0 \cdot |\mathbb{R} - \mathbb{Q}| + 1 \cdot |\mathbb{Q}| = 0.$$
Thus, even though the Dirichlet function is nowhere continuous, it is Lebesgue integrable, and its integral is zero.