Building Hamiltonian diagonal on given states Usually, in second quantization formalism, we are dealing with hamiltonians that are certain functions of the creation and annihilation operators.
I have been given a particular state and I want to build an Hamiltonian, or more generally an operator, that is diagonal in said basis.
So I want an Hamiltonian of the type
\begin{equation}
\hat{H}=\sum_i c_i|v_i\rangle\langle v_i|
\end{equation}
and I want to see how it looks like as a function of the creation/annihilation operators.
I know how my states $|v_i\rangle$ look like (in the Fock basis representation they are $|v_i\rangle=\hat{a}_i \sum_{n_1,n_1,\dots} f(n_1)f(n_2)\dots|2n_1,2n_2,\dots\rangle$) and I can substitute them into the Hamiltonian to get the representation of the Hamiltonian in the Fock basis.
\begin{equation}
\hat{H}=\sum_ic_i\hat{a}_i \sum_{n_1,n_1,\dots,m_1,m_2,\dots} f(n_1)f(n_2)\dots f(n_1)f(n_2)\dots|2m_1,2m_2,\dots\rangle\langle2m_1,2m_2,\dots|\hat{a}^\dagger_i
\end{equation}
and then I could write $|2n_1,2n_2,\dots\rangle$ as $(a_1^\dagger)^{n_1}(a_2^\dagger)^{n_2}\dots|0,0,\dots\rangle$.
It may be a stupid question but how do I ''get rid'' of the vacuum states $|0,0,\dots\rangle\langle 0,0,\dots|$ or can I even do that? I know that when we have a first quantization Hamiltonian and we want to ''upgrade'' it to the second quantization form we sum over all the particles and over all the states and then we use a completeness relation to get rid of the bra\kets but it doesn't look like I can do it here so I was wondering if I can even ger rid of it.
 A: Let's consider a much simple case: a single harmonic oscillator, where the Fock states are simply $|n \rangle$ where $n \geq 0$. Your original Hamiltonian has the form
$$H_{\text{int}} = \sum_n c_n |n \rangle \langle n |.$$
We can of course rewrite it in the form
$$H_{\text{int}} = \sum_n \frac{c_n}{n!} (a^\dagger)^n |0 \rangle \langle 0| a^n$$
where I'm using a slightly different normalization from you, the standard one for the harmonic oscillator. But this isn't what we want; in second quantized notation the Hamiltonian should be written purely in terms of creation and annihilation operators. For example, if we want a normal ordered Hamiltonian,
$$H_{\text{int}} = \sum_n b_n (a^\dagger)^n a^n.$$
We can't just "erase the $|0 \rangle \langle 0|$" to conclude $b_n = c_n / n!$, because that would not give the same Hamiltonian. However, the coefficients $a_n$ can be related to the $c_n$ in a more complex way. We have
$$c_n = \langle n | H_{\text{int}} |n \rangle = \sum_m b_m \langle n | (a^\dagger)^m a^m | n \rangle = \sum_{m \leq n} \binom{n}{m} b_m.$$
So the second quantized coefficients $b_n$ are the binomial transform of the first quantized coefficients $c_n$,
$$b_n = \sum_{m \leq n} \binom{n}{m} (-1)^{n-m} c_m.$$
This expression, suitably generalized for multiple harmonic oscillators, gives the second-quantized coefficients you want.
The reason you don't often see this in textbooks is because it's usually not needed. Most of the time in field theory, we are directly specifying the $b_n$, so there's no need to get it from the $c_n$. At other times, we specify the $c_n$ but only for low $n$, say up to $n = 1$ or $n = 2$, because higher-body interactions are negligible. This fixes the $b_n$ for low $n$, and then we set the higher $b_n$ to zero.

Here's a simple example of this in action. A simple harmonic oscillator has
$$c_n = n \hbar \omega.$$
This implies that
$$b_n = (-1)^n \hbar \omega \sum_{m \leq n} \binom{n}{m} (-1)^{m} m.$$
Using the defining property of the binomial coefficients,
$$\binom{n}{m} = \binom{n-1}{m-1} + \binom{n-1}{m}$$
the sum becomes
$$b_n = (-1)^n \hbar \omega \sum_{m \leq n} \left(\binom{n-1}{m-1} + \binom{n-1}{m}\right) (-1)^{m} m = (-1)^n \hbar \omega \sum_{k \leq n-1} \binom{n-1}{k} (-1)^{k+1}.$$
Using the binomial theorem, we have
$$b_n = (-1)^{n+1} \hbar \omega (1 - 1)^{n-1} = (-1)^{n+1} \hbar \omega \delta_{n, 1} = \hbar \omega \delta_{n, 1}.$$
As expected, we have $b_1 = \hbar \omega$ with all other coefficients equal to zero.
