4. Let the function $y=f(x)$ be defined on $\mathbf{R}$, and have an inverse function $f^{-1}(x)$. It is known that the inverse function of $y=f(x+1)-2$ is $y=f^{-1}(2 x+1)$, and $f(1)=4$. If $n \in \mathbf{N}_{+}$, then $f(n)=$ $\qquad$
$$
\begin{array}{l}
\text { 4. } 3+\left(\frac{1}{2}\right)^{n-1} \text {. } \\
\text { Given } y=f^{-1}(2 x+1) \\
\Rightarrow 2 x+1=f(y) \\
\Rightarrow x=\frac{1}{2}(f(y)-1) .
\end{array}
$$

Thus, the inverse function of $y=f^{-1}(2 x+1)$ is
$$
y=\frac{1}{2}(f(x)-1) \text {. }
$$

Then, $f(x+1)-2=\frac{1}{2}(f(x)-1)$.
Hence, $f(n+1)-3=\frac{1}{2}(f(n)-3)$
$$
\begin{array}{l}
=\cdots \\
=(f(1)-3)\left(\frac{1}{2}\right)^{n}=\left(\frac{1}{2}\right)^{n} .
\end{array}
$$

Therefore, $f(n)=3+\left(\frac{1}{2}\right)^{n-1}$.