Solution (source code)

= Solution

The dual of the <Kantorovich optimal transport problem> is
$$
\boxed{\sup_{(u,v)\in\mathcal A_c}\left\{\int_Xu\,d\mu+\int_Yv\,d\nu\right\},}
$$
where the <Kantorovich potentials> are measurable representatives satisfying
$$
\mathcal A_c=\{(u,v):u\in L^1(\mu),\ v\in L^1(\nu),\ u(x)+v(y)\leq c(x,y)\ \text{for every }(x,y)\in X\times Y\}.
$$
One standard form of the <Kantorovich duality theorem> assumes that $X,Y$ are <Polish spaces>, $\mu,\nu$ are <probability measures> defined as <Borel measures>, and $c:X\times Y\to[0,+\infty]$ is <sequentially lower semicontinuous>. Then
$$
\boxed{\min_{\pi\in\Pi(\mu,\nu)}\int c\,d\pi
=\sup_{(u,v)\in\mathcal A_c}\left(\int u\,d\mu+\int v\,d\nu\right).}
$$
The primal infimum is attained; its value may be $+\infty$. Nonnegativity can be replaced by a constant lower bound by shifting the cost. This duality for lower semicontinuous costs is also discussed in https://arxiv.org/abs/0911.4347[Beiglboeck, Leonard and Schachermayer's duality paper].

\b[Equality of values does not by itself assert a dual maximum.] A sufficient stronger setting for attainment on both sides is <compact metric spaces> $X,Y$ and a finite <continuous> cost $c$; then <continuous> <Kantorovich potentials> attain the dual supremum. The general statement above correctly uses a supremum.