4. Let $x, y \in \mathbf{R}$, and
$$
\frac{\sin ^{2} x-\cos ^{2} x+\cos ^{2} x \cdot \cos ^{2} y-\sin ^{2} x \cdot \sin ^{2} y}{\sin (x+y)}=1 \text {. }
$$

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

From the problem, we know
$$
\begin{array}{c}
\sin ^{2} x \cdot \cos ^{2} y-\cos ^{2} x \cdot \sin ^{2} y \\
=\sin (x+y) \cdot \sin (x-y),
\end{array}
$$

and $\sin (x+y) \neq 0$.
Therefore, $\sin (x-y)=1$.
Hence, $x-y=2 k \pi+\frac{\pi}{2}(k \in \mathbf{Z})$.