How badly can Dini's theorem fail if the p.w. limit isn't continuous?

Dini's theorem is commonly seen in real analysis courses (possibly with the requirement that $X$ be a compact metric space if topological spaces are still off in the future), but suppose one wanted to give an example of how much it can fail without the requirement that the pointwise limit of the sequence of functions is continuous. The problem therefore is:

Exhibit a sequence of continuous functions $f_n: [0,1] \to [0,1]$ pointwise monotonically decreasing to a function $f: [0,1] \to [0,1]$ such that the set of points where $f$ is discontinuous has measure $1$.

This could for example be used to demonstrate how poorly behaved the Riemann integral is with respect to pointwise limits since the sequence $(f_n)$ is pretty much as nice as you can possibly get without being uniformly convergent and $f$ is obviously Lebesgue integrable, but it "maximally fails" to satisfy Lebesgue's criterion for Riemann integrability. Additionally, it would demonstrate the existence of comeagre Lebesgue null sets because the set of points where $f$ is continuous is comeagre by the Baire-Osgood theorem (does anyone have a good free online reference for this? (EDIT: I wrote one myself)).


For each $k\in \mathbb N$, let $C_k$ be a closed subset of $[0,1]$ with empty interior and measure greater than $1-\frac{1}{k}$, e.g. a fat Cantor set. Let $g_k(x)=$the distance from $x$ to $C_k$. Let $f_n(x)=\sum\limits_{k=1}^\infty2^{-k}(1-g_k(x))^n$. Each summand is continuous and the convergence of the series is uniform, so each $f_n$ is continuous. The sequence $(f_n)$ decreases to a limit $f$ which is $0$ on the complement of $\bigcup\limits_{k=1}^\infty C_k$, and positive on $\bigcup\limits_{k=1}^\infty C_k$. Since the complement of $\bigcup\limits_{k=1}^\infty C_k$ is dense by Baire's theorem, this implies that $f$ is discontinuous at each point in $\bigcup\limits_{k=1}^\infty C_k$. Since $C_m\subset \bigcup\limits_{k=1}^\infty C_k$ for each $m$, $\bigcup\limits_{k=1}^\infty C_k$ has measure $1$.


As promised, here is my own answer.

Let $D = \{x_1,x_2,\dotsc\}$ be a countable dense subset of $[0,1]$ and let $$ \begin{align*} U_n &= \bigcup_{m=1}^\infty (x_m-2^{-n-m},x_m+2^{-m-j}) \cap [0,1] \text{ and} \\ K_n &= [0,1] \setminus U_n. \end{align*} $$

Hence each $K_n$ is compact (because it's the complement of an open subset of a compact space) and nowhere dense in $[0,1]$ (because $\overline{K_n} = K_n$ cannot contain any point from $D$ so $K_n$ cannot contain any intervals) with $m(K_n) \geq 1-2^{-n}$. Note that we have $K_1 \subseteq K_2 \subseteq \dotsb$, and $E := \cup_n K_n$ is a nowhere dense set with full measure in $[0,1]$.

Using these sets we define a sequence of continuous functions $(f_n)$ mapping $[0,1]$ to itself by

$$f_n(x) = \frac{d(x,x_n)}{d(x,K_n) + d(x,x_n)}.$$

This standard construction of $f_n$ has the property that $f_n$ is $0$ exactly at $x_n$ and is $1$ exactly on $K_n$.

Define $$g_n(x) := \prod_{i=1}^n f_i(x) = f_1(x)\cdot \dotsb \cdot f_n(x).$$

Then the sequence $(g_n)$ is pointwise monotonically decreasing, so it converges to a function $g: [0,1] \to [0,1]$.

If $x \in E$, then it is in $K_N$ for some $N \in \mathbb N$, and then we have for all $n \geq N$ that $f_n(x) = 1$. We further have that $x \notin D$, so $(g_n(x)) = (\prod_{i=1}^nf_i(x))$ is eventually constant and all the factors are positive. Hence $g(x) > 0$, and since $g|_D = 0$ and $D$ is dense, $g$ must be discontinuous at $x$. Since $x$ was arbitrary we conclude that $g$ is discontinuous on $E$ - a comeagre set of measure $1$. $\rule{5pt}{5pt}$

Of course this proof tells us nothing about where $g$ might be continuous. We know that $g(x) = 0$ is a necessary condition for $g$ to be continuous at $x$, but we're unable to even tell whether $g$ is continuous at any point of the dense set $D$ that we started with.