boolean_function

Struct AnfPolynomial

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

Polynomial representation of Boolean function in Algebraic Normal Form (ANF).

The ANF representation is a XOR sum of monomials, where each monomial is a AND product of variables.

Implementations§

Source§

impl AnfPolynomial

Source

pub fn get_polynomial_small(&self) -> Option<u64>

Get the polynomial in ANF representation in unsigned 64-bit integer format. The unsigned representation of ANF is explained in README.md.

Returns None if the polynomial is too big to fit in a 64-bit integer (ie more than 6 variables).

Source

pub fn get_polynomial_big(&self) -> BigUint

Get the polynomial in ANF representation in big unsigned integer format. The unsigned representation of ANF is explained in README.md.

Source

pub fn get_degree(&self) -> usize

Get the degree of the polynomial.

The degree of the polynomial is the maximum number of variables in a monomial.

Source

pub fn to_string(&self) -> String

Returns the string representation of the polynomial.

The monomials are ordered by the number of variables in the monomial in descending order, and then by the lexicographic order of the variables.

Example: “x0*x1 + x0 + x1 + x2”, the ‘+’ operator is the XOR operator, and the ‘*’ operator is the AND operator.

Source

pub fn from_str( anf_polynomial: &str, num_variables: usize, ) -> Result<Self, BooleanFunctionError>

Computes the ANF polynomial from string representation

Representation must be in the form “x0*x2*x3 + x2*x3 + x1 + 1”.

X’s index starts at 0, meaning the maximum index is variable count - 1.

§Parameters:
  • anf_polynomial: The string representation of the ANF form
  • num_variables: Variable count of the polynomial
§Returns:

The ANF polynomial, or an error if the input string doesn’t respect the format and unsafe_disable_safety_checks feature is not activated.

Source

pub fn get_boolean_function_type(&self) -> BooleanFunctionType

Returns Boolean function internal storage type:

  • Small for u64 internal storage (less or equal than 6 variables Boolean function)
  • Big for BigUInt internal storage (more than 6 variables Boolean function)
Source

pub fn to_boolean_function(&self) -> BooleanFunction

Convert ANF polynomial to the corresponding Boolean Function, using fast ANF transform algorithm

§Returns

A Boolean function corresponding to the polynomial

Trait Implementations§

Source§

impl Clone for AnfPolynomial

Source§

fn clone(&self) -> AnfPolynomial

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for AnfPolynomial

Source§

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

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

impl Display for AnfPolynomial

Display implementation for AnfPolynomial.

Internally uses the AnfPolynomial::to_string method.

Source§

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

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

impl PartialEq for AnfPolynomial

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 Eq for AnfPolynomial

Source§

impl StructuralPartialEq for AnfPolynomial

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, dst: *mut T)

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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§

default 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.