Formal identity involving fermion propagator in quantum field theory I'm studying from here: Roberto Soldati - Field Theory 2. Intermediate Quantum Field Theory (A Next-to-Basic Course for Primary Education)
I'm trying to understand and prove an equality at page 52, between equations $(2.36)$ and $(2.37)$. The equality is the following
$$
\langle x|(i\not\!{\partial} - M )^{-1}|y\rangle = - i S_F(x - y) \tag{1}
$$
Where $S_F$ is a fermion propagator and satisfies
$$
(i\not\!{\partial} - M ) S_F(x - y) = i \delta^{(4)}(x-y) \tag{2}
$$
and whose explicit expression is the following
$$
S_F(x - y) = \int \frac{d^4p}{(2\pi)^4} \frac{i}{\not\! p - m + i\epsilon} e^{-ip\cdot(x-y)}\\
= \int \frac{d^4p}{(2\pi)^4} \frac{i(\not\! p + m)}{p^2 - m^2 + i\epsilon} e^{-ip\cdot(x-y)} \tag{3}
$$
I tried to prove the equality, but


*

*I am not sure my proof is correct, therefore I want to ask you: is it?

*If it is correct there is a passage I don't really understand a passage, I don't know why I did it, beside from the fact that it gives me the correct result.


My attempt:
Starting from $(2)$ I multiply both sides for  $(i\not\!{\partial_x} - M )^{-1}$ obtaining 
$$
-iS_F(x-y)= (i\not\!{\partial_x} - M )^{-1} \delta^{(4)}(x-y) = (i\not\!{\partial_x} - M )^{-1} \int \frac{d^4p}{(2\pi)^4}  e^{-ip\cdot(x-y)}
$$
Now, like in standard QM: $e^{-ip\cdot x} = \langle x|p\rangle$ and $e^{ip \cdot y}=\langle p|y\rangle$ and I have
$$
-iS_F(x-y)= \int \frac{d^4p}{(2\pi)^4} \langle x|(i\not\!{\partial_x} - M )^{-1}|p\rangle \langle p|y\rangle
$$
Now I solve the integral in $d^4p$, and since $\int \frac{d^4p}{(2\pi)^4}\langle p|y\rangle= \delta^{(4)}(x-y)$, I obtain
$$
-iS_F(x-y) = \langle x|(i\not\!{\partial} - M )^{-1}|y\rangle
$$
So is this correct? If it is why I can put the operator $(i\not\!{\partial_x} - M )^{-1}$ inside $\langle x|p\rangle$ ? I thought that since we have $i\not\!{\partial_x}$ it can be that the operator acts on the bra or ket with $x$, is it right?
I'm pretty sure I'm making some mistakes and confusion, could you clarify why that equality is true?
 A: The proof is unnecessarily confusing. It is hard to follow, and so it is hard to tell whether it is correct or not.
But anyway, here is the simplest approach. In fact, let us do something slightly more general. Let $D=D(i\partial)$ be an arbitrary differential operator, and consider the expression
$$
\mathscr D:=\langle x|D|y\rangle
$$
We will ultimately take $D(z)=1/(\not\! z-M+i\epsilon)$, but the approach works for more general differential operators.
One can insert a complete set of momentum states in the form
$$
1=\int\frac{\mathrm d^np}{(2\pi)^n}|p\rangle\langle p|
$$
such that
$$
\begin{aligned}
\mathscr D&=\langle x| D\,1|y\rangle\\
&=\int\frac{\mathrm d^np}{(2\pi)^n}\langle x|D|p\rangle\langle p|y\rangle
\end{aligned}
$$
Now use
$$
D(i\partial)|p\rangle=D(p)|p\rangle,\qquad \langle p|z\rangle=\mathrm e^{ipz}
$$
to write
$$
\begin{aligned}
\color{red}{\mathscr D}&=\int\frac{\mathrm d^np}{(2\pi)^n}D(p)\overbrace{\langle x|p\rangle}^{\mathrm e^{-ipx}}\overbrace{\langle p|y\rangle}^{\mathrm e^{ipy}}\\
&=\color{red}{\int\frac{\mathrm d^np}{(2\pi)^n}D(p)\mathrm e^{ip(y-x)}}
\end{aligned}
$$
In the case in the OP, we have $D(z)=1/(\not\! z-M+i\epsilon)$, and so
$$
\langle x|(i\not\!\partial-M)^{-1}|y\rangle\equiv \int\frac{\mathrm d^np}{(2\pi)^n}\frac{1}{\not\! p-M+i\epsilon}\mathrm e^{ip(y-x)}
$$
which is precisely the fermion propagator, $S(x-y)$, as required.
