NPAHierarchy

NPAHierarchy is a function that determines whether or not a given set of probabilities satisfy the constraints specified by the NPA hierarchy, 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)
 * IS_NPA = NPAHierarchy(P,K)

Argument descriptions

 * P: A 4D array such that P(a,b,x,y) is the probability that Alice and Bob obtain measurement result (a,b) when they use measurement setting (x,y) (i.e., this is equal to $p(a,b|x,y)$ from above).
 * K (optional, default 1): A non-negative integer that determines the level of the NPA hierarchy to use. If K = 0</tt> then the NPA hierarchy isn't use at all, and this function just checks whether or not P</tt> is a valid probability array that satisfies non-signalling 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). Alternatively, 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.

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> 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):