4. Find all positive integer triples $(x, y, z)$ such that
$$
2^{x}+1=7^{y}+2^{z} \text {. }
$$
4. Since $x, y, z \in \mathbf{Z}_{+}$, we have $7^{y}>1$.

Thus, $2^{x}>2^{z} \Rightarrow x>z$.
Rewriting the original equation, we get
$$
\begin{array}{l}
2^{z}\left(2^{x-z}-1\right)=7^{y}-1 . \\
\text { Since } 7^{y} \equiv 1(\bmod 3) \\
\Rightarrow 3 \text { divides }\left(7^{y}-1\right) \\
\Rightarrow 3 \text { divides }\left(2^{x-z}-1\right)
\end{array}
$$
$$
\Rightarrow x-z \text { is even. }
$$

We will consider two cases.
(1) If $y$ is odd, by the lifting the exponent lemma, we have
$$
\begin{array}{l}
v_{2}\left(7^{y}-1\right)=v_{2}(7-1)=1 \\
\Rightarrow v_{2}\left(2^{z}\right)=1 \\
\Rightarrow z=1 .
\end{array}
$$

Substituting into the original equation, we get $2^{x}=7^{y}+1$.
Again, by the lifting the exponent lemma, we have
$$
\begin{array}{l}
v_{2}\left(7^{y}+1\right)=v_{2}(7+1)=3 \\
\Rightarrow v_{2}\left(2^{x}\right)=3 \\
\Rightarrow x=3, y=1 \\
\Rightarrow(x, y, z)=(3,1,1) .
\end{array}
$$
(2) If $y$ is even, let $y=2 k\left(k \in \mathbf{Z}_{+}\right)$, then $2^{z}\left(2^{x-z}-1\right)=49^{k}-1$.
(i) If $k$ is odd, by the lifting the exponent lemma, we have
$$
\begin{array}{l}
v_{2}\left(49^{k}-1\right)=v_{2}(49-1)=4 \\
\Rightarrow v_{2}\left(2^{z}\right)=4 \\
\Rightarrow z=4 .
\end{array}
$$

Substituting into the original equation, we get $2^{x}-49^{k}=15$.
Since $x-z$ is even and $z=4$, $x$ is also even.
Let $x=2 t\left(t \in \mathbf{Z}_{+}\right)$. Then
$$
\begin{array}{l}
4^{t}-49^{k}=15 \\
\Leftrightarrow\left(2^{t}+7^{k}\right)\left(2^{t}-7^{k}\right)=15 .
\end{array}
$$

Since $2^{t}+7^{k} \leqslant 15$, we have
$$
\begin{array}{l}
7^{k}<15 \Rightarrow k=1 . \\
\text { By } 4^{t}=64 \Rightarrow t=3
\end{array}
$$
$$
\begin{array}{l}
\Rightarrow x=6, y=2 \\
\Rightarrow(x, y, z)=(6,2,4) \text {. }
\end{array}
$$
(ii) If $k$ is even, let $k=2 l\left(l \in \mathbf{Z}_{+}\right)$, then $y=4 l$.
Since $49^{k} \equiv(-1)^{k} \equiv 1(\bmod 25)$
$$
\Rightarrow 25 \text { divides }\left(2^{x-z}-1\right) \text {. }
$$

Let $x-z=2 a\left(a \in \mathbf{Z}_{+}\right)$. Then $25 \text { divides }\left(4^{a}-1\right)$.
Since $5 \text { divides }\left(4^{a}-1\right)$, $a$ is even.
Let $a=2 b\left(b \in \mathbf{Z}_{+}\right)$. Then
$$
2^{z}\left(16^{b}-1\right)=49^{k}-1 \text {. }
$$

By the lifting the exponent lemma, we have
$$
\begin{array}{l}
v_{5}\left(2^{z}\left(16^{b}-1\right)\right)=v_{5}\left(16^{b}-1\right) \\
=v_{5}(16-1)+v_{5}(b)=1+v_{5}(b) .
\end{array}
$$

Since $v_{5}\left(49^{k}-1\right) \geqslant 2$, we have
$$
1+v_{5}(b) \geqslant 2 \Rightarrow v_{5}(b) \geqslant 1 \text {. }
$$

This implies that $5 \text { divides } b$.
Let $b=5 c\left(c \in \mathbf{Z}_{+}\right)$. Then
$$
\begin{array}{l}
2^{x-z}-1=2^{20 c}-1=1024^{2 c}-1 \\
\equiv 0(\bmod 1023) .
\end{array}
$$

Since $31 \text { divides } 1023$, we have $31 \text { divides }\left(7^{y}-1\right)$.
$$
\begin{array}{l}
\text { Also, } 7^{15}=\left(7^{3}\right)^{5} \equiv 343^{5} \equiv 2^{5} \\
\equiv 32 \equiv 1(\bmod 31),
\end{array}
$$

and $7,7^{3}, 7^{5} \not\equiv 1(\bmod 31)$, so the order of 7 modulo 31 is 15.
Thus, $15 \text { divides } y$.
Since $3 \text { divides } y$ and $4 \text { divides } y$, we have $12 \text { divides } y$.
By Fermat's Little Theorem, we have
13 divides $\left(7^{y}-1\right)$
$\Rightarrow 13 \text { divides }\left(2^{x-z}-1\right)$.
Since the order of 2 modulo 13 is 12, we have $12 \text { divides }(x-z)$.
By Fermat's Little Theorem, we have 7 divides $\left(2^{x-x}-1\right)$, which contradicts that $2^{x-z}-1$ is not divisible by 7.
In summary, the solutions are
$(x, y, z)=(3,1,1),(6,2,4)$.