4. If $2 x+y \geqslant 1$, then the minimum value of the function $u=y^{2}-2 y+x^{2}$ $+4 x$ is $\qquad$
4. $u_{\min }=-\frac{9}{5}$.

By completing the square from $u=y^{2}-2 y+x^{2}+4 x$, we get
$$
(x+2)^{2}+(y-1)^{2}=u+5 \text {. }
$$

The left side $(x+2)^{2}+(y-1)^{2}$ can be interpreted as the square of the distance between point $P(x, y)$ and the fixed point $A(-2,1)$. The constraint $2 x+y \geqslant 1$ indicates that point $P$ is in the region $G$ which is the right upper area of the line $l: 2 x+y=1$.

Thus, the problem is transformed into finding the minimum distance between point $A(-2,1)$ and the points in region $G$, which is the distance $d$ from point $A$ to the line $l$:
$$
d=\frac{|2 \times(-2)+1-1|}{\sqrt{2^{2}+1^{2}}}=\frac{4}{\sqrt{5}} .
$$

Therefore, $d^{2}=\frac{16}{5}$.
From $u+5=\frac{16}{5}$, we have $u=\frac{16}{5}-5=-\frac{9}{5}$,
which means $u_{\text {min }}=-\frac{9}{5}$.