4. Find all functions $f: \mathbf{R} \rightarrow \mathbf{R}$, such that for any $x, y \in \mathbf{R}$, the following holds:
$$
f(x+y) \leqslant f\left(x^{2}+y\right) .
$$
For $\varepsilon\left(0<\varepsilon<\frac{1}{4}\right)$, take $x=\frac{1+\sqrt{1+4 \varepsilon}}{2}$, then for any $y$, we have
$$
f\left(\frac{1+\sqrt{1+4 \varepsilon}}{2}+y\right) \leqslant f\left(\frac{1+\sqrt{1+4 \varepsilon}+2 \varepsilon}{2}+y\right) \text {, }
$$

i.e., for any $y$, we have
$$
f(y) \leqslant f(\varepsilon+y) \text {. }
$$

Similarly, take $x=\frac{1+\sqrt{1-4 \varepsilon}}{2}$, we get for any $y$,
$$
f(y+\varepsilon) \leqslant f(y) .
$$

Thus, for any $y$, we have
$$
f(y) \leqslant f(\varepsilon+y) \leqslant f(y) \text {. }
$$

Let $\varepsilon \rightarrow 0$, we know that $f(x)$ is a constant function.
Therefore, $f(x)=c(c \in \mathbf{R})$.