Solution (source code)

= Solution

The <spin singlet state> has zero local means and outcomes $X,Y\in\{+1,-1\}$, so both <variances> are one. Its <Pearson correlation coefficient> is therefore $C=\mathbb E[XY]$. Summing over the four joint outcomes gives
$$
\boxed{C=P_{++}+P_{--}-P_{+-}-P_{-+}.}
$$
The equal-sign products contribute $+1$ and the opposite-sign products contribute $-1$. In a finite sample the corresponding relative frequencies estimate these probabilities; the formula is not an assertion that a finite random sample has exactly zero empirical means.