How do we know that the Cauchy principal value gives the right answer in a calculation of $\int_{-\infty}^\infty\frac{\sin x}{x}dx$? In calculating the integral
$$\int_{-\infty}^{\infty} \frac{\sin x}{x}dx$$
by contour integration, we use
$$\int_{-\infty}^{\infty} \frac{\sin x}{x}dx = \int_{-\infty}^{\infty} \frac{\operatorname{Im}(e^{ix})}{x}dx =\operatorname{Im}\left(\int_{-\infty}^{\infty} \frac{e^{ix}}{x}dx \right)$$
but in the process, we have gone from an integral which is well-defined with no real singularities to one with a real singularity which in fact is just undefined as an improper integral. Therefore, in the source I am reading, we take the cauchy principal value (CPV) of the integral on the RHS instead of treating it as an improper integral. This principal value is calculated by use of the Residue Theorem.
My question: There are different ways to treat singularities in integrals. How do we know that this one (the CPV) will give us the correct result for $\int_{-\infty}^{\infty} \frac{\sin x}{x}dx$? Of course, knowing the answer by other methods, we can compare and see it was correct, but I'm looking to understand why the reasoning is valid.
Response to 1st answer: Simply saying that the integral converges is not enough. We need some way to know that in particular the CPV is the correct notion of integration for the exponential integral. Clearly, not any notion of integration which converges must give the correct result.
Response to 2nd answer: The question I ask is: by what reasoning is the notion of CPV in $\int_{-\infty}^{\infty} \frac{\sin x}{x}dx =\operatorname{Im}\left(CPV\int_{-\infty}^{\infty} \frac{e^{ix}}{x}dx \right)$ justified. Of course the first integral is the same as an improper integral or CPV, this just doesn't answer the question.
 A: In order to say that the Cauchy principal value agrees with the ordinary value of an improper integral you only need to know that the integral coverges, which you may show using a convergence test. This is because the Cauchy principal value is simply a particularly easy way of taking the limit. The Cauchy principal value takes the limit symmetrically. If the limit exists, it means you can take it in any manner you like, for example symmetrically.
A: Since this is a question about rigor we should state what integral we are using. From (1) This integral is not Lebesgue integrable as it is not absolutely convergent, it is an improper Riemann integral though so we will use the Riemann integral.
Let us have a visual of the function being integrated


When we state the purely real integral $$I_1 = \int_{-\infty}^{\infty} \frac{\sin x}{x}dx$$ this is short-hand for $$I_1 = \lim_{a \to -\infty} \lim_{b \to \infty} \int_{a}^{b} f(x) dx$$ where $$f(x) = \begin{cases}
\frac{\sin(x)}{x} & x \not = 0 \\
1 & x = 0 \\
\end{cases}$$
The convergence of this integral must be addressed. It does not converge absolutely so we should attempt to cancel parts of the integral with itself. We will show that the right side (from $2\pi$ to $\infty$) converges by chopping it up and subtracting the negative part of each sine wave from the positive part. For each segment we have
$$\begin{align}
&\, \left|\int_{\pi 2 k}^{\pi (2 k + 2)} \frac{\sin(x)}{x} dx\right| \\
\le&\, \left|\int_{\pi 2 k}^{\pi (2 k + 1)} \frac{\sin(x)}{x} - \frac{\sin(x)}{x + \pi} dx\right| \\
\le&\, \left|\int_{\pi 2 k}^{\pi (2 k + 1)} \frac{\sin(x)}{\pi (2 k + 1)} - \frac{\sin(x)}{\pi (2 k + 2)} dx\right| \\
\le&\, \left|\int_{\pi 2 k}^{\pi (2 k + 1)} \frac{\sin(x)}{\pi} \left[\frac{1}{2 k + 1} - \frac{1}{2 k + 2}\right] dx\right| \\
\end{align}$$
and the alternating harmonic series converges. Note that each segment is positive and their sum converges absolutely. Note that we showed the integral from $0$ to $\infty$ converges independently of the integral from $-\infty$ to $0$.
The finite part from $0$ to $2 \pi$ easily converges as we always have $\sin(x)/x \le 1$.

When we state a contour integral like
$$I_2 = \mathrm{p.v.} \int_\gamma \frac{e^{i z} - e^{-i z}}{2 i \cdot z} dz$$
($\gamma$ denoting a line from $-\infty$ to $\infty$).
the meaning (2) is that the we delete from the contour $\gamma$ an $\epsilon$ sized ball around the singularity and take the limit of $\epsilon$ to 0.
So $$I_2 = \lim_{\epsilon \to 0} \lim_{a \to -\infty} \lim_{b \to \infty} \left(\int_a^{-\epsilon} + \int_{\epsilon}^b\right) \frac{e^{i z} - e^{-i z}}{2 i \cdot z} dz$$
Regarding convergence of $I_2$, this integral (or half of it, to be precise) drops out algebraically from an application of Cauchy's Theorem (that a contour integral around a closed curve not containing poles gives 0) to the meromorphic function $e^{iz}/z$. The details are here.

Now to show $I_1 = I_2$. The single exceptional point at $x=0$ has no bearing on the value of the integral $I_1$ so we may split $I_1$ around 0 and add a $\lim_{\epsilon \to 0}$ on it. Now $I_1 - I_2 = 0$ can be shown. Rewrite $I_2$ to use the complex $\sin$ function.
$$\begin{align}
I_1 - I_2 =& \left[\lim_{a \to -\infty} \lim_{b \to \infty} \int_{a}^{b} f(x) dx \right] - \left[\lim_{\epsilon \to 0} \lim_{a \to -\infty} \lim_{b \to \infty} \left(\int_a^{-\epsilon} + \int_{\epsilon}^b\right) \frac{e^{i z} - e^{-i z}}{2 i \cdot z} dz\right] \\
=& \left[\lim_{\epsilon \to 0} \lim_{a \to -\infty} \lim_{b \to \infty} \left(\int_a^{-\epsilon} + \int_{\epsilon}^b\right) \frac{\sin(x)}{x} dx \right] - \left[\lim_{\epsilon \to 0} \lim_{a \to -\infty} \lim_{b \to \infty} \left(\int_a^{-\epsilon} + \int_{\epsilon}^b\right) \frac{\sin(z)}{z} dz\right]  \\
=& \lim_{\epsilon \to 0} \lim_{a \to -\infty} \lim_{b \to \infty} \left(\int_a^{-\epsilon} + \int_{\epsilon}^b\right) \left[\frac{\sin(x)}{x} - \frac{\sin(x)}{x} \right]  dx \\
=& 0
\end{align}$$


*

*(1) https://en.wikipedia.org/wiki/Dirichlet_integral

*(2) https://en.wikipedia.org/wiki/Cauchy_principal_value

*(3): Theorem 15.2 of Complex Analysis - M.W. Wong https://books.google.co.uk/books?id=7OKiVxvselkC&pg=PA94&redir_esc=y#v=onepage&q&f=false proves that if the improper integral exists then the cauchy p.v. exists and is equal.

A: Why the Cauchy Principal Value Gives the Proper Value
Your question boils down to the following
$$
\begin{align}
&\mathrm{Im}\left(\mathrm{PV}\int_{-\infty}^\infty\frac{e^{ix}}x\,\mathrm{d}x\right)\\
&=\mathrm{Im}\left(\mathrm{PV}\int_{-\infty}^\infty\frac{\cos(x)}x\,\mathrm{d}x+i\,\mathrm{PV}\int_{-\infty}^\infty\frac{\sin(x)}x\,\mathrm{d}x\right)\tag{1a}\\
&=\mathrm{Im}\left(\lim_{\epsilon\to0}\int_{|x|\gt\epsilon}\frac{\cos(x)}x\,\mathrm{d}x+i\int_{-\infty}^\infty\frac{\sin(x)}x\,\mathrm{d}x\right)\tag{1b}\\
&=\mathrm{Im}\left(0+i\int_{-\infty}^\infty\frac{\sin(x)}x\,\mathrm{d}x\right)\tag{1c}\\
&=\int_{-\infty}^\infty\frac{\sin(x)}x\,\mathrm{d}x\tag{1d}
\end{align}
$$
Explanation:
$\text{(1a)}$: $e^{ix}=\cos(x)+i\sin(x)$ and $\mathrm{PV}$ is linear
$\text{(1b)}$: definition of $\mathrm{PV}$ on the cosine integral
$\phantom{\text{(1b):}}$ $\mathrm{PV}$ of a convergent integral is that integral
$\text{(1c)}$: the integral of an odd function over a domain
$\phantom{\text{(1c):}}$ symmetric about the origin is $0$
$\text{(1d)}$: take the imaginary part
Actually, it doesn't even matter what the Principal Value of the cosine integral is. As long as it exists and is real, it is eliminated by taking the imaginary part.

Avoid Singularities Altogether
There is no singularity whatsoever in
$$
\int_{-\infty}^\infty\frac{\sin(x)}x\,\mathrm{d}x\tag2
$$
The way to compute this integral and never come close to a singularity is to note that
$$
\lim_{R\to\infty}\int_{\gamma_R}\frac{\sin(z)}z\,\mathrm{d}z=0\tag3
$$
where $\gamma_R=[-R,R]\cup[R,R-i]\cup[R-i,-R-i]\cup[-R-i,-R]$. This is because there are no singularities inside this contour for any $R$.
Furthermore, the integral vanishes on $[R,R-i]$ and $[-R-i,-R]$ as $R\to\infty$ since $|\sin(z)|\le\cosh(1)$ and $|z|\ge R$ and the length of each path is $1$. Thus, the integral over both paths is no bigger than $\frac{2\cosh(1)}R$.
Discounting the integrals which vanish, $(3)$ becomes
$$
\int_{-\infty}^\infty\frac{\sin(x)}x\,\mathrm{d}x=\int_{-\infty-i}^{\infty-i}\frac{\sin(z)}z\,\mathrm{d}z\tag4
$$
The path of integration on the right side of $(4)$ passes nowhere near a singularity. Use $\sin(z)=\frac{e^{iz}-e^{-iz}}{2i}$ to evaluate the right side of $(4)$:
$$
\begin{align}
\int_{-\infty-i}^{\infty-i}\frac{\sin(z)}z\,\mathrm{d}z
&=\frac1{2i}\int_{-\infty-i}^{\infty-i}\frac{e^{iz}}z\,\mathrm{d}z-\frac1{2i}\int_{-\infty-i}^{\infty-i}\frac{e^{-iz}}z\tag{5a}\\
&=\frac1{2i}\lim_{R\to\infty}\int_{\gamma_R^+}\frac{e^{iz}}z\,\mathrm{d}z-\frac1{2i}\lim_{R\to\infty}\int_{\gamma_R^-}\frac{e^{-iz}}z\tag{5b}
\end{align}
$$
where $\gamma_R^+=[-R-i,R-i]\cup Re^{i[0,\pi]}-i$ and $\gamma_R^-=[-R-i,R-i]\cup Re^{i[0,-\pi]}-i$. $\text{(5b)}$ follows because the integrals along the huge arcs go to $0$; $e^{iz}$ vanishes exponentially in the upper half-plane and $e^{-iz}$ vanishes exponentially in the lower half-plane. In fact, the integrals along those arcs are bounded by
$$
\begin{align}
\int_0^\pi\overbrace{e^{-R\sin(\theta)+1}\vphantom{\frac RR}}^{\large e^{\pm iz}}\overbrace{\ \frac{R\,\mathrm{d}\theta}{R-1}\ }^{\mathrm{d}z/z}
&\le\frac{2eR}{R-1}\int_0^{\pi/2}e^{-2R\theta/\pi}\,\mathrm{d}\theta\tag{6a}\\
&\le\frac{2eR}{R-1}\frac\pi{2R}\tag{6b}\\[3pt]
&=\frac{e\pi}{R-1}\tag{6c}
\end{align}
$$
Since $\gamma_R^-$ contains no singularities, the integral on the right-hand side of $\text{(5b)}$ is $0$. Since $\gamma_R^+$ contains the singularity at $0$, whose residue is $1$, we get that the integral on the left-hand side of $\text{(5b)}$ is $2\pi i$.
Putting together $(2)-(5)$, we conclude
$$
\int_{-\infty}^\infty\frac{\sin(x)}x\,\mathrm{d}x=\pi\tag7
$$
A: The value of the improper integral is $$\lim\limits_{\substack{z\to&\,\,\,\infty \\ y\to&-\infty}}\int_y^z\frac{\sin x}{x}\,\mathrm{d}x$$  Clearly, if this limit exists, then so does the Cauchy principal value, and it has the same value as the integral.
I would appreciate it if someone would show me how to properly format the limit, so that both lines are the same size.
A: I don't think there is a way in which we can rigorously use the expression $$\operatorname{Im}\left(\int_{-\infty}^{\infty} \frac{e^{ix}}{x}dx \right)$$
If you test the following in wolfram alpha for example

*

*integral from 0.0000001 to inf of e^(ix)/x dx

*integral from 0.0000000001 to inf of e^(ix)/x dx

*integral from 0.00000000000001 to inf of e^(ix)/x dx
you can see that the 'value' of this integral (we are using the cauchy principal value of course) would be "$\infty + i \tfrac{\pi}{2}$". Not a valid complex number, it's just a divergent integral so we can't really take the imaginary part to just throw away the infinity.
You may be be able to do manipulation with the divergent integral and still get right answers but I wouldn't trust it.
Note that the convergence of a Reimann integral is stronger than the convergence of the C.P.V.
