Derivation of the Klein Gordon Propagator

I'm learning some quantum field theory. I'm currently using the book An Introduction to Quantum Field Theory by Peskin and Schroeder. I have a problem that I can't figure out at the moment. It is related to the derivation of the Klein-Gordon propagator.

It goes like this Assuming $x^0>y^0$

Step 1 $$<0|[\phi(x),\phi(y)]|0>=\int \frac{d^3p}{(2\pi)^3}\frac{1}{2E_\textbf{p}}(e^{-ip\cdot(x-y)}-e^{ip\cdot(x-y)})$$ The $p^0$ is equal to $=E_\textbf{p}$ in both exponents. Since we’re integrating over all $\textbf{p}$ we can change the integration variable from $\textbf{p}$ to $-\textbf{p}$ in the second term and thus obtain

Step 2 $$\begin{equation} <0|[\phi(x),\phi(y)]|0> = \int \frac{d^3p}{(2\pi)^3}\Big(\frac{1}{2E_\textbf{p}}e^{-ip\cdot(x-y)}\Big |_{p^0=E_\textbf{p}}+\frac{1}{-2E_\textbf{p}}e^{-ip\cdot(x-y)}\Big |_{p^0=-E_\textbf{p}}\Big) \end{equation}$$ So if $x^0>y^0$

Step 3 $$\begin{equation} \label{eq:1} <0|[\phi(x),\phi(y)]|0> = ∫\frac{d^3p}{(2π)^3}∫\frac{dp^0}{2πi}\frac{−1}{p^2−m^2}e^{−ip⋅(x−y)} \end{equation}$$

Question: I don't understand what happens between Step 2 and Step 3. I need some clarification. Why is an integrand over $p^0$ suddenly appearing Where did we get the $2\pi i$ from and why do we only have one term now instead a sum of two?

First, Klein-Gordon propagator is defined as $$\left<0\right| \text{T} \phi(x) \phi(y) \left|0\right>$$ where $\text{T}$ is the chronological ordering symbol. The commutator does not enter this definition. Thus the two terms shouldn't appear there.
Second, the appearance of the $dp^0$ integral is a mathematical trick. You can check that it indeed works by deforming the contour in the complex plane such that it doesn't pass through poles and take the sum of residues in the poles: $$\int_\Gamma dz f(z) = 2 \pi i \cdot \sum_{i} \text{Res}[f, z_i].$$
In our case there's only one pole though. The exact choice of the pole is determined by the $i \varepsilon$ prescription (i.e. this explains why we are interested in the Feynman propagator in QFT).
• FWIW: there are several KG propagators; the $T$ one is the symmetric (or Feynman's) propagator, and the one in the OP is the casual one (see e.g. ncatlab.org/nlab/show/Feynman+propagator for other propagators). – AccidentalFourierTransform Sep 8 '17 at 22:41