# BellInequalityMax

 Other toolboxes required BellInequalityMax Computes the maximum value of a Bell inequality CVX NPAHierarchyParallelRepetitionXORGameValue Nonlocality and Bell inequalities no

BellInequalityMax is a function that computes the maximum possible value of a given Bell inequality or nonlocal 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

• BMAX = BellInequalityMax(COEFFICIENTS,DESC,NOTATION)
• BMAX = BellInequalityMax(COEFFICIENTS,DESC,NOTATION,MTYPE)
• BMAX = BellInequalityMax(COEFFICIENTS,DESC,NOTATION,MTYPE,K)

## Argument descriptions

• COEFFICIENTS: A matrix or tensor that specifies the coefficients of the Bell inequality in either full probability, full correlator, or Collins-Gisin notation.
• DESC: A vector of 4 elements describing the number of outputs of Alice, number of outputs of Bob, number of inputs of Alice, and number of inputs of Bob, in this order.
• NOTATION: A string indicating in which notation are the coefficients of the Bell inequality given. Must be one of 'fp', 'fc', or 'cg', for full probability, full correlator, or Collins-Gisin, respectively.
• MTYPE (optional, default 'classical'): A string indicating which type of theory should be used when computing the maximum value of the Bell inequality. Must be one of 'classical', 'quantum', or 'nosignal'. If MTYPE = 'quantum' then only an upper bound on the Bell inequality is computed, not necessarily is best upper bound (see the argument K below).
• K (optional, default 1): If MTYPE = 'quantum' then this is a positive integer indicating what level of the NPA hierarchy should be used when bounding the Bell inequality. 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 says that if $\{A_1,A_2\}$ and $\{B_1,B_2\}$ are $\{-1,+1\}$-valued measurement settings, then in classical physics the following inequality holds: $\langle A_1 B_1 \rangle + \langle A_1 B_2 \rangle + \langle A_2 B_1 \rangle - \langle A_2 B_2 \rangle \leq 2.$ Similarly, the best bound on this quantity is $2\sqrt{2}$ in a quantum mechanical setting (this is Tsirelson's bound), and it is $4$ in no-signalling theories. All three of these bounds can be found as follows:

>> M = [0 0 0;0 1 1;0 1 -1];
>> desc = [2 2 2 2];
>> BellInequalityMax(M,desc,'fc','classical')

ans =

2

>> BellInequalityMax(M,desc,'fc','quantum')

ans =

2.8284

>> BellInequalityMax(M,desc,'fc','nosignal')

ans =

4

### The CHSH inequality again

Another (equivalent) formulation of the CHSH inequality is in Collins-Gisin notation. We write in terms of only the probabilities of obtaining one of the outcomes, as the other probabilities are redundant given the normalization and no-signalling conditions. In this formulation, the following inequality holds in classical theories: $p(11|11) + p(11|12) + p(11|21) - p(11|22) - p_A(1|1) - p_B(1|1) \leq 0.$ Similarly, the best bound on this quantity is $1/\sqrt{2} - 1/2$ in a quantum mechanical setting, and it is $1/2$ in no-signalling settings. These three bounds can be verified as follows:

>> M = [0 -1 0; -1 1 1; 0 1 -1];
>> desc = [2 2 2 2];
>> BellInequalityMax(M,desc,'cg','classical')

ans =

0

>> BellInequalityMax(M,desc,'cg','quantum')

ans =

0.2071

>> BellInequalityMax(M,desc,'cg','nosignal')

ans =

0.5000

### The CHSH game

The CHSH inequality can be reformulated as a nonlocal game, as is favoured in computer science. The rules of the game are as follows:

• A referee asks Alice a question $x \in \{0,1\}$ and Bob a question $y \in \{0,1\}$ with uniform probability.
• 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:

>> M = chshd(2);
>> desc = [2 2 2 2];
>> BellInequalityMax(M,desc,'fp','classical')

ans =

0.7500

>> BellInequalityMax(M,desc,'fp','quantum')

ans =

0.8536

>> BellInequalityMax(M,desc,'fp','nosignal')

ans =

1

The auxiliary function chshd() above produces the predicate of the CHSH-d game, an intensively studied variant of the CHSH game that generalizes it to a larger alphabet. The rules are analogous, with the difference that each of $a,b,x,y$ are taken from the set $\{0,1,\ldots,d-1\}$ and sum is done modulo $d$. The algorithm used to calculate the classical bound is parallelized and slightly smarter than naïve brute force. It can handle up to $d=8$ quickly:

>> M = chshd(8);
>> desc = [8 8 8 8];
>> BellInequalityMax(M,desc,'fp','classical')
Starting parallel pool (parpool) using the 'local' profile ... connected to 2 workers.

ans =

0.4688

### The I3322 inequality

The I3322 inequality is a Bell inequality where each of Alice and Bob has three possible inputs and 2 possible outputs. Its symmetric version in Collins-Gisin notation is given by: $-p(11|11) - p(11|12) - p(11|13) - p(11|21) - p(11|22) + p(11|23) - p(11|31) + p(11|32) + p_A(1|1) + p_B(1|1) \leq 1.$ Similarly, it is known that a value of (strictly) larger than $1+1/4$ is possible in quantum mechanics, and the best possible bound is $2$ in no-signalling theories. The following code computes the best possible classical and no-signalling bounds exactly, and computes several different upper bounds for the quantum mechanical setting:

>> format long
>> cvx_precision high
>> M = [0 1 0 0;1 -1 -1 -1;0 -1 -1 1;0 -1 1 0];
>> desc = [2 2 3 3];
>> BellInequalityMax(M,desc,'cg','classical')

ans =

1

>> BellInequalityMax(M,desc,'cg','quantum',1)

ans =

1.374999999999371

>> BellInequalityMax(M,desc,'cg','quantum','1+ab')

ans =

1.251470897748553

>> BellInequalityMax(M,desc,'cg','quantum',2)

ans =

1.250939721643942

>> BellInequalityMax(M,desc,'cg','quantum',3)

ans =

1.250875562046812

>> BellInequalityMax(M,desc,'cg','quantum',4)

ans =

1.250875384515790

>> BellInequalityMax(M,desc,'cg','nosignal')

ans =

2

We note that the values provided for the quantum upper bound above for K = '1+ab', K = 2, and K = 3 agree with the values found in  (subtracted 1 to account for the different form of the inequality). Furthermore, the value when K = 4 agrees with the value found in . The exact value of the best upper bound in the quantum setting is an open problem, but is known to be approximately $1.250875384514$.