Struct SmallBooleanFunction

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

Struct representing a boolean function with a big truth table.

The struct internally stores the truth table as an u64, meaning that the maximum number of variables is 6.

For more than 6 variables, use the crate::BigBooleanFunction struct, or the crate::BooleanFunction type to store both small and big boolean functions.

Implementations§

Source§

impl SmallBooleanFunction

Source

pub fn from_truth_table( truth_table: u64, variables_count: usize, ) -> Result<Self, BooleanFunctionError>

Creates a new SmallBooleanFunction from a truth table and the number of variables.

§Parameters
  • truth_table - The truth table of the Boolean function, where the lower bit represents the output of the Boolean function for the input 0.
  • variables_count - The number of variables of the Boolean function.
§Returns

A SmallBooleanFunction instance from the truth table and the number of variables or an error if:

  • The number of variables is greater than 6.
  • The truth table is too big for the number of variables, and the unsafe_disable_safety_checks feature is not enabled.
Source

pub fn get_truth_table_u64(&self) -> u64

Returns the truth table of the Boolean function, as an u64.

Source

pub fn derivative_inner( &self, direction: u32, ) -> Result<Self, BooleanFunctionError>

Computes the derivative of the Boolean function for a given direction.

§Parameters
  • direction - The direction of the derivative.
§Returns

The derivative of the Boolean function for the given direction, or an error if the direction is greater than the maximum input value and the unsafe_disable_safety_checks feature is not enabled.

Source

pub fn reverse_inner(&self) -> Self

Computes the reverse of the Boolean function.

§Returns

The reverse of the Boolean function.

Source

pub fn annihilator_inner( &self, max_degree: Option<usize>, ) -> Option<(SmallBooleanFunction, usize, usize)>

Computes the annihilator of the Boolean function for a given maximum degree.

§Parameters
  • max_degree - An optional maximum degree of the annihilator to search for. If set to None, the value is set to the variable count.
§Returns

A tuple containing the annihilator function, its degree and the dimension of the annihilator vector space, or None no annihilator was found.

Source

pub fn from_walsh_hadamard_values( walsh_values: &[i32], ) -> Result<Self, BooleanFunctionError>

Computes a SmallBooleanFunction from Walsh-Hadamard values, by applying the inverse Walsh-Hadamard transform.

§Parameters
  • walsh_values - The Walsh-Hadamard values of the Boolean function.
§Returns

The Boolean function created from the Walsh-Hadamard values list, or an error if:

  • the list length is less than 4
  • the list length is not a power of 2.
  • the number of variables is greater than 6 (meaning that the list length is greater than 64).
Source

pub fn from_walsh_fourier_values( walsh_values: &[i32], ) -> Result<Self, BooleanFunctionError>

Computes a SmallBooleanFunction from Walsh-Fourier values, by applying the inverse Walsh-Fourier transform.

§Parameters
  • walsh_values - The Walsh-Hadamard values of the Boolean function.
§Returns

The Boolean function created from the Walsh-Hadamard values list, or an error if:

  • the list length is less than 4
  • the list length is not a power of 2.
  • the number of variables is greater than 6 (meaning that the list length is greater than 64).
Source

pub fn get_1_local_neighbor_inner(&self, position: u32) -> Self

Returns a 1-local neighbor of the Boolean function, at a specific position

§Parameters
  • position: The position $i$ at which to compute the 1-local neighbor.
§Returns

The 1-local neighbor of the Boolean function at the given position.

§Panics

If the position is greater than the maximum input value, and the unsafe_disable_safety_checks feature is not enabled.

Source

pub fn close_balanced_functions_iterator_inner( &self, ) -> Result<SmallCloseBalancedFunctionIterator, BooleanFunctionError>

Returns an iterator over the closest possible balanced Boolean functions.

See BooleanFunctionImpl::close_balanced_functions_iterator for more details.

§Returns

An iterator over close balanced Boolean functions, or an error if the function is already balanced.

§Note

It is assumed that the function truth table is correctly sanitized, so be careful if you generated it with unsafe_disable_safety_checks feature activated.

Source

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

Computes SmallBooleanFunction from string ANF representation

The ANF string representation must be in exact 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 SmallBooleanFunction corresponding to the ANF string representation, or an error if:

  • the input string doesn’t respect the format and unsafe_disable_safety_checks feature is not activated.
  • the polynomial variable count is greater than 6
Source

pub fn from_anf_polynomial_inner( anf_polynomial: &AnfPolynomial, ) -> Result<Self, BooleanFunctionError>

Computes SmallBooleanFunction from ANF polynomial

§Parameters:
  • anf_polynomial: The polynomial in Algebraic Normal Form
§Returns

The SmallBooleanFunction corresponding to the ANF polynomial, or an error if polynomial variable count > 6

Trait Implementations§

Source§

impl Add for SmallBooleanFunction

ADD operator for Boolean functions truth tables.

It is equivalent to crate::SmallBooleanFunction::bitxor operator.

§Panics

If the Boolean functions have different number of variables, and the unsafe_disable_safety_checks feature is not enabled.

Source§

type Output = SmallBooleanFunction

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl AddAssign for SmallBooleanFunction

In-place ADD operator for Boolean functions truth tables.

It is equivalent to crate::SmallBooleanFunction::bitxor_assign operator.

§Panics

If the Boolean functions have different number of variables, and the unsafe_disable_safety_checks feature is not enabled.

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl BitAnd for SmallBooleanFunction

AND operator for Boolean functions truth tables.

§Panics

If the Boolean functions have different number of variables, and the unsafe_disable_safety_checks feature is not enabled.

Source§

type Output = SmallBooleanFunction

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: Self) -> Self::Output

Performs the & operation. Read more
Source§

impl BitAndAssign for SmallBooleanFunction

In-place AND operator for Boolean functions truth tables.

§Panics

If the Boolean functions have different number of variables, and the unsafe_disable_safety_checks feature is not enabled.

Source§

fn bitand_assign(&mut self, rhs: Self)

Performs the &= operation. Read more
Source§

impl BitXor for SmallBooleanFunction

XOR operator for Boolean functions truth tables.

§Panics

If the Boolean functions have different number of variables, and the unsafe_disable_safety_checks feature is not enabled.

Source§

type Output = SmallBooleanFunction

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: Self) -> Self::Output

Performs the ^ operation. Read more
Source§

impl BitXorAssign for SmallBooleanFunction

In-place XOR operator for Boolean functions truth tables.

§Panics

If the Boolean functions have different number of variables, and the unsafe_disable_safety_checks feature is not enabled.

Source§

fn bitxor_assign(&mut self, rhs: Self)

Performs the ^= operation. Read more
Source§

impl BooleanFunctionImpl for SmallBooleanFunction

Source§

fn variables_count(&self) -> usize

Variable count of the Boolean function.
Source§

fn get_boolean_function_type(&self) -> BooleanFunctionType

Internal type of the Boolean function abstraction: Read more
Source§

fn is_balanced(&self) -> bool

Returns true if the Boolean function is balanced, ie it has an equal number of 0 and 1 outputs.
Source§

fn compute_cellular_automata_rule(&self, input_bits: u32) -> bool

Computes the value of the Boolean function for a given input, as a 32-bit unsigned integer. Read more
Source§

fn derivative( &self, direction: u32, ) -> Result<BooleanFunction, BooleanFunctionError>

Computes the derivative of the Boolean function for a given direction. Read more
Source§

fn is_linear(&self) -> bool

Returns true if the Boolean function is linear, ie its algebraic degree is 0 or 1.
Source§

fn reverse(&self) -> BooleanFunction

Reverse the Boolean function, ie swap 0 and 1 outputs. Read more
Source§

fn algebraic_normal_form(&self) -> AnfPolynomial

Returns the Algebraic Normal Form of the Boolean function, in the form of an AnfPolynomial. Read more
Source§

fn annihilator( &self, max_degree: Option<usize>, ) -> Option<(BooleanFunction, usize, usize)>

Returns, if it exists, an annihilator function, its degree and the dimension of annihilator vector space. Read more
Source§

fn get_1_local_neighbor(&self, position: u32) -> BooleanFunction

Returns a 1-local neighbor of the Boolean function, at a specific position Read more
Source§

fn iter(&self) -> BooleanFunctionIterator

Returns an iterator over the values of the Boolean function. Read more
Source§

fn printable_hex_truth_table(&self) -> String

Returns the truth table of the Boolean function as a hexadecimal string. Read more
Source§

fn biguint_truth_table(&self) -> BigUint

Returns the truth table of the Boolean function as a BigUint. Read more
Source§

fn close_balanced_functions_iterator( &self, ) -> Result<CloseBalancedFunctionIterator, BooleanFunctionError>

Returns an iterator over the closest possible balanced Boolean functions. Read more
Source§

fn get_max_input_value(&self) -> u32

Maximum input value for the Boolean function, as unsigned 32-bit integer. Read more
Source§

fn walsh_hadamard_transform(&self, w: u32) -> i32

Computes the Walsh-Hadamard transform of the Boolean function for a given point. Read more
Source§

fn walsh_hadamard_values(&self) -> Vec<i32>

Computes the Walsh-Hadamard values for all points. Read more
Source§

fn absolute_walsh_hadamard_spectrum(&self) -> HashMap<u32, usize>

Computes the absolute Walsh-Hadamard spectrum of the Boolean function. Read more
Source§

fn walsh_fourier_transform(&self, w: u32) -> i32

Computes the Walsh-Fourier transform of the Boolean function for a given point. Read more
Source§

fn walsh_fourier_values(&self) -> Vec<i32>

Computes the Walsh-Fourier values for all points. Read more
Source§

fn auto_correlation_transform(&self, w: u32) -> i32

Computes the autocorrelation transform of the Boolean function for a given point. The autocorrelation transform of a Boolean function $f$, for a given point $\omega$, is defined as: Read more
Source§

fn absolute_autocorrelation(&self) -> HashMap<u32, usize>

Computes the absolute autocorrelation spectrum of the Boolean function. Read more
Source§

fn absolute_indicator(&self) -> u32

Returns the absolute indicator of the Boolean function. Read more
Source§

fn algebraic_degree(&self) -> usize

Returns the algebraic degree of the Boolean function. Read more
Source§

fn is_symmetric(&self) -> bool

Returns true if the Boolean function is symmetric. Read more
Source§

fn nonlinearity(&self) -> u32

Returns the nonlinearity of the Boolean function. Read more
Source§

fn is_bent(&self) -> bool

Returns true if the Boolean function is bent, meaning maximally nonlinear, or perfectly nonlinear. Read more
Source§

fn is_near_bent(&self) -> bool

Returns true if the Boolean function is near-bent. Read more
Source§

fn algebraic_immunity(&self) -> usize

Returns the algebraic immunity of the Boolean function. Read more
Source§

fn is_plateaued(&self) -> bool

Returns true if the Boolean function is plateaued. Read more
Source§

fn sum_of_square_indicator(&self) -> usize

Returns the sum of the square of the indicator of the Boolean function. Read more
Source§

fn has_linear_structure(&self) -> bool

Returns true if the Boolean function has a linear structure. Read more
Source§

fn is_linear_structure(&self, value: u32) -> bool

Checks if the parameter is a linear structure of the Boolean function. Read more
Source§

fn linear_structures(&self) -> Vec<u32>

List of all linear structures of the Boolean function. Read more
Source§

fn correlation_immunity(&self) -> usize

Returns the correlation immunity order of the Boolean function (calculated using Xiao Massey theorem). Read more
Source§

fn resiliency_order(&self) -> Option<usize>

Returns the resiliency order of the Boolean function. Read more
Source§

fn support(&self) -> HashSet<u32>

Returns the support of the Boolean function. Read more
Source§

fn propagation_criterion(&self) -> usize

Returns the maximum propagation criterion of the Boolean function. Read more
Source§

fn try_u64_truth_table(&self) -> Option<u64>

Returns the truth table of the Boolean function as an unsigned 64-bit integer, if it fits (meaning the Boolean function has 6 or less input variables). Read more
Source§

impl Clone for SmallBooleanFunction

Source§

fn clone(&self) -> SmallBooleanFunction

Returns a duplicate 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 SmallBooleanFunction

Source§

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

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

impl Deref for SmallBooleanFunction

Source§

type Target = dyn Fn(u32) -> bool

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl From<SmallBooleanFunction> for BooleanFunction

Source§

fn from(v: SmallBooleanFunction) -> BooleanFunction

Converts to this type from the input type.
Source§

impl Mul for SmallBooleanFunction

MUL operator for Boolean functions truth tables.

It is equivalent to crate::SmallBooleanFunction::bitand operator.

§Panics

If the Boolean functions have different number of variables, and the unsafe_disable_safety_checks feature is not enabled.

Source§

type Output = SmallBooleanFunction

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
Source§

impl MulAssign for SmallBooleanFunction

In-place MUL operator for Boolean functions truth tables.

It is equivalent to crate::SmallBooleanFunction::bitand_assign operator.

§Panics

If the Boolean functions have different number of variables, and the unsafe_disable_safety_checks feature is not enabled.

Source§

fn mul_assign(&mut self, rhs: Self)

Performs the *= operation. Read more
Source§

impl Not for SmallBooleanFunction

NOT operator for Boolean functions.

This is equivalent to the crate::BooleanFunctionImpl::reverse operation: it reverses each output of the Boolean function.

Source§

type Output = SmallBooleanFunction

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
Source§

impl PartialEq for SmallBooleanFunction

Source§

fn eq(&self, other: &SmallBooleanFunction) -> 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 TryInto<SmallBooleanFunction> for BooleanFunction

Source§

type Error = &'static str

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

fn try_into( self, ) -> Result<SmallBooleanFunction, <Self as TryInto<SmallBooleanFunction>>::Error>

Performs the conversion.
Source§

impl Copy for SmallBooleanFunction

Source§

impl Eq for SmallBooleanFunction

Source§

impl StructuralPartialEq for SmallBooleanFunction

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<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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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, 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.