4. Let $x, y \in \mathbf{R}$, and $\frac{\sin ^{2} x-\cos ^{2} x+\cos ^{2} x \cos ^{2} y-\sin ^{2} x \sin ^{2} y}{\sin (x+y)}=1$, then $x-y=$ $\qquad$
$$
\begin{array}{l}
\sin ^{2} x-\cos ^{2} x+\cos ^{2} x \cos ^{2} y-\sin ^{2} x \sin ^{2} y=\sin ^{2} x\left(1-\sin ^{2} y\right)-\cos ^{2} x\left(1-\cos ^{2} y\right) \\
=\sin ^{2} x \cos ^{2} y-\cos ^{2} x \sin ^{2} y=\sin (x+y) \sin (x-y)
\end{array}
$$

Then, $\sin (x-y)=1 \Rightarrow x-y=2 k \pi+\frac{\pi}{2}(k \in \mathbf{Z})$.