Difference between revisions of "NPAHierarchy"

From QETLAB
Jump to navigation Jump to search
m (→‎Argument descriptions: K=0 doesn't exist anymore)
 
(2 intermediate revisions by 2 users not shown)
Line 5: Line 5:
 
|req=[http://cvxr.com/cvx/ CVX]
 
|req=[http://cvxr.com/cvx/ CVX]
 
|cat=[[List of functions#Nonlocality_and_Bell_inequalities|Nonlocality and Bell inequalities]]
 
|cat=[[List of functions#Nonlocality_and_Bell_inequalities|Nonlocality and Bell inequalities]]
|upd=December 9, 2014
+
|upd=November 11, 2022
 
|cvx=yes (concave)}}
 
|cvx=yes (concave)}}
 
<tt>'''NPAHierarchy'''</tt> is a [[List of functions|function]] that determines whether or not a given set of probabilities satisfy the constraints specified by the NPA hierarchy<ref name="npa">M. Navascués, S. Pironio, and A. Acín. Bounding the set of quantum correlations. ''Phys. Rev. Lett.'', 98:010401, 2007. E-print: [http://arxiv.org/abs/quant-ph/0607119/ arXiv:quant-ph/0607119]</ref><ref name="npa2">M. Navascués, S. Pironio, and A. Acín. A convergent hierarchy of semidefinite programs characterizing the set of quantum correlations. '' New J. Phys.'', 10:073013, 2008. E-print: [http://arxiv.org/abs/0803.4290 arXiv:0803.4290] [quant-ph]</ref>, which are a set of necessary conditions that probabilities arising from quantum mechanics must satisfy. That is, given a set of probabilities $\{p(a,b|x,y)\}$, this function tries to determine whether or not there is a quantum state $\rho$ shared between Alice and Bob, and sets of measurement operators $\{M_{a|x}\}$ for Alice and $\{M_{b|y}\}$ for Bob such that $p(a,b|x,y) = \mathrm{Tr}(\rho(M_{a|x} \otimes M_{b|y}))$ for all $a,b,x,y$ (here $x$ indexes the different measurement settings for Alice, while $a$ indexes the different measurement outcomes within that setting, and similarly for $y$ and $b$ for Bob).
 
<tt>'''NPAHierarchy'''</tt> is a [[List of functions|function]] that determines whether or not a given set of probabilities satisfy the constraints specified by the NPA hierarchy<ref name="npa">M. Navascués, S. Pironio, and A. Acín. Bounding the set of quantum correlations. ''Phys. Rev. Lett.'', 98:010401, 2007. E-print: [http://arxiv.org/abs/quant-ph/0607119/ arXiv:quant-ph/0607119]</ref><ref name="npa2">M. Navascués, S. Pironio, and A. Acín. A convergent hierarchy of semidefinite programs characterizing the set of quantum correlations. '' New J. Phys.'', 10:073013, 2008. E-print: [http://arxiv.org/abs/0803.4290 arXiv:0803.4290] [quant-ph]</ref>, which are a set of necessary conditions that probabilities arising from quantum mechanics must satisfy. That is, given a set of probabilities $\{p(a,b|x,y)\}$, this function tries to determine whether or not there is a quantum state $\rho$ shared between Alice and Bob, and sets of measurement operators $\{M_{a|x}\}$ for Alice and $\{M_{b|y}\}$ for Bob such that $p(a,b|x,y) = \mathrm{Tr}(\rho(M_{a|x} \otimes M_{b|y}))$ for all $a,b,x,y$ (here $x$ indexes the different measurement settings for Alice, while $a$ indexes the different measurement outcomes within that setting, and similarly for $y$ and $b$ for Bob).
  
 
==Syntax==
 
==Syntax==
* <tt>IS_NPA = NPAHierarchy(P)</tt>
+
* <tt>IS_NPA = NPAHierarchy(P,desc)</tt>
* <tt>IS_NPA = NPAHierarchy(P,K)</tt>
+
* <tt>IS_NPA = NPAHierarchy(P,desc,K)</tt>
  
 
==Argument descriptions==
 
==Argument descriptions==
* <tt>P</tt>: A 4D array such that <tt>P(a,b,x,y)</tt> is the probability that Alice and Bob obtain measurement result <tt>(a,b)</tt> when they use measurement setting <tt>(x,y)</tt> (i.e., this is equal to $p(a,b|x,y)$ from above).
+
* <tt>P</tt>: A behaviour in Collins-Gisin notation. That is, a matrix with components
* <tt>K</tt> (optional, default 1): A non-negative integer that determines the level of the NPA hierarchy to use. If <tt>K = 0</tt> then the NPA hierarchy isn't use at all, and this function just checks whether or not <tt>P</tt> is a valid probability array that satisfies non-signally constraints (i.e., all entries are non-negative, each matrix face sums to 1, and the marginal probabilities for Alice and Bob are consistent with each other).
+
:<math>
 +
\begin{pmatrix}
 +
1 & p_B(0|0) & p_B(1|0) & \ldots & p_B(0|1) & p_B(1|1) & \ldots \\
 +
p_A(0|0) & p(00|00) & p(01|00) & \ldots & p(00|01) & p(01|01) &\ldots \\
 +
p_A(1|0) & p(10|00) & p(11|00) & \ldots & p(10|01) & p(11|01) &\ldots \\
 +
\vdots & \vdots & \vdots & \vdots & \vdots & \vdots &\vdots \\
 +
p_A(0|1) & p(00|10) & p(01|10) & \ldots & p(00|11) & p(01|11) &\ldots \\
 +
p_A(1|1) & p(10|10) & p(11|10) & \ldots & p(10|11) & p(11|11) &\ldots \\
 +
\vdots & \vdots & \vdots & \vdots & \vdots & \vdots &\ddots \\
 +
\end{pmatrix}
 +
</math>
 +
* <tt>DESC</tt>: 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.
 +
* <tt>K</tt> (optional, default 1): A positive integer that determines the level of the NPA hierarchy to use. Alternatively, <tt>K</tt> 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.
  
 
==Examples==
 
==Examples==
 
===Can be used within CVX===
 
===Can be used within CVX===
Within CVX, this function is treated as any other concave function (so you can use it as an equality or <tt>>=</tt> constraint, or maximize it subject to other constraints). Maximizing it has the interpretation of trying to find a set of probabilities that satisfy the constraints of the NPA hierarchy, as well as whatever other constraints you specify. For example, the following code finds a $2$-measurement, $2$-outcome probability array satisfying the constraints of the second level of the hierarchy and also has $p(1,1|1,1) = p(1,2|1,1) + 0.1$ and $p(1,2|1,2) = p(2,2|1,2) - 0.2$ (these last two constraints have no special significance; they are just there for illustrative purposes):
+
Within CVX, this function is treated as any other concave function (so you can use it as an equality or <tt>>=</tt> constraint, or maximize it subject to other constraints). It is used inside the function [[BellInequalityMax]] to upperbound the Tsirelson bound. One can use it to maximize a Bell inequality subject to further constraints, or to determine whether a behaviour belongs to the quantum set of correlations.
 +
 
 +
For example, one might wonder what is the maximal violation of the CHSH inequality if Alice and Bob obtain equal outcomes with probability 1 in one of the settings. Translating into Collins-Gisin notation, this is the condition that <math>2p(00|xy) = p_A(0|x) + p_B(0|y)</math> for some x,y.:
 +
 
 
<syntaxhighlight>
 
<syntaxhighlight>
 
+
>> B = [0, -1, 0; -1, 1, 1; 0, 1, -1]; %CHSH functional in Collins-Gisin form
>> cvx_begin sdp quiet
+
  desc = [2 2 2 2];
   variable p(2,2,2,2); % 2 measurements, 2 outcomes each
+
  cvx_begin
   maximize NPAHierarchy(p,2) % second level of the hierarchy
+
   variable p(3,3);
 +
   objective = B(:)'*p(:);
 +
  maximize objective
 
   subject to
 
   subject to
      % these constraints do not have any particular significance
+
p(1,1) == 1; %the top left element of the behaviour must always be equal to 1
      p(1,1,1,1) == p(1,2,1,1) + 0.1;
+
NPAHierarchy(p,desc,2) == 1; %here we impose level 2 of the NPA hierarchy
      p(1,2,1,2) == p(2,2,1,2) - 0.2;
+
2*p(2,2) == p(1,2) + p(2,1); %this is the constraint that Alice and Bob have equal outcomes
 
   cvx_end
 
   cvx_end
  cvx_optval
 
  
cvx_optval =
+
Optimal value (cvx_optval): +0.125009
 +
</syntaxhighlight>
  
    1 % a value of 1 indicates that a probability array satisfying the constraints exists
+
One can see that the SDP solver runs into numerical problems and delivers a solution that is not so close to the analytical one, 1/8. This is not a problem with the code, but a fundamental problem with semidefinite programming: this problem is not strictly feasible, and the interior-point algorithms relies on strict feasibility to obtain a reliable solution. In order to obtain a reliable solution numerically one needs to reformulate the problem to make it strictly feasible, for example using facial reduction<ref>Dmitriy Drusvyatskiy, Henry Wolkowicz. The many faces of degeneracy in conic optimization. E-print: [http://arxiv.org/abs/1706.03705 arXiv:1706.03705]</ref>.
  
>> p % let's have a look at it
+
In order to test whether a given behaviour belongs to the quantum set, one must also be careful to formulate the problem in a strictly feasible way. One way to do that is ask how much of the uniformly random behaviour must be mixed with P in order to make it fall into the quantum set. If the answer is zero, it means that the behaviour was already quantum. The following code shows that the PR-box is not in the quantum set:
  
p(:,:,1,1) =
+
<syntaxhighlight>
 
+
>> prbox = [2, 1, 1;1, 1, 1;1,1,0]/2; %PR box
    0.2637   0.1637
+
  p_random = [4, 2, 2;2, 1, 1;2, 1, 1]/4; %uniformly random behaviour
    0.2698   0.3029
+
  desc = [2 2 2 2];
 +
  cvx_begin
 +
  variable lambda;
 +
  minimize lambda;
 +
   subject to
 +
NPAHierarchy(lambda*p_random + (1-lambda)*prbox,desc,2) == 1;
 +
   cvx_end
  
 
+
Optimal value (cvx_optval): +0.292893
p(:,:,2,1) =
 
 
 
    0.2667    0.2333
 
    0.2667    0.2333
 
 
 
 
 
p(:,:,1,2) =
 
 
 
    0.2692    0.1582
 
    0.2145    0.3582
 
 
 
 
 
p(:,:,2,2) =
 
 
 
    0.2418    0.2582
 
    0.2418    0.2582
 
 
</syntaxhighlight>
 
</syntaxhighlight>
 
 
{{SourceCode|name=NPAHierarchy}}
 
{{SourceCode|name=NPAHierarchy}}
  
 
==References==
 
==References==
 
<references />
 
<references />

Latest revision as of 12:39, 11 November 2022

NPAHierarchy
Determines whether or not a set of probabilities satisfy the conditions of the NPA hierarchy

Other toolboxes required CVX
Related functions BellInequalityMax
XORGameValue
Function category Nonlocality and Bell inequalities
Usable within CVX? yes (concave)

NPAHierarchy is a function that determines whether or not a given set of probabilities satisfy the constraints specified by the NPA hierarchy[1][2], which are a set of necessary conditions that probabilities arising from quantum mechanics must satisfy. That is, given a set of probabilities $\{p(a,b|x,y)\}$, this function tries to determine whether or not there is a quantum state $\rho$ shared between Alice and Bob, and sets of measurement operators $\{M_{a|x}\}$ for Alice and $\{M_{b|y}\}$ for Bob such that $p(a,b|x,y) = \mathrm{Tr}(\rho(M_{a|x} \otimes M_{b|y}))$ for all $a,b,x,y$ (here $x$ indexes the different measurement settings for Alice, while $a$ indexes the different measurement outcomes within that setting, and similarly for $y$ and $b$ for Bob).

Syntax

  • IS_NPA = NPAHierarchy(P,desc)
  • IS_NPA = NPAHierarchy(P,desc,K)

Argument descriptions

  • P: A behaviour in Collins-Gisin notation. That is, a matrix with components

\[ \begin{pmatrix} 1 & p_B(0|0) & p_B(1|0) & \ldots & p_B(0|1) & p_B(1|1) & \ldots \\ p_A(0|0) & p(00|00) & p(01|00) & \ldots & p(00|01) & p(01|01) &\ldots \\ p_A(1|0) & p(10|00) & p(11|00) & \ldots & p(10|01) & p(11|01) &\ldots \\ \vdots & \vdots & \vdots & \vdots & \vdots & \vdots &\vdots \\ p_A(0|1) & p(00|10) & p(01|10) & \ldots & p(00|11) & p(01|11) &\ldots \\ p_A(1|1) & p(10|10) & p(11|10) & \ldots & p(10|11) & p(11|11) &\ldots \\ \vdots & \vdots & \vdots & \vdots & \vdots & \vdots &\ddots \\ \end{pmatrix} \]

  • 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.
  • K (optional, default 1): A positive integer that determines the level of the NPA hierarchy to use. 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.

Examples

Can be used within CVX

Within CVX, this function is treated as any other concave function (so you can use it as an equality or >= constraint, or maximize it subject to other constraints). It is used inside the function BellInequalityMax to upperbound the Tsirelson bound. One can use it to maximize a Bell inequality subject to further constraints, or to determine whether a behaviour belongs to the quantum set of correlations.

For example, one might wonder what is the maximal violation of the CHSH inequality if Alice and Bob obtain equal outcomes with probability 1 in one of the settings. Translating into Collins-Gisin notation, this is the condition that \(2p(00|xy) = p_A(0|x) + p_B(0|y)\) for some x,y.:

>> B = [0, -1, 0; -1, 1, 1; 0, 1, -1]; %CHSH functional in Collins-Gisin form
   desc = [2 2 2 2];
   cvx_begin
   variable p(3,3);
   objective = B(:)'*p(:);
   maximize objective
   subject to
	p(1,1) == 1; %the top left element of the behaviour must always be equal to 1
	NPAHierarchy(p,desc,2) == 1; %here we impose level 2 of the NPA hierarchy
	2*p(2,2) == p(1,2) + p(2,1); %this is the constraint that Alice and Bob have equal outcomes
   cvx_end

Optimal value (cvx_optval): +0.125009

One can see that the SDP solver runs into numerical problems and delivers a solution that is not so close to the analytical one, 1/8. This is not a problem with the code, but a fundamental problem with semidefinite programming: this problem is not strictly feasible, and the interior-point algorithms relies on strict feasibility to obtain a reliable solution. In order to obtain a reliable solution numerically one needs to reformulate the problem to make it strictly feasible, for example using facial reduction[3].

In order to test whether a given behaviour belongs to the quantum set, one must also be careful to formulate the problem in a strictly feasible way. One way to do that is ask how much of the uniformly random behaviour must be mixed with P in order to make it fall into the quantum set. If the answer is zero, it means that the behaviour was already quantum. The following code shows that the PR-box is not in the quantum set:

>> prbox = [2, 1, 1;1, 1, 1;1,1,0]/2; %PR box
   p_random = [4, 2, 2;2, 1, 1;2, 1, 1]/4; %uniformly random behaviour
   desc = [2 2 2 2];
   cvx_begin
   variable lambda;
   minimize lambda;
   subject to
	NPAHierarchy(lambda*p_random + (1-lambda)*prbox,desc,2) == 1;
   cvx_end

Optimal value (cvx_optval): +0.292893

Source code

Click here to view this function's source code on github.

References

  1. M. Navascués, S. Pironio, and A. Acín. Bounding the set of quantum correlations. Phys. Rev. Lett., 98:010401, 2007. E-print: arXiv:quant-ph/0607119
  2. M. Navascués, S. Pironio, and A. Acín. A convergent hierarchy of semidefinite programs characterizing the set of quantum correlations. New J. Phys., 10:073013, 2008. E-print: arXiv:0803.4290 [quant-ph]
  3. Dmitriy Drusvyatskiy, Henry Wolkowicz. The many faces of degeneracy in conic optimization. E-print: arXiv:1706.03705