Rigorous explanation of second quantization of Hamiltonian

I am having trouble understanding the formalism of second quantization. I haven't found any reference with a rigorous explanation. For simplicity, lets say I want to write the second quantized form of the Hamiltonian $$H=\sum_i \frac{p_i^2}{2m}.$$ I've found answers like \begin{align} H &=\int d^3rd^3r'\sum_{i,j}|i\rangle\langle i|r\rangle\langle r|\sum_i\frac{p_i^2}{2m}|r'\rangle\langle r'|j\rangle\langle j| \\&=-\int d^3rd^3r'\sum_{i,j}|i\rangle\phi_i^*(r)\frac{\hbar^2}{2m}\Delta\delta(r-r')\phi_j(r')\langle j| \\&=-\int d^3r\sum_{i,j}a_i^\dagger\phi_i^*(r)\frac{\hbar^2}{2m}\Delta\phi_j(r)a_j \\&=-\int d^3r\psi^\dagger(r)\frac{\hbar^2}{2m}\Delta\psi(r). \end{align} To begin with, doesn't this answer forget to differentiate the delta function? Why do they put $|i\rangle$ (which I understand is a one particle state) equal to the creation operator $a_i^\dagger$? Where do these symbols live! Are they in Fock space? Are they in the single particle Hilbert space? I need better definitions. Any help understanding this or pointing me to a good reference is appreciated.

• For a better explanation with everything nicely defined I recommend the first few pages of Altland and Simons. – knzhou Feb 20 '18 at 21:57