XORGameValue

XORGameValue is a function that computes the classical or quantum value of a nonlocal binary XOR game. That is, it computes the optimal probability of two parties (Alice and Bob) winning such a game, assuming that they can communicate before the game, but not during the game, and either (1) they cannot share entanglement, or (2) they can share entanglement.

Syntax

 * VAL = XORGameValue(P,F)
 * VAL = XORGameValue(P,F,VTYPE)

Argument descriptions

 * P: A matrix whose (s,t)-entry gives the probability that the referee will give Alice the value s and Bob the value t. The sum of all entries of this matrix must be 1.
 * F: A binary matrix (of the same size as P) whose (s,t)-entry indicates the winning choice (either 0 or 1) when Alice and Bob receive values s and t from the referee.
 * VTYPE (optional, default 'classical'): One of 'classical' or 'quantum', indicating whether or not Alice and Bob can use quantum strategies (i.e., shared entanglement).

The CHSH game
The CHSH game is a game in which the referee (uniformly at random) gives each of Alice and Bob a single bit, and Alice and Bob win if the XOR of their responses is the AND of the bits received by the referee. That is, Alice and Bob want the XOR of their responses to be 1 if and only if they both received a 1 from the referee.

It is well-known that the maximum probability of winning this game if Alice and Bob share entanglement is $\cos^2(\pi/8)$, whereas the maximum probability of winning this game without entanglement is $3/4$. The following code demonstrates this fact: the p</tt> matrix has each entry 1/4</tt> because each of the 4 possible combinations of bits from the referee are equally likely, and the matrix f</tt> equals [0 0;0 1]</tt> because Alice and Bob want the XOR of their answers to be 1 only when they both receive a 1 from the referee (the first row of the matrix corresponds to Alice receiving a 0, the second row of the matrix corresponds to Alice receiving a 1, and the columns are similar for Bob).

The odd cycles game
The odd cycles game is a game where Alice and Bob try to convince the referee that an cycle of length n has a 2-coloring, which is impossible when n is odd. The referee gives each of Alice and Bob a number from 1 to n (representing the n different vertices of the n-cycle), and Alice and Bob respond with a color (0 or 1). They win the game if either (1) the referee gave Alice and Bob the same number and Alice and Bob's responses are the same; or (2) the referee gave Alice and Bob numbers that differ by 1 (corresponding to adjacent vertices) and Alice and Bob's responses are different. Otherwise, they lose the game.

If $n$ is odd, it is known that the maximum probability of winning this game with shared entanglement is $\cos^2(\pi/4n)$, whereas the maximum probability of winning this game without entanglement is $1 - 1/(2n)$. These facts are verified by the following code when $n = 5$: