5. Let $0<x<y<\frac{\pi}{2}$. Then
$$
P=\cos 2 x-\cos 2 y-4 \cos x+4 \cos y
$$

the range of values for $P$ is $\qquad$
5. $(-2,0)$.

From the given, we have
$$
P=2\left[\left(\cos ^{2} x-2 \cos x\right)-\left(\cos ^{2} y-2 \cos y\right)\right] \text {. }
$$

Let $f(t)=t^{2}-2 t$. Then
$$
P=2[f(\cos x)-f(\cos y)] \text {. }
$$

Given $0<x<y<\frac{\pi}{2}$, we know $0<\cos y<\cos x<1$.
Combining with the graph of the quadratic function $f(t)=t^{2}-2 t$, we have
$$
-1<f(\cos x)<f(\cos y)<0 \text {. }
$$

Thus, $-1<f(\cos x)-f(\cos y)<0$.
Therefore, $-2<P<0$.