I'm going to state and prove a theorem (as we did during a lecture), which basically is contained in Differentiable Functions on Bad Domains - Vladimir G. Maz'ya, Sergei V. Poborchi, and I'll add my question(s) below. I hope that someone will be enough patient to read everything.
Definition (Sobolev space). $\Omega \subseteq \mathbb{R}^N$, $l \in \mathbb{N}$, $p \in [1,\infty]$. We set $$W^{l,p}(\Omega):= \{f \in L^p (\Omega) \, : \, \exists \ D^{\alpha}_w f \in L^p(\Omega) \ \forall \ \alpha \in \mathbb{N}^N \text{ with } |\alpha|=l \}.$$
Theorem (Removable singularities). $\Omega \subseteq \mathbb{R}^N$ open, $l \in \mathbb{N}$, $p \in [1,\infty]$. Let $F \subset \Omega$ be a closed set. If $\mathcal{H}_{N-1} (F)=0$, where $\mathcal{H}_{N-1}$ is the $(N-1)$-dimensional Hausdorff measure, then $W^{l,p}(\Omega) = W^{l,p} ( \Omega \setminus F)$.
Before starting with the proof, a remark is needed:
Remark. The condition $\mathcal{H}_{N-1}(F)=0$ may be replaced with the condition that every projection of $F$ on the coordinates hyperplanes has $(N-1)$-dimensional Lebesgue measure $m( \cdot )$ $=0$.
Proof. Obviously $W^{l,p}(\Omega) \subset W^{l,p}(\Omega \setminus F)$, and we need to prove the converse. Take $ u \in W^{l,p}(\Omega \setminus F)$; it is enough to show that $u_0 \in W^{l,p}(\Omega)$, where $$u_0(x):=\begin{cases} u(x) & \text{if } x \in \Omega \setminus F \\ 0 & \text{if } x \in F. \end{cases}$$In order to do that, we show that $\forall \ |\alpha|=l \ \exists \ D^{\alpha} u_0=(D^{\alpha} u)_0$; in particular is it true that $$\int_{\Omega} u_0 D^\alpha \varphi \, dx = (-1)^{|\alpha|} \int_{\Omega} (D^\alpha u)_0 \varphi \, dx \quad $$for all $\varphi \in \mathcal{C}^\infty _c (\Omega)$ (compactly supported smooth functions)? Let's see.
Using the density of $\mathcal{C}^\infty (\Omega \setminus F) \cap W^{l,p}(\Omega \setminus F)$ in $W^{l,p}(\Omega \setminus F)$, we take a sequence $u_n \in \mathcal{C}^\infty (\Omega \setminus F) \cap W^{l,p}(\Omega \setminus F)$ such that $u_n \to u$ in $W^{l,p}(\Omega \setminus F)$; moreover consider $\Pi^{(i)} : \mathbb{R}^{N} \to \mathbb{R}^{N-1}$ defined by $(x_1, \dots, x_n) \mapsto (x_1, \dots, x_{i-1}, x_{i+1}, \dots, x_n)$.
Note that by Remark $m(F^{(i)})=0$, where clearly $F^{(i)} = \Pi ^{(i)} (F)$. We have $$\int_\Omega u_0 D^{\alpha} \varphi \, dx = \int_{\Omega \setminus F} u D^{\alpha} \varphi \, dx = \lim_{n} \int_{\Omega \setminus F} u_n D^{\alpha} \varphi \, dx. $$Here comes the part I don't understand: $$\boxed{\begin{split}I=\int_{\Omega \setminus F} u_n D^{\alpha} \varphi \, dx & = \int_{\Omega^{(i)}} \int_{ \{x_i \in \mathbb{R} \, : \, (x_1, \dots, x_i, \dots, x_N) \in \Omega \setminus F \}} u_n (x) D^\alpha \varphi (x) \, dx_i \, \dots \, dx_{i-1} \, d_{x_{i+1}} \, \dots \, d x_N \\ & = \int_{\Omega^{(i)} \setminus F^{(i)}} \int_{ \{x_i \in \mathbb{R} \, : \, (x_1, \dots, x_i, \dots, x_N) \in \Omega \} } u_n (x) D^\alpha \varphi (x) \, dx_i \, \dots \, dx_{i-1} \, d_{x_{i+1}} \, \dots \, d x_N \end{split}} $$and then integrating by parts (I'm sorry for the insane notation) we have $$\begin{split} I & = \int_{\Omega^{(i)} \setminus F^{(i)}} (-1)^{\alpha_i} \int_{ \{x_i \in \mathbb{R} \, : \, (x_1, \dots, x_i, \dots, x_N) \in \Omega \} } \frac{\partial^{\alpha_i} u_n}{\partial x_i ^{\alpha_i}} \frac{\partial^{|\alpha|-\alpha_i}\varphi}{\partial x_1 ^{\alpha_1} \dots \partial x_{i-1} ^{\alpha_{i-1}} \partial x_{i+1}^{\alpha_{i+1}} \dots \partial x_N^{\alpha_N}} \, dx_i \, \dots \, dx_{i-1} \, d_{x_{i+1}} \, \dots \, d x_N \\ & = (-1)^{\alpha_i} \int_{\Omega \setminus F} \frac{\partial^{|\alpha|-\alpha_i}\varphi}{\partial x_1 ^{\alpha_1} \dots \partial x_{i-1} ^{\alpha_{i-1}} \partial x_{i+1}^{\alpha_{i+1}} \dots \partial x_N^{\alpha_N}} \, dx = \dots = (-1)^{|\alpha|}\int_{\Omega \setminus F} D^{\alpha} u_n \varphi \, dx. \end{split} $$ Taking the limit $n \to \infty$ one gets the thesis.
Question: I don't get what happens in the box. How is the hypothesis of $m(F^{(i)})=0$ used?
Thank you in advance!
The equality $$ \int_{\Omega \setminus F} (\dots) \, dx = \int_{\Omega^{(i)}} \int_{ \{x_i \in \mathbb{R} \, : \, (x_1, \dots, x_i, \dots, x_N) \in \Omega \setminus F \}} (\dots) \, dx_i \, \dots \, dx_{i-1} \, d{x_{i+1}} $$ is Fubini's theorem. It has nothing to do with the functions being integrated, or with the assumption on $F$. It's just doing integration in order: over $x_i$ first, then over the other variables.
The following step uses the fact that integrating something over $ \Omega^{(i)}$ gives the same result as integrating over $\Omega^{(i)}\setminus F^{(i)}$, since $F^{(i)}$ is negligible. So we can write $$\cdots = \int_{\Omega^{(i)}\setminus F^{(i)}} \int_{ \{x_i \in \mathbb{R} \, : \, (x_1, \dots, x_i, \dots, x_N) \in \Omega \setminus F \}} (\dots) \, dx_i \, \dots \, dx_{i-1} \, d{x_{i+1}} $$ But now the domain of integration over $x_i$ can be simplified: since the projection of $F$ is removed, there is no danger of $(x_1, \dots, x_i, \dots, x_N)$ being in $F$. This leads to $$\cdots = \int_{\Omega^{(i)}\setminus F^{(i)}} \int_{ \{x_i \in \mathbb{R} \, : \, (x_1, \dots, x_i, \dots, x_N) \in \Omega \}} (\dots) \, dx_i \, \dots \, dx_{i-1} \, d{x_{i+1}} $$