Explain step in Galindo and Pascual (Quantum Mechanics I) proof of self-adjointness of the momentum operator in QM In the book Quantum Mechanics (Volume I) by Galindo & Pascual, they define the domain of the QM momentum operator on the Hilbert space $\mathcal{H}=L^2(\mathbb{R})$ as
\begin{equation*}
  D(P)=\Biggl\{\psi\in\mathcal{H}: \psi\text{ absolutely continuous,}
  \int_{-\infty}^\infty\!dx\,\Biggl\lvert\frac{d\psi(x)}{dx}\Biggr\rvert^2<\infty\Biggr\}
\end{equation*}
and the momentum operator $P$ by
$$(P\psi)(x)=-i\frac{d\psi(x)}{dx}.$$
They go on to prove that $P$ is densely defined and symmetric. To prove that $P$ is self-adjoint, they attempt to show that $D(P^\dagger)\subseteq D(P)$. Here are the next couple of lines of the proof:
... consider a function $\psi\in D(P^\dagger)$ and define $\psi_1=P^\dagger\psi$; then
$$\langle\psi|P|\varphi\rangle=\langle\psi_1|\varphi\rangle,\quad\forall\varphi\in D(P)$$
can be rewritten as
\begin{equation*}
  \begin{split}
    \langle\psi|P|\varphi\rangle
    &=\int_{-\infty}^\infty\!dx\,\psi_1^*(x)\varphi(x)\\
    &=i\int_{-\infty}^\infty\!dx\Biggl[\frac{d}{dx}
    \Biggl(i\int_0^x\!dt\,\psi_1(t)+c\Biggr)^*\Biggr]\varphi(x),
  \end{split}
\end{equation*}
where $c$ is an arbitrary constant. Choosing $\varphi\in C^\infty_0$, integrating by parts,
and taking into account that $\varphi$ is zero outside a finite interval, we obtain
\begin{equation}\tag{2.16}
  \int_{-\infty}^\infty\!dx\Biggl(\psi(x)-i\int_0^x\!dt\,\psi_1(t)-c\Biggr)^*
  \Biggl(-i\frac{d\varphi(x)}{dx}\Biggr)=0,\quad\forall\varphi\in C^\infty_0.
\end{equation}
[So far, this seems OK to me. It is the next statement that I don't follow:]
Since $C^\infty_0$ is dense in $L^2(\mathbb{R})$, the first factor of the integrand
in (2.16) must be a constant and hence, with a convenient choice $c_0$ for $c$, we can write
almost everywhere
\begin{equation}\tag{2.17}
  \psi(x)=c_0+i\int_0^x\!dt\,\psi_1(t),
\end{equation}
[and it goes on from there]
I want to concentrate on the validity of going from (2.16) to (2.17). I understand that,
with total lack of rigor, if we have
$$\int h\varphi'=0\quad\forall\varphi\in C^\infty_0$$
we'd like to do an integration by parts and write
$$\int h'\varphi=\int h\varphi'=0\quad\forall\varphi\in C^\infty_0$$
from which we would get that $h'=0$ almost everywhere hence $h=c$ almost everywhere.
But I don't see how to apply that here since I don't know that $\psi$ is differentiable a.e.
or even a.e. on a compact interval.
It even looks like a version of the DuBois-Raymond theorem from variational calculus, but I only know that for continuous functions on a compact interval, so it would seem to not apply here.
So, my questions are:


*

*how do you get from (2.16) to (2.17)?

*what element of $L^2(\mathbb{R})$ would they be talking about when they say that $C^\infty_0$
is dense in $L^2(\mathbb{R})$?
 A: The fact that $C_0^\infty$ is dense in $L^2$ allows to have $(2.16)$ but with any function from $L^2$ in place of the second bracket (that is, given any $g\in L^2$ there is a $\varphi\in C_0^\infty$ such that $-i\varphi'$ is as close to $g$ as you want). 
In particular you can use the function $g= \psi(x)-i\int_0^x\!dt\,\psi_1(t)-c$, and you get $\int_{-\infty}^{\infty}|g|^2=0,$ so $g=0$. That is, $$\psi(x)-i\int_0^x\!dt\,\psi_1(t)-c=0,$$ which is $(2.17)$.
A: I found an answer in this post: https://math.stackexchange.com/a/428744/527829
I'll convert it to the current situation.$\newcommand{\loc}{\mathop{\rm loc}}$
Let $\varphi\in C^\infty_0(\mathbb{R})$. Choose any $\varphi_1\in C^\infty_0(\mathbb{R})$ such that $\int_{-\infty}^\infty\!\varphi_1=1$. Let
$[a,b]$ contain the supports of both $\varphi$ and $\varphi_1$. Put $\alpha=\int_{-\infty}^\infty\!\varphi$ and $\varphi_0(x)=\int_a^x\!(\varphi(t)-\alpha\varphi_1(t))\,dt$. Then $\varphi_0'(x)=\varphi(x)-\alpha\varphi_1(x)$ for all $x\in\mathbb{R}$,
so $\varphi_0\in C^\infty(\mathbb{R})$. For $t\leq a$,
$\varphi(t)-\alpha\varphi_1(t)=0$, so for $x\leq a$, $\varphi_0(x)=0$. For $x\geq b$,
$$\varphi_0(x)=\varphi_0(b)=\int_a^b\!\varphi-\Biggl(\int_{-\infty}^\infty\!\varphi\Biggr)\Biggl(\int_a^b\!\varphi_1\Biggr)=0,$$
so $\varphi_0\in C^\infty_0(\mathbb{R})$.
Let $u\in L^1_{\loc}(\mathbb{R})$ such that $\int_{-\infty}^\infty\!u\varphi'=0$ for all $\varphi\in C^\infty_0(\mathbb{R})$. Put $c=\int_{-\infty}^\infty\!u\varphi_1$
and $\tilde{u}=u-c\in L^1_{\loc}(\mathbb{R})$.
In the following, all the limits of integration are from $-\infty$ to $\infty$:
\begin{equation*}
  \begin{split}
    \int\!\tilde{u}\varphi
    &=\int\!(u-c)(\varphi_0'+\alpha\varphi_1)
    =\int\!u\varphi_0'-c\int\!\varphi_0'+\alpha\int\!u\varphi_1-\alpha c\int\varphi_1\\
    &=0-c\cdot(0-0)+\alpha\int\!u\varphi_1-\alpha\biggl(\int\!u\varphi_1\biggr)\cdot 1
    =0.\qquad\qquad\qquad\qquad\qquad\qquad(1)
  \end{split}
\end{equation*}
Since $\tilde{u}\in L^1_{\loc}(\mathbb{R})$ and (1) holds for all $\varphi\in C^\infty_0(\mathbb{R})$, we have (for example by Lang Real and Functional Analysis Chapter VI Corollary 9.5) that $u-c=\tilde{u}=0$ almost everywhere.
Apply this in (2.16) with
$$u(x)=\Biggl(\psi(x)-i\int_0^x\!dt\,\psi_1(t)-c\Biggr)^*.$$
