I'm really confused on the discretization stuff on this chapter of P&S. My question is related to the computation of the Action in scalar field theory done in page 285. When they compute the action of the real scalar field, they get $$ \int d^4x\left(\frac{1}{2}(\partial_\mu \phi)^2-\frac{1}{2}m^2\phi^2\right)=-\frac{1}{V}\sum_n\frac{1}{2}(m^2-k_n^2)|\phi(k_n)|^2.\tag{p.285} $$
I'm stuck on this equation. Here is what I tried to do:
Following from the left-hand side, I can use the properties of the (continuous) Fourier transform and get $$ \int d^4x\left(\frac{1}{2}(\partial_\mu \phi)^2-\frac{1}{2}m^2\phi^2\right)=\int d^4x \frac{1}{2}\left(k^2-m^2\right)(\phi(x))^2. $$
The field is real, therefore $(\phi(x))^2 = |\phi(x)|^2$. Now I think Parseval's theorem should be used, $$ \int d^4x \frac{1}{2}\left(k^2-m^2\right)(\phi(x))^2 = \dfrac{1}{2}(k^2-m^2)\int d^4x |\phi(x)|^2 =\dfrac{1}{2}(k^2-m^2)\int \dfrac{d^4k}{(2\pi)^4}|\phi(k)|^2. $$
Changing the integral in $d^4k$ to a series in $n$, (I'm assuming I can use eq. 9.22 backwards $\int \frac{d^4k}{(2\pi)^4} \to \frac{1}{V}\sum_n$), $$ \dfrac{1}{2}(k^2-m^2)\int \dfrac{d^4k}{(2\pi)^4}|\phi(k)|^2 = \dfrac{1}{2V}(k^2-m^2)\sum_n|\phi(k_n)|^2. $$
Here is a problem, I have a continuous variable $k$ and a discrete one $k_n$ on the same equation instead of just $k_n$. What I'm doing wrong? Is the eq. 9.22 backwards the problem?