I have the following problem:
$$u_t=u_{xx}, x>0, t>0$$ $$u(x=0,t)=0 , t>0$$ $$u(x,t=0)=f(x), x>0$$
The solution of the problem is: $$u(x,t)=\int_0^{+\infty} a(k) \sin(kx) e^{-k^2t} dk$$
$$u(x,0)=f(x)=\int_0^{+\infty} a(k) \sin(kx) dk$$
$$\sin(k'x) f(x)= \sin(k'x) \int_0^{+\infty} a(k) \sin(kx) dk \Rightarrow \int_{0}^{\infty}\sin(k'x) f(x) dx = \int_0^{+\infty} a(k) \sin(kx) \sin(k'x) dk dx$$
We know the integral:
$$\int_{-\infty}^{+\infty} e^{-i(k-k')x}dx= 2 \pi \delta(k-k')$$
$$e^{-ikx} e^{ik'x}=\cos(kx) \cos(k'x)+\sin(kx) \sin(k'x)+ i(\cos(kx) \sin(k'x)-sin(kx) \cos(k'x)) $$
Why do we know that $e^{-ikx} e^{ik'x}=$ is real,so $\cos(kx) \sin(k'x)-sin(kx) \cos(k'x)=0$ ?
Also, why $\int_{-\infty}^{+\infty} (\cos(kx) \cos(k'x)+\sin(kx) \sin(k'x))dx=2 \int_{\infty}^{+\infty} \sin(kx) \sin(k'x) dx$ ?
If I understand your question properly you are asking two things. The first of which is "why is $e^{-i(k-k^\prime)x}$ real?". The answer to this is, it's not. I think your confusion is arising from the fact that the result of the integral is a real function (the Direc-$\delta$ function), however the integral of a complex function is not necessarily complex itself.
Consider Fourier transforming the $\delta$ function:
$$\int_{-\infty}^\infty e^{-i k x} \,\delta(x) \, dx = e^{-i\, k\, 0} = 1$$
from the definition of the $\delta$-function. Therefore the (inverse) Fourier transform of a constant function gives us back the $\delta$. The factor of $2\pi$ comes from the definition of the Fourier transform used here, there are different definitions however.
The second part asked why
$$\int_{-\infty}^\infty \cos(kx)\cos(k^\prime x)+\sin(kx)\sin(k^\prime x)\, dx = 2\int_{-\infty}^\infty\sin(kx)\sin(k^\prime x)\,dx$$
This is quite easy to see if we consider that
$$\int_a^b f(x) \, dx = \int_{a+c}^{b+c} f(x-c)\, dx,$$
That is, if we shift a function by $c$ but also shift the limits of integration to compensate for this we get the same answer back. So in our case we can shift $\cos(x)$ by $-\pi/2$, but since the limits are $\pm\infty$ they do not change and we use that $\cos(x-\pi/2)=\sin(x)$ giving us the answer.
Though this integral does not converge and we obtained it through the wrong assumption that $e^{-i (k-k^\prime) x}$ was real.
Hope this helps.