4. Find all functions $f(x)$ and $g(x)$ that satisfy the following condition:
$$
f(x)+f(y)+g(x)-g(y)=\sin x+\cos y, \quad x, y \in \mathrm{R}.
$$
4. Let $x=y$ substitute into the given equation, we get $f(x)=\frac{\sin x+\cos x}{2}$, so $\frac{\sin x+\cos x}{2}+\frac{\sin y+\cos y}{2}+g(x)-g(y)=\sin x+\sin y$, which leads to $g(x)-\frac{1}{2} \sin x+\frac{1}{2} \cos x=g(y)-\frac{1}{2} \sin y+\frac{1}{2} \cos y$. Let $h(x)=g(x)-\frac{1}{2} \sin x+\frac{1}{2} \cos x$, since for any $x, y \in \mathrm{R}, h(x) \equiv h(y)$, so $h(x)=$ constant, thus we deduce $\dot{f}(x)=\frac{\sin x+\cos x}{2}, g(x)=\frac{\sin x-\cos x}{2}+c$.