Monomial classes and functions

InflationLP monomial classes

class inflation.lp.monomial_classes.InternalAtomicMonomial(inflation_lp_instance, as_1d_vec: ndarray)[source]
property _raw_name

A string representing the monomial. In case of knowable monomials, it is of the form p(outputs|inputs). Otherwise it represents the expectation value of the monomial with bracket notation.

compute_marginal(prob_array: ndarray) float[source]

Given a probability distribution, compute the numerical value of the Monomial.

Parameters:

prob_array (numpy.ndarray) – The target probability distribution. The dimensions of this array are (outcomes_per_party, settings_per_party), where the settings are explicitly 1 is there is only one measurement performed.

Returns:

The value of the corresponding probability (which can be a marginal involving only a few parties)

Return type:

float

class inflation.lp.monomial_classes.CompoundMoment(monomials: Tuple[InternalAtomicMonomial])[source]
attach_idx(idx: int)[source]

Assign an index to the Monomial. This is used when generating the monomials in a scenario, and identifying them with integers.

compute_marginal(prob_array: ndarray) float[source]

Given a probability array, evaluate all the knowable atomic moment factors in the monomial and return the product of the resulting values.

The whole moment needs to be knowable (self.is_knowable = True), else this method will raise an error.

Parameters:

prob_array (np.ndarray) – A conditional probability distribution over the non-inflated scenario with dimensions (da,db,...,dx,dy,...) (i.e., first outcomes and then settings for the parties).

See also

CompoundMonomial.evaluate

This function does not rely on the knowability of the monomial.

evaluate(known_monomials: Dict[InternalAtomicMonomial, float], use_lpi_constraints=True) Tuple[float, List, str][source]

Given a dictionary of values for known atomic monomials, substitute all factors of the compound moment that are specified in the dictionary with their values and return the product of the values and a remainder compound moment made of the remaining factors.

Parameters:
  • known_monomials (Dict[InternalAtomicMonomial, float]) – A dictionary of known atomic monomials and their values.

  • use_lpi_constraints (bool, optional) – Whether compound moments whose factors are partially present in known_monomials are labelled as "Semi" or "Unknowable". If True, they are labelled as "Semi". By default True.

Returns:

A tuple where the first element is the value of the knowable parts of the compound moment, the second element is a compound monomial of all the remaining factors not present in known_monomials and the third element is a string describing whether all factors are present in known_monomials ("Known"), some are ("Semi"), or none are ("Unknown").

Return type:

Tuple[float, List, str]

InflationSDP monomial classes

class inflation.sdp.monomial_classes.InternalAtomicMonomialSDP(inflation_sdp_instance, lexmon: ndarray)[source]
property dagger

Returns the adjoint of the Monomial.

property is_hermitian: bool

Whether the atomic monomial is equivalent to its conjugate under inflation symmetries and commutation.

class inflation.sdp.monomial_classes.CompoundMomentSDP(monomials: Tuple[InternalAtomicMonomialSDP])[source]
property is_all_commuting

If all factors of the compount moment contain operators that all commute.

property is_hermitian

If all factors of the compount moment contain monomials that are hermitian.

property is_physical

If all factors of the compount moment contain monomials that are physical, i.e., products of positive operators that are positive.