4. Given that $\triangle A B C$ and $\triangle A D E$ are both isosceles triangles, $\angle A=90^{\circ}, A B=2 A D=4$. As shown in Figure 1, $\triangle A D E$ is rotated counterclockwise around point $A$ by an angle $\alpha$, and the extension of $B D$ intersects line $C E$ at point $P$, as shown in Figure 2.
Figure 1
Figure 2
During the process of rotating $\triangle A D E$ counterclockwise around point $A$ from $0^{\circ}$ to $180^{\circ}$, the length of the path traced by point $P$ is $\qquad$
4. $\frac{4 \sqrt{2} \pi}{3}$.

Let $\angle B A D=\alpha$. It is easy to know that,
$$
\begin{array}{l}
\triangle A C E \cong \triangle A B D \Rightarrow \angle E C A=\angle D B A \\
\Rightarrow \angle P C B+\angle C B P=90^{\circ} \Rightarrow \angle B P C=90^{\circ} .
\end{array}
$$

Therefore, point $P$ moves on the arc with $B C$ as the diameter, i.e., $P$ moves on the circumcircle arc of $\triangle A B C$, as shown in Figure 5.
When $\alpha=0^{\circ}$, point $P$ coincides with $A$.
Since point $D$ moves on the circle with $A$ as the center and 2 as the radius, the farthest position of $B D$ is the tangent of $\odot A$.

Since $A B=2 A D$, it is easy to know that $\alpha=60^{\circ}$. Let the position of point $P$ at this time be $P_{0}$. Then $\angle P_{0} B A=30^{\circ}$.
Take the midpoint $O$ of side $B C$, and connect $O P_{0}, O A$.
Thus, $\angle P_{0} O A=60^{\circ}$, i.e., $\overparen{P_{0} A^{\circ}}=60^{\circ}$.
By $O P_{0}=O A=\frac{1}{2} B C=2 \sqrt{2}$, in the process of $\triangle A D E$ rotating counterclockwise from $0^{\circ}$ to $180^{\circ}$ around point $A$, point $P$ moves on the arc $\overparen{P_{0} A^{\circ}}=60^{\circ}$ once back and forth, i.e., its path is the arc $\overparen{A P}_{0}+\overparen{P_{0} A}$ with $O$ as the center and $O A$ as the radius.
Thus, the length of the path of point $P$ is
$$
\begin{aligned}
l & =\overparen{A P}_{0}+\overparen{P_{0} A}=2 \overparen{A P_{0}} \\
& =\frac{60 \pi \times 2 \sqrt{2}}{180} \times 2=\frac{4 \sqrt{2} \pi}{3} .
\end{aligned}
$$