Functions to build problem elements

inflation.sdp.quantum_tools.calculate_momentmatrix_1d_internal(cols: List, notcomm: ndarray, orthomat: ndarray, commuting: bool = False, verbose: int = 0) Tuple[ndarray, Dict][source]

Calculate the moment matrix. The function takes as input the generating set \(\{M_i\}_i\) encoded as a list of monomials. Each monomial is a matrix where each row is an operator and the columns specify the operator labels/indices. The moment matrix is the inner product between all possible pairs of elements from the generating set. The program outputs the moment matrix as a 2d array. Entry \((i,j)\) of the moment matrix stores the index of the monomial that represents the result of the expectation value \(\text{Tr}(\rho\cdot M_i^\dagger M_j)\) for an unknown quantum state \(\rho\) after applying the substitutions. The program returns the moment matrix and the dictionary mapping each monomial in string representation to its integer representation.

Parameters:
  • cols (List) – List of numpy.ndarray representing the generating set in 1d internal format.

  • notcomm (numpy.ndarray) – Matrix of commutation relations, given in the format specified by inflation.quantum.fast_npa.commutation_matrix.

  • orthomat (numpy.ndarray) – Matrix of orthogonality relations. Each operator can be identified by an integer i which also doubles as its lexicographic rank. Given two operators with ranks i, j, notcomm[i, j] is 1 if the operators are orthogonal, and 0 if they do.

  • commuting (bool, optional) – Whether the variables in the problem commute or not. By default False.

  • verbose (int, optional) – How much information to print. By default 0.

Returns:

The moment matrix \(\Gamma\), where each entry \((i,j)\) stores the integer representation of a monomial. The Dict is a mapping from string representation to integer representation.

Return type:

Tuple[numpy.ndarray, Dict]

inflation.sdp.quantum_tools.construct_normalization_eqs(column_equalities: List[Tuple[int, List[int]]], momentmatrix: ndarray, verbose=0) List[Tuple[int, List[int]]][source]

Given a list of column level normalization equalities and the moment matrix, this function computes the implicit normalization equalities between matrix elements. Column-level and monomial-level equalities share nearly the same format, they differ merely in whether integers pertain to column indices or the indices that represent the unique moment matrix elements.

Parameters:
  • column_equalities (List[Tuple[int, List[int]]]) – The list of equalities between columns in the moment matrix, in the form of tuples whose first element is the index of one of the columns, and the second element is the list of indices of the columns whose corresponding operators sum up to the operator corresponding to the first element.

  • momentmatrix (numpy.ndarray) – The moment matrix of which the identification between variables shall be computed.

  • verbose (int, optional) – Verbosity level. By default 0.

Returns:

The equalities between variables. For each tuple, the first element is the index of one of the variables in momentmatrix, and the second is the list of variables whose sum corresponds to the first.

Return type:

List[Tuple[int, List[int]]]

inflation.sdp.quantum_tools.generate_operators(outs_per_input: List[int], name: str) List[List[List[Symbol]]][source]

Generates the list of sympy.core.symbol.Symbol variables representing the measurements for a given party. The variables are treated as non-commuting. This code is adapted from ncpol2sdpa.

Parameters:
  • outs_per_input (List[int]) – The number of outcomes of each measurement for a given party

  • name (str) – The name to be associated to the party

Returns:

The list of Sympy operators

Return type:

list

Auxiliary functions

inflation.sdp.quantum_tools.apply_inflation_symmetries(momentmatrix: ndarray, inflation_symmetries: ndarray, verbose: bool = False) Tuple[ndarray, Dict[int, int], ndarray][source]

Applies the inflation symmetries, in the form of permutations of the rows and colums of a moment matrix, to the moment matrix.

Parameters:
  • momentmatrix (numpy.ndarray) – The moment matrix.

  • inflation_symmetries (numpy.ndarray) – Two-dimensional array where each row represents a permutation of the rows and columns of the moment matrix.

  • verbose (bool) – Whether information about progress is printed out.

Returns:

  • sym_mm (numpy.ndarray) – The symmetrized version of the moment matrix, where each cell is the lowest index of all the Monomials that are equivalent to that in the corresponding cell in momentmatrix.

  • orbits (Dict[int, int]) – The map from unsymmetrized indices in momentmatrix to their symmetrized counterparts in sym_mm.

  • repr_values (numpy.ndarray) – An array of unique representative former (unsymmetrized) indices. This is later used for hashing indices and making sanitization much faster.

inflation.sdp.quantum_tools.format_permutations(array: ndarray | List[List[int]] | List[Tuple[int, ...]] | Tuple[Tuple[int, ...], ...] | Tuple[List[int], ...]) ndarray[source]

Permutations of inflation indices must leave the integers 0, corresponding to sources not being measured by the operator, invariant. In order to achieve this, this function shifts a permutation of sources by 1 and prepends it with the integer 0.

Parameters:

array (numpy.ndarray) – 2-d array where each row is a permutations.

Returns:

The processed list of permutations.

Return type:

numpy.ndarray