# NonlocalGameValue

 Other toolboxes required NonlocalGameValue Computes the maximum value of a two-player non-local game cvx BellInequalityMaxNPAHierarchyXORGameValue Nonlocality and Bell inequalities no

NonlocalGameValue is a function that computes the maximum possible value of a given non-local game under either classical mechanics, quantum mechanics, or general no-signalling theories. In the classical and non-signalling cases, an exact value is computed, whereas the value computed in the quantum case is only an upper bound (found using the NPA hierarchy).

## Syntax

• NGVAL = NonlocalGameValue(P,V)
• NGVAL = NonlocalGameValue(P,V,MTYPE)
• NGVAL = NonlocalGameValue(P,V,MTYPE,K)

## Argument descriptions

• P: A probability matrix whose $(x,y)$-entry gives the probability that the referee asks Alice question $x$ and Bob question $y$.
• V: A 4-D array whose $(a,b,x,y)$-entry gives the value awarded to Alice and Bob if they reply with answers $(a,b)$ to questions $(x,y)$.
• MTYPE (optional, default 'classical'): A string indicating which type of theory should be used when computing the maximum value of the non-local game. Must be one of 'classical', 'quantum', or 'nosignal'. If MTYPE = 'quantum' then only an upper bound on the non-local game is computed, not necessarily is best upper bound (see the argument K below).
• K (optional, default 1): If MTYPE = 'quantum' then this is a non-negative integer indicating what level of the NPA hierarchy should be used when bounding the value of the non-local game. Higher values of K give better bounds, but require more memory and time. Alternatively, K can be a string of a form like '1+ab+aab', which indicates that an intermediate level of the hierarchy should be used, where this example uses all products of 1 measurement, all products of one Alice and one Bob measurement, and all products of two Alice and one Bob measurement. Use plus signs to separate the different categories of products, as above. The first character of this string should always be a number, indicating the base level to use. If MTYPE is anything other than 'quantum' then K has no effect.

## Examples

### The CHSH inequality

One formulation of the CHSH inequality[1] is as follows:

• A referee asks Alice a question $x \in \{0,1\}$ and Bob a question $y \in \{0,1\}$.
• Alice and Bob then reply with answers $a \in \{0,1\}$ and $b \in \{0,1\}$ respectively.
• Alice and Bob win if and only if $a \oplus b = xy$.

The optimal probability with which Alice and Bob can win this game in classical, quantum, and no-signalling theories are as follows:

>> d = 2;
>> p = ones(d,d)/d^2;
>> V = zeros(d,d,d,d);
>> for a = 1:d
for b = 1:d
for x = 1:d
for y = 1:d
if(mod(a+b+x*y,d)==0)
V(a,b,x,y) = 1;
end
end
end
end
end
>> NonlocalGameValue(p,V,'classical')

ans =

0.7500

>> NonlocalGameValue(p,V,'quantum',1)

ans =

0.8536

>> NonlocalGameValue(p,V,'nosignal')

ans =

1.0000

### The CHSH-d inequality

A generalization of the CHSH inequality to higher dimensions is exactly as above, except each of $a,b,x,y$ are taken from the set $\{0,1,\ldots,d-1\}$.[2] The following code computes the values of the CHSH-3 game:

>> d = 2;
>> p = ones(d,d)/d^2;
>> V = zeros(d,d,d,d);
>> for a = 1:d
for b = 1:d
for x = 1:d
for y = 1:d
if(mod(a+b+x*y,d)==0)
V(a,b,x,y) = 1;
end
end
end
end
end
>> NonlocalGameValue(p,V,'classical')

ans =

0.6667

>> NonlocalGameValue(p,V,'quantum',1)

ans =

0.7182

>> NonlocalGameValue(p,V,'quantum',2)

ans =

0.7182

>> NonlocalGameValue(p,V,'quantum','2+aab')

ans =

0.7124

>> NonlocalGameValue(p,V,'nosignal')

ans =

1.0000

## Notes

In practice, K probably can't be any larger than 4 when MTYPE = 'quantum'.

## References

1. J.F. Clauser, M.A. Horne, A. Shimony, R.A. Holt. Proposed experiment to test local hidden-variable theories. Phys. Rev. Lett., 23(15):880–884, 1969.
2. M. Howard. Maximum nonlocality and minimum uncertainty using magic states. E-print: arXiv:arXiv:1501.05319 [quant-ph], 2015.