Solution (source code)

= Solution

Let the two internal angles be $r=\theta_2$ and $\phi-r=\theta_3$, since the <optical prism> geometry gives $\theta_2+\theta_3=\phi$. By <Snell's law>, the corresponding external angles are $F(r)$ and $F(\phi-r)$, where $F(r)=\arcsin(n\sin r)$. The deviation is
$$
\gamma(r)=F(r)+F(\phi-r)-\phi.
$$
On the transmitted branch with $n>1$ and $0<r<\arcsin(1/n)$,
$$
F''(r)=\frac{n(n^2-1)\sin r}{(1-n^2\sin^2r)^{3/2}}>0.
$$
Thus $F'$ is strictly increasing. The stationary condition $\gamma'(r)=F'(r)-F'(\phi-r)=0$ forces $r=\phi-r$, and the positive second <derivative> makes this the unique <minimum deviation>. Consequently
$$
\boxed{\theta_2=\theta_3=\frac\phi2,\qquad\theta_1=\theta_4.}
$$
The argument assumes a transmitted ray is possible; the symmetric internal angles must lie below the critical angle.