Solution (source code)

= Solution

A risky-asset portfolio $\varphi$ financed through the risk-free asset has zero-cost discounted gain
$$
G_\varphi=\varphi^T(S_1-(1+r)S_0).
$$
It is an <arbitrage> when $G_\varphi\geq0$ almost surely and $\mathbb P(G_\varphi>0)>0$.