Solution (source code)

= Solution

Let $\mathbf d=\mathbf a_2-\mathbf a_1$ and $\mathbf w=\mathbf v_1\times\mathbf v_2$. The assumed <linear independence> gives $\mathbf w\ne\mathbf0$. Every displacement joining one <line> to the other is
$$
\mathbf s=\mathbf d+\lambda_2\mathbf v_2-\lambda_1\mathbf v_1.
$$
Its <dot product> with $\mathbf w$ is always $\mathbf d\cdot\mathbf w$. The component in that direction is therefore fixed, so <orthogonal decomposition> gives $\|\mathbf s\|\geq|\mathbf d\cdot\mathbf w|/\|\mathbf w\|$.

The two <linearly independent vectors> $\mathbf v_1,\mathbf v_2$ span the <plane> perpendicular to $\mathbf w$. Suitable $\lambda_1,\lambda_2$ cancel the component of $\mathbf d$ in that <plane>, attaining the lower bound. Thus the <distance between skew lines> formula, also valid when the <lines> intersect, gives
$$
\boxed{d(L_1,L_2)=\frac{|(\mathbf a_2-\mathbf a_1)\cdot(\mathbf v_1\times\mathbf v_2)|}{\|\mathbf v_1\times\mathbf v_2\|}.}
$$