4. Let the area of $\triangle ABC$ be 1, and the midpoints of sides $AB$ and $AC$ be $E$ and $F$, respectively. Let $P$ be a moving point on segment $EF$. Then
$$
f=\overrightarrow{P B} \cdot \overrightarrow{P C}+\overrightarrow{B C}^{2}
$$

the minimum value of $f$ is . $\qquad$
4. $\sqrt{3}$.

Construct $P D \perp B C$ at point $D$. Let $B C=a$.
As shown in Figure 2, when point $D$ is on the line segment $B C$ or the extension of $C B$,
$$
\begin{aligned}
f & =(\overrightarrow{P D}+\overrightarrow{D B}) \cdot(\overrightarrow{P D}+\overrightarrow{D C})+B C^{2} \\
& =\overrightarrow{P D}^{2}+\overrightarrow{D B} \cdot \overrightarrow{D C}+a^{2} \\
& \geqslant \frac{1}{4} h_{a}^{2}+a^{2}>a h_{a}=2>\sqrt{3} .
\end{aligned}
$$

As shown in Figure 3, when point $D$ is on the side $B C$,
$$
\begin{aligned}
f & =(\overrightarrow{P D}+\overrightarrow{D B}) \cdot(\overrightarrow{P D}+\overrightarrow{D C})+B C^{2} \\
& =\overrightarrow{P D}^{2}+\overrightarrow{D B} \cdot \overrightarrow{D C}+a^{2} \\
& \geqslant \frac{1}{4} h_{a}^{2}-|\overrightarrow{D B}||\overrightarrow{D C}|+a^{2} \\
& \geqslant \frac{1}{4} h_{a}^{2}-\frac{a^{2}}{4}+a^{2}=\frac{3 a^{2}+h_{a}^{2}}{4} \\
& \geqslant \frac{\sqrt{3}}{2} a h_{a}=\sqrt{3} .
\end{aligned}
$$

When $D$ is the midpoint of line segment $B C$ and $a=\sqrt{\frac{2}{\sqrt{3}}}$, the equality holds.
In summary, $f_{\text {min }}=\sqrt{3}$.