InflationProblem Class

class inflation.InflationProblem(dag=None, outcomes_per_party=(), settings_per_party=(), inflation_level_per_source=(), order=(), verbose=0)[source]

Class for encoding relevant details concerning the causal compatibility scenario.

Parameters
  • dag (Dict[str, List[str]], optional) – Dictionary where each key is a parent node, and the corresponding value is a list of the corresponding children nodes. By default it is a single source connecting all the parties.

  • outcomes_per_party (List[int]) – Measurement outcome cardinalities.

  • settings_per_party (List[int], optional) – Measurement setting cardinalities. By default 1 for all parties.

  • inflation_level_per_source ([int, List[int]], optional) – Number of copies per source in the inflated graph. Source order is the same as insertion order in dag. If an integer is provided, it is used as the inflation level for all sources. By default 1 for all sources.

  • order (List[str], optional) – Name of each party. This also fixes the order in which party outcomes and settings are to appear in a conditional probability distribution. Default is alphabetical order and labels, e.g., ['A', 'B', ...].

  • verbose (int, optional) –

    Optional parameter for level of verbose:

    • 0: quiet (default),

    • 1: monitor level: track program process and show warnings,

    • 2: debug level: show properties of objects created.

factorize_monomial(monomial: ndarray, canonical_order=False) Tuple[ndarray, ...][source]

Split a moment/expectation value into products of moments according to the support of the operators within the moment. The moment is encoded as a 2d array where each row is an operator. If monomial=A*B*C*B then row 1 is A, row 2 is B, row 3 is C, and row 4 is B. In each row, the columns encode the following information:

  • First column: The party index, starting from 1 (e.g., 1 for A, 2 for B, etc.)

  • Last two columns: The input x starting from zero, and then the output a starting from zero.

  • In between: This encodes the support of the operator. There are as many columns as sources/quantum states. Column j represents source j-1 (-1 because the first column represents the party). If the value is 0, then this operator does not measure this source. If the value is, e.g., 2, then this operator is acting on copy 2 of source j-1.

The output is a tuple of ndarrays where each array represents another monomial s.t. their product is equal to the original monomial.

Parameters
  • monomial (numpy.ndarray) – Monomial in 2d array form.

  • canonical_order (bool, optional) – Whether to return the different factors in a canonical order.

Returns

A tuple of ndarrays, where each array represents an atomic monomial factor.

Return type

Tuple[numpy.ndarray]

Examples

>>> monomial = np.array([[1, 0, 1, 1, 0, 0],
                         [2, 1, 0, 2, 0, 0],
                         [1, 0, 3, 3, 0, 0],
                         [3, 3, 5, 0, 0, 0],
                         [3, 1, 4, 0, 0, 0],
                         [3, 6, 6, 0, 0, 0],
                         [3, 4, 5, 0, 0, 0]])
>>> factorised = factorize_monomial(monomial)
[array([[1, 0, 1, 1, 0, 0]]),
 array([[1, 0, 3, 3, 0, 0]]),
 array([[2, 1, 0, 2, 0, 0],
        [3, 1, 4, 0, 0, 0]]),
 array([[3, 3, 5, 0, 0, 0],
        [3, 4, 5, 0, 0, 0]]),
 array([[3, 6, 6, 0, 0, 0]])]
rectify_fake_setting(monomial: ndarray) ndarray[source]

When constructing the monomials in a non-network scenario, we rely on an internal representation of operators where the integer denoting the setting actually is an ‘effective setting’ that encodes, in addition to the ‘private setting’ that each party is free to choose, the values of all the parents of the variable in question, which also effectively act as settings. This function resets this ‘effective setting’ integer to the true ‘private setting’ integer. It is useful to relate knowable monomials to their meaning as conditional events in non-network scenarios. If the scenario is a network, this function does nothing.

Parameters

monomial (numpy.ndarray) – An internal representation of a monomial as a 2d numpy array. Each row in the array corresponds to an operator. For each row, the zeroth element represents the party, the last element represents the outcome, the second-to-last element represents the setting, and the remaining elements represent inflation copies.

Returns

The monomial with the index of the setting representing only the private setting.

Return type

numpy.ndarray