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
impl ProvenancePoly
Sourcepub fn singleton(var: impl Into<String>) -> Self
pub fn singleton(var: impl Into<String>) -> Self
Polynomial consisting of a single variable with coefficient 1.
Sourcepub fn from_monomial(monomial: Monomial, coefficient: u64) -> Self
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().
Sourcepub fn terms(&self) -> impl Iterator<Item = (&Monomial, &u64)>
pub fn terms(&self) -> impl Iterator<Item = (&Monomial, &u64)>
Iterate (monomial, coefficient) in monomial-sorted order.
Sourcepub fn term_count(&self) -> usize
pub fn term_count(&self) -> usize
Number of distinct monomials with positive coefficient.
Sourcepub fn coefficient(&self, monomial: &Monomial) -> u64
pub fn coefficient(&self, monomial: &Monomial) -> u64
Coefficient of a specific monomial, or 0 if not present.
Sourcepub fn support(&self) -> BTreeSet<String>
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).
Sourcepub fn insert_term(&mut self, monomial: Monomial, coefficient: u64)
pub fn insert_term(&mut self, monomial: Monomial, coefficient: u64)
Add a single term in place, merging like monomials.
Sourcepub fn retract<S: AsRef<str>>(&self, retracted: &BTreeSet<S>) -> Self
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
impl Add<&ProvenancePoly> for &ProvenancePoly
Source§type Output = ProvenancePoly
type Output = ProvenancePoly
+ operator.Source§fn add(self, other: &ProvenancePoly) -> ProvenancePoly
fn add(self, other: &ProvenancePoly) -> ProvenancePoly
+ operation. Read moreSource§impl Add for ProvenancePoly
impl Add for ProvenancePoly
Source§type Output = ProvenancePoly
type Output = ProvenancePoly
+ operator.Source§fn add(self, other: ProvenancePoly) -> ProvenancePoly
fn add(self, other: ProvenancePoly) -> ProvenancePoly
+ operation. Read moreSource§impl AddAssign<&ProvenancePoly> for ProvenancePoly
impl AddAssign<&ProvenancePoly> for ProvenancePoly
Source§fn add_assign(&mut self, other: &ProvenancePoly)
fn add_assign(&mut self, other: &ProvenancePoly)
+= operation. Read moreSource§impl Clone for ProvenancePoly
impl Clone for ProvenancePoly
Source§fn clone(&self) -> ProvenancePoly
fn clone(&self) -> ProvenancePoly
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ProvenancePoly
impl Debug for ProvenancePoly
Source§impl Default for ProvenancePoly
impl Default for ProvenancePoly
Source§fn default() -> ProvenancePoly
fn default() -> ProvenancePoly
Source§impl<'de> Deserialize<'de> for ProvenancePoly
impl<'de> Deserialize<'de> for ProvenancePoly
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Source§impl Display for ProvenancePoly
impl Display for ProvenancePoly
Source§impl Mul<&ProvenancePoly> for &ProvenancePoly
impl Mul<&ProvenancePoly> for &ProvenancePoly
Source§type Output = ProvenancePoly
type Output = ProvenancePoly
* operator.Source§fn mul(self, other: &ProvenancePoly) -> ProvenancePoly
fn mul(self, other: &ProvenancePoly) -> ProvenancePoly
* operation. Read moreSource§impl Mul for ProvenancePoly
impl Mul for ProvenancePoly
Source§type Output = ProvenancePoly
type Output = ProvenancePoly
* operator.Source§fn mul(self, other: ProvenancePoly) -> ProvenancePoly
fn mul(self, other: ProvenancePoly) -> ProvenancePoly
* operation. Read moreSource§impl MulAssign<&ProvenancePoly> for ProvenancePoly
impl MulAssign<&ProvenancePoly> for ProvenancePoly
Source§fn mul_assign(&mut self, other: &ProvenancePoly)
fn mul_assign(&mut self, other: &ProvenancePoly)
*= operation. Read moreSource§impl PartialEq for ProvenancePoly
impl PartialEq for ProvenancePoly
Source§fn eq(&self, other: &ProvenancePoly) -> bool
fn eq(&self, other: &ProvenancePoly) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for ProvenancePoly
impl Serialize for ProvenancePoly
impl Eq for ProvenancePoly
impl StructuralPartialEq for ProvenancePoly
Auto Trait Implementations§
impl Freeze for ProvenancePoly
impl RefUnwindSafe for ProvenancePoly
impl Send for ProvenancePoly
impl Sync for ProvenancePoly
impl Unpin for ProvenancePoly
impl UnsafeUnpin for ProvenancePoly
impl UnwindSafe for ProvenancePoly
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.