4. Given $\overrightarrow{O P}=(2,1), \overrightarrow{O A}=(1,7), \overrightarrow{O B}=(5,1)$. Let $X$ be a point on the line $O P$ (where $O$ is the origin). Then, the value of $\angle A X B$ when $\overrightarrow{X A} \cdot \overrightarrow{X B}$ is minimized is ( ).
(A) $90^{\circ}$
(B) $\arccos \frac{4 \sqrt{17}}{17}$
(C) $\arccos \left(\frac{-4 \sqrt{17}}{17}\right)$
(D) $\pi+\arccos \left(-\frac{4 \sqrt{17}}{17}\right)$
4. (C).

Let $\overrightarrow{O X}=\left(x_{0}, y_{0}\right), \overrightarrow{O P}=(2,1)$, then $\frac{x_{0}}{2}=\frac{y_{0}}{1}$.
$\therefore x_{0}=2 y_{0}$, then
$$
\begin{array}{c}
\overrightarrow{X A}=\left(1-2 y_{0}, 7-y_{0}\right), \overrightarrow{X B}=\left(5-2 y_{0}, 1-y_{0}\right) . \\
\therefore \overrightarrow{X A} \cdot \overrightarrow{X B}=\left(5-2 y_{0}\right)\left(1-2 y_{0}\right)+\left(1-y_{0}\right) \cdot \\
\left(7-y_{0}\right)=5 y_{0}^{2}-20 y_{0}+12 .
\end{array}
$$

Therefore, when $y_{0}=2$, $\overrightarrow{X A} \cdot \overrightarrow{X B}$ has the minimum value, at this time, $\overrightarrow{O X}=(4,2), \overrightarrow{X A}=(-3,5), \overrightarrow{X B}=(1,-1),|\overrightarrow{X A}|=$ $\sqrt{34},|\overrightarrow{X B}|=\sqrt{2}$,
thus, $\cos \angle A X B=\frac{\overrightarrow{X A} \cdot \overrightarrow{X B}}{|\overrightarrow{X A}| \cdot|\overrightarrow{X B}|}$
$$
=\frac{(-3,5) \cdot(1,-1)}{\sqrt{34} \cdot \sqrt{2}}=\frac{-8}{\sqrt{68}}=-\frac{4 \sqrt{17}}{17} \text {. }
$$