Solution (source code)

= Solution

Combining the <EPR criterion of reality> with perfect predictive correlations and locality motivates pre-existing values for the locally selectable observables. The general <local hidden-variable theory> additionally assumes a complete shared variable $\lambda$ and conditional factorization
$$
p(A,B\mid a,b,\lambda)=p_A(A\mid a,\lambda)p_B(B\mid b,\lambda),
\qquad \rho(\lambda\mid a,b)=\rho(\lambda).
$$
The second condition is <measurement independence>. The reality criterion alone does not prove this factorization for arbitrary imperfect correlations: it motivates the local completion whose consequences are being tested.

A <deterministic local hidden-variable model> may be used without loss of generality by putting local random seeds into $\lambda$. For each $\lambda$, write its setting responses as $A,A',B,B'\in\{-1,1\}$. Integrating with the same setting-independent distribution and using the <triangle inequality> gives
$$
\begin{aligned}
|E(a,b)-E(a,b')|+|E(a',b)+E(a',b')|
&\leq\int d\lambda\,\rho(\lambda)
\left(|A(B-B')|+|A'(B+B')|\right)\\
&=\int d\lambda\,\rho(\lambda)
\left(|B-B'|+|B+B'|\right)=2.
\end{aligned}
$$
Exactly one of $B-B'$ and $B+B'$ vanishes and the other has magnitude two. Hence the requested \b[CHSH bound is two]. No assumption about the spacelike quantum state enters this local-model derivation.