Skip to main content

ProvenancePoly

Struct ProvenancePoly 

Source
pub struct ProvenancePoly { /* private fields */ }
Expand description

A provenance polynomial: a finite sum of monomials with natural-number coefficients.

Stored in normal form: monomials with zero coefficient are dropped; like terms are merged.

The empty polynomial is 0 (additive identity). The polynomial {Monomial::one() -> 1} is the multiplicative identity 1.

Custom serde: serialized as a sorted array of {"monomial": ..., "coefficient": n} entries, since JSON objects require string keys.

Implementations§

Source§

impl ProvenancePoly

Source

pub fn zero() -> Self

Additive identity: the polynomial 0.

Source

pub fn one() -> Self

Multiplicative identity: the polynomial 1.

Source

pub fn singleton(var: impl Into<String>) -> Self

Polynomial consisting of a single variable with coefficient 1.

Source

pub fn from_monomial(monomial: Monomial, coefficient: u64) -> Self

Polynomial consisting of a single monomial with the given coefficient. If the coefficient is 0, returns zero().

Source

pub fn terms(&self) -> impl Iterator<Item = (&Monomial, &u64)>

Iterate (monomial, coefficient) in monomial-sorted order.

Source

pub fn term_count(&self) -> usize

Number of distinct monomials with positive coefficient.

Source

pub fn is_zero(&self) -> bool

Whether this is the additive identity.

Source

pub fn coefficient(&self, monomial: &Monomial) -> u64

Coefficient of a specific monomial, or 0 if not present.

Source

pub fn support(&self) -> BTreeSet<String>

Support: the set of variables appearing in any monomial with positive coefficient.

This is what Theorem 2 bounds under retraction: for any retracted set Y, support(retract(p, Y)) is a subset of support(p).

Source

pub fn insert_term(&mut self, monomial: Monomial, coefficient: u64)

Add a single term in place, merging like monomials.

Source

pub fn retract<S: AsRef<str>>(&self, retracted: &BTreeSet<S>) -> Self

Retract every variable in retracted by the substitution x -> 0. This is the homomorphism rho_Y from docs/THEORY.md Section 6.

Operationally: any monomial containing a retracted variable is dropped. Monomials with no retracted variables are kept with their coefficients unchanged.

Trait Implementations§

Source§

impl Add<&ProvenancePoly> for &ProvenancePoly

Source§

type Output = ProvenancePoly

The resulting type after applying the + operator.
Source§

fn add(self, other: &ProvenancePoly) -> ProvenancePoly

Performs the + operation. Read more
Source§

impl Add for ProvenancePoly

Source§

type Output = ProvenancePoly

The resulting type after applying the + operator.
Source§

fn add(self, other: ProvenancePoly) -> ProvenancePoly

Performs the + operation. Read more
Source§

impl AddAssign<&ProvenancePoly> for ProvenancePoly

Source§

fn add_assign(&mut self, other: &ProvenancePoly)

Performs the += operation. Read more
Source§

impl Clone for ProvenancePoly

Source§

fn clone(&self) -> ProvenancePoly

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ProvenancePoly

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ProvenancePoly

Source§

fn default() -> ProvenancePoly

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for ProvenancePoly

Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for ProvenancePoly

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Mul<&ProvenancePoly> for &ProvenancePoly

Source§

type Output = ProvenancePoly

The resulting type after applying the * operator.
Source§

fn mul(self, other: &ProvenancePoly) -> ProvenancePoly

Performs the * operation. Read more
Source§

impl Mul for ProvenancePoly

Source§

type Output = ProvenancePoly

The resulting type after applying the * operator.
Source§

fn mul(self, other: ProvenancePoly) -> ProvenancePoly

Performs the * operation. Read more
Source§

impl MulAssign<&ProvenancePoly> for ProvenancePoly

Source§

fn mul_assign(&mut self, other: &ProvenancePoly)

Performs the *= operation. Read more
Source§

impl PartialEq for ProvenancePoly

Source§

fn eq(&self, other: &ProvenancePoly) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for ProvenancePoly

Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for ProvenancePoly

Source§

impl StructuralPartialEq for ProvenancePoly

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,