4. Find all functions $f: \mathbb{Z} \rightarrow \mathbb{Z}$, satisfying for any prime $p$:
(1) $f(p)>0$;
(2) For all $x \in \mathbb{Z}$,
$$
p \mid \left((f(x)+f(p))^{f(p)}-x\right).
$$
4. Suppose the function $f$ satisfies the problem statement.

Let $x=p$ (where $p$ is a prime), substituting into condition (2) gives
$p\left|\left((2 f(p))^{f(p)}-p\right) \Rightarrow p\right| 2 f(p)$
$\Rightarrow p \mid 2$ or $p \mid f(p)$.
Let $x=0$, substituting into condition (2) gives
$p \mid\left((f(0)+f(p))^{f(p)}-0\right)$.
Since $p$ is a prime, we have $p \mid(f(0)+f(p))$.
When $p \neq 2$, we have $p|f(p) \Rightarrow p| f(0)$.
Thus, $f(0)$ can divide infinitely many primes.
Therefore, $f(0)=0$.
When $p=2$, we have
$2|(f(0)+f(2)) \Rightarrow 2| f(2)$,
which fits the form of $p \mid f(p)$.
Hence, for any prime $p$, we have $p \mid f(p)$.
Condition (2) is equivalent to for all positive integers $x$ and primes $p$,
$(f(x))^{f(p)} \equiv x(\bmod p)$.
Thus, $p|f(x) \Leftrightarrow p| x$.
At this point, when $x$ is a prime $q$ different from $p$, $f(q)$ cannot be divisible by any prime $p(p \neq q)$.

Given $f(q)>0$, we know $f(q)$ is a power of $q$, combining with Fermat's Little Theorem, we know for all primes $p$ and integers $n$,
$$
n^{p} \equiv n(\bmod p) .
$$

Thus, for non-negative integers $t$, we have $n^{p^{t}} \equiv n(\bmod p)$.
For all primes $p$, since $f(p)$ is of the form $p^{t}(t \in \mathbf{N})$, condition (2) is equivalent to for all positive integers $x$ and primes $p$, we have $f(x) \equiv x(\bmod p)$.
Therefore, for all integers $x$ and primes $p$, we have $p \mid((f(x)-x)$.
Thus, for any fixed $x \in \mathbf{Z}$, the integer $f(x)-x$ can divide infinitely many primes.
Hence, $f(x)-x=0 \Rightarrow f(x)=x$.
Assuming for all $x, f(x)=x$, then for all primes $p$, we have $f(p)>0$, and for all integers $x$

and primes $p$, combining with Fermat's Little Theorem, we know
$$
\begin{array}{l}
(f(x)+f(p))^{f(p)}-x=(x+p)^{p}-x \\
\equiv x^{p}-x \equiv 0(\bmod p) .
\end{array}
$$

Therefore, $f(x)=x$ is the only function that satisfies the problem statement.