Understanding Bell's inequality vs. quantum mechanics I have difficulty to understand how Bell's inequality rules out local hidden variable theory. It seems to me that there is some hidden variable in the Kolmogorov's axiomatization of probability theory, where quantum mechanic is based, so what's the point?
To be precise, first let's state Bell's (or called CHSH) inequality in mathematical terms:

Suppose $X,Y,X',Y'$ are random variables which are almost surely bounded by $1$. Then we have $\mathbb E\lvert XY+XY'+X'Y-X'Y'\rvert\le2$.

It easily follows from the fact that $\lvert XY+XY'+X'Y-X'Y'\rvert\le2$ a.s.
Now let's focus on spin measurement, which contradicts Bell's inequality, and where Hilbert spaces are finite dimensional therefore we needn't care about infinitude issues.
Let $H=\mathbb Ce_1\oplus\mathbb Ce_2$ be the state space of spin 1/2, and $H\otimes H$ to be the state space of the spin measurement. We prepare for the initial state $\psi=(e_1\otimes e_2-e_2\otimes e_1)/\sqrt2$. As computed in wiki page, there is a specific choice of $a,b,a',b'\in S^2$ (for example, $a=(1,0,0),a'=(0,1,0),b=(1/\sqrt2,-1/\sqrt2,0),b'=(1/\sqrt2,1/\sqrt2,0)$) such that $S(a,b,a',b'):=\sigma(a,b)+\sigma(a,b')+\sigma(a',b)-\sigma(a',b')=-2\sqrt2$, hence the measurement results of spins cannot be described as random variables of a probability space. On the other hand, the measurement results should be random variables by the formulation of quantum mechanics. I don't understand what's really involved here.
I call for a mathematical explanation for this. Any help is welcome. Thanks!
EXPLANATIONS:
It seems to me that I need to elaborate the description for spin measurements. First, $H=\mathbb Ce_1\oplus\mathbb Ce_2$ is a Hilbert space with Hermitian product $\langle x_1e_1+x_2e_2,y_1e_1+y_2e_2\rangle=\overline{x_1}y_1+\overline{x_2}y_2$. Pauli matrices $S_x=\begin{bmatrix}0&1\\1&0\end{bmatrix},S_y=\begin{bmatrix}0&-i\\i&0\end{bmatrix},S_z=\begin{bmatrix}1&0\\0&-1\end{bmatrix}$ (which correspond to spins around $x,y,z$-axes) acts on this space, and set $S_u=xS_x+yS_y+zS_z$ for $u=(x,y,z)\in S^2$. It seems to me that the measurement results are associated with random variables. For example, the measurement result of the spin around $u$ is measured by the observable $S_u\otimes1$, and the correlation $\sigma(u,v)$ with expectation of the random variable correspondent to $S_u\otimes S_v$. The state vector is $\psi=(e_1\otimes e_2-e_2\otimes e_1)/\sqrt2$ (normalized), therefore $\sigma(u,v)=\langle\psi,(S_u\otimes S_v)\psi\rangle$. (I didn't take advantage of Dirac's notation)
 A: In the Kolmogorov formalism, you could call the entire sample space a "hidden variable", since it is usually not observed directly but only through actual random variables. The reason it doesn't conflict with Bell's inequality is that is is not local -- on the contrary it is the most global hidden variable conceivable, governing both which measurement the observers at each end of the experiment decide to make, and how the two entangled particles react to those measurements.
My understanding (which is filtered through several popular works, so caveat lector) is that the kind of "hidden variable theory" that Bell's theorem rules out is one where there are three independent random variables $A$, $B$ and $H$, such that


*

*Which measurement is made on one of the particles is a deterministic function of the value of $A$.

*The result of that measurement is a deterministic function of the values of $A$ and $H$ together.

*Which measurement is made on the other particle is a deterministic function of the value of $B$.

*The result of that measurement is a determiniatic function of the values of $B$ and $H$ together.

*Each of the relevant measurements has a nonzero chance of being performed.


I order to get the frequencies predicted by the quantum model one either needs to drop the assumption that $A$, $B$ and $H$ are independent or to modify the model such that, say, the result of the second measurement depends on both $A$ and $B$. (The latter is what the usual quantum mechanics formalism does; while also dispensing with $H$).
The various "loopholes" that have been proposed for Bell-inequality tests can generally be understood as proposals for physically plausible ways that two of the three variables might have a dependence in the particular experiment being considered.
A: I don't think that we need the formalism of quantum mechanics to explain the problem of hidden variables in general. Also, we do not need inequalities to see what could go wrong with them. However, without defining in a specific situation what a hidden variable is one will never understand the point.

Imagine that I have two nice, honest looking homogeneous discrete Markov chains with the same state space $\{1,2\}$ and with the same state transition matrix: $\left[\begin{smallmatrix}\frac12\frac12\\\frac12\frac12\end{smallmatrix}\right].$ I allow my Markov chains  to agree in advance from which state they will start working. This pair of initial states is their secret, this pair will be the hidden variable. 

Then I send away my Markov chains with the secret hidden variable in their pockets. One has to go to the oak tree to the left and the other one has to go to the elm tree to the right. At the trees there are two observers who will take notes about the moves of the separated Markov chains. We agree that the Markov chains will change state when I whistle. I call back my Markov chains and the observers after 100 whistles.

When the observers and the Markov chains come back it turns out that the chain's states were just the opposite. When the Markov chain at the oak tree was in state $1$ then the other one at the elm tree was in state $2$. Yes, of course, they must have agreed to start in these initial states. But, according to the logs they stayed in this strange mirrored situation while changing states properly during the whole experiment. At least the two observers did not see anything strange in the behavior of the separated Markov chains.  Both observers told that on oath. 

Question: Can one explain the strange mirrored behavior of the two Markov chains by assuming that they managed to choose a suitable pair of initial states (the hidden variable)? No! The two impostors had to exchange signals otherwise their behavior could not be so much harmonized.

So, this specific phenomenon could not be explained by assuming the existence of a well defined hidden variable.

As far as locality: The behavior of the Markov chains was not local. Either the random events at the oak tree influenced the random looking events at the elm tree or vice versa...
