pub struct BigBooleanFunction { /* private fields */ }Expand description
Struct representing a boolean function with a big truth table.
As the crate::SmallBooleanFunction struct internally uses a u64 to store the truth table, this struct allows to store Boolean functions with more than 6 variables.
For a variable count less or equal to 6, the crate::SmallBooleanFunction struct is more efficient. You could use the crate::BooleanFunction to store both types of Boolean functions.
Implementations§
Source§impl BigBooleanFunction
impl BigBooleanFunction
Sourcepub fn from_truth_table(truth_table: BigUint, variables_count: usize) -> Self
pub fn from_truth_table(truth_table: BigUint, variables_count: usize) -> Self
Creates a new BigBooleanFunction 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 BigBooleanFunction instance from the truth table and the number of variables.
§Panics
Panics if the truth table is too big for the number of variables or if the number of variables is greater than 31, and the unsafe_disable_safety_checks feature is not enabled.
Sourcepub fn derivative_inner(
&self,
direction: u32,
) -> Result<Self, BooleanFunctionError>
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.
Sourcepub fn reverse_inner(&self) -> Self
pub fn reverse_inner(&self) -> Self
Sourcepub fn annihilator_inner(
&self,
max_degree: usize,
) -> Option<(BigBooleanFunction, usize, usize)>
pub fn annihilator_inner( &self, max_degree: usize, ) -> Option<(BigBooleanFunction, usize, usize)>
Computes the annihilator of the Boolean function for a given maximum degree.
§Parameters
max_degree- The maximum degree of the wished annihilator.
§Returns
A tuple containing the annihilator function, its degree and the dimension of the annihilator vector space, or None no annihilator was found.
Sourcepub fn from_walsh_hadamard_values(
walsh_values: &[i32],
) -> Result<Self, BooleanFunctionError>
pub fn from_walsh_hadamard_values( walsh_values: &[i32], ) -> Result<Self, BooleanFunctionError>
Computes a BigBooleanFunction 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, or not a power of 2.
Sourcepub fn from_walsh_fourier_values(
walsh_values: &[i32],
) -> Result<Self, BooleanFunctionError>
pub fn from_walsh_fourier_values( walsh_values: &[i32], ) -> Result<Self, BooleanFunctionError>
Computes a BigBooleanFunction from Walsh-Fourier values, by applying the inverse Walsh-Fourier transform.
§Parameters
walsh_values- The Walsh-Fourier values of the Boolean function.
§Returns
The Boolean function created from the Walsh-Fourier values list, or an error if the list length is less than 4, or not a power of 2.
Sourcepub fn get_1_local_neighbor_inner(&self, position: u32) -> Self
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.
Sourcepub fn close_balanced_functions_iterator_inner(
&self,
) -> Result<BigCloseBalancedFunctionIterator, BooleanFunctionError>
pub fn close_balanced_functions_iterator_inner( &self, ) -> Result<BigCloseBalancedFunctionIterator, 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.
Sourcepub fn from_anf_polynomial_str_inner(
anf_polynomial: &str,
num_variables: usize,
) -> Result<Self, BooleanFunctionError>
pub fn from_anf_polynomial_str_inner( anf_polynomial: &str, num_variables: usize, ) -> Result<Self, BooleanFunctionError>
Computes BigBooleanFunction 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 formnum_variables: Variable count of the polynomial
§Returns
The BigBooleanFunction 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.
Sourcepub fn from_anf_polynomial_inner(anf_polynomial: &AnfPolynomial) -> Self
pub fn from_anf_polynomial_inner(anf_polynomial: &AnfPolynomial) -> Self
Trait Implementations§
Source§impl BitXor for BigBooleanFunction
impl BitXor for BigBooleanFunction
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§impl BitXorAssign for BigBooleanFunction
impl BitXorAssign for BigBooleanFunction
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)
fn bitxor_assign(&mut self, rhs: Self)
^= operation. Read moreSource§impl BooleanFunctionImpl for BigBooleanFunction
impl BooleanFunctionImpl for BigBooleanFunction
Source§fn variables_count(&self) -> usize
fn variables_count(&self) -> usize
Source§fn get_boolean_function_type(&self) -> BooleanFunctionType
fn get_boolean_function_type(&self) -> BooleanFunctionType
Source§fn is_balanced(&self) -> bool
fn is_balanced(&self) -> bool
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
fn compute_cellular_automata_rule(&self, input_bits: u32) -> bool
Source§fn derivative(
&self,
direction: u32,
) -> Result<BooleanFunction, BooleanFunctionError>
fn derivative( &self, direction: u32, ) -> Result<BooleanFunction, BooleanFunctionError>
Source§fn is_linear(&self) -> bool
fn is_linear(&self) -> bool
true if the Boolean function is linear, ie its algebraic degree is 0 or 1.Source§fn reverse(&self) -> BooleanFunction
fn reverse(&self) -> BooleanFunction
Source§fn algebraic_normal_form(&self) -> AnfPolynomial
fn algebraic_normal_form(&self) -> AnfPolynomial
Source§fn annihilator(
&self,
max_degree: usize,
) -> Option<(BooleanFunction, usize, usize)>
fn annihilator( &self, max_degree: usize, ) -> Option<(BooleanFunction, usize, usize)>
Source§fn get_1_local_neighbor(&self, position: u32) -> BooleanFunction
fn get_1_local_neighbor(&self, position: u32) -> BooleanFunction
Source§fn iter(&self) -> BooleanFunctionIterator ⓘ
fn iter(&self) -> BooleanFunctionIterator ⓘ
Source§fn printable_hex_truth_table(&self) -> String
fn printable_hex_truth_table(&self) -> String
Source§fn biguint_truth_table(&self) -> BigUint
fn biguint_truth_table(&self) -> BigUint
Source§fn close_balanced_functions_iterator(
&self,
) -> Result<CloseBalancedFunctionIterator, BooleanFunctionError>
fn close_balanced_functions_iterator( &self, ) -> Result<CloseBalancedFunctionIterator, BooleanFunctionError>
Source§fn get_max_input_value(&self) -> u32
fn get_max_input_value(&self) -> u32
Source§fn walsh_hadamard_transform(&self, w: u32) -> i32
fn walsh_hadamard_transform(&self, w: u32) -> i32
Source§fn walsh_hadamard_values(&self) -> Vec<i32>
fn walsh_hadamard_values(&self) -> Vec<i32>
Source§fn absolute_walsh_hadamard_spectrum(&self) -> HashMap<u32, usize>
fn absolute_walsh_hadamard_spectrum(&self) -> HashMap<u32, usize>
Source§fn walsh_fourier_transform(&self, w: u32) -> i32
fn walsh_fourier_transform(&self, w: u32) -> i32
Source§fn walsh_fourier_values(&self) -> Vec<i32>
fn walsh_fourier_values(&self) -> Vec<i32>
Source§fn auto_correlation_transform(&self, w: u32) -> i32
fn auto_correlation_transform(&self, w: u32) -> i32
Source§fn absolute_autocorrelation(&self) -> HashMap<u32, usize>
fn absolute_autocorrelation(&self) -> HashMap<u32, usize>
Source§fn absolute_indicator(&self) -> u32
fn absolute_indicator(&self) -> u32
Source§fn algebraic_degree(&self) -> usize
fn algebraic_degree(&self) -> usize
Source§fn is_symmetric(&self) -> bool
fn is_symmetric(&self) -> bool
true if the Boolean function is symmetric. Read moreSource§fn nonlinearity(&self) -> u32
fn nonlinearity(&self) -> u32
Source§fn is_bent(&self) -> bool
fn is_bent(&self) -> bool
true if the Boolean function is bent, meaning maximally nonlinear, or perfectly nonlinear. Read moreSource§fn is_near_bent(&self) -> bool
fn is_near_bent(&self) -> bool
true if the Boolean function is near-bent. Read moreSource§fn algebraic_immunity(&self) -> usize
fn algebraic_immunity(&self) -> usize
Source§fn is_plateaued(&self) -> bool
fn is_plateaued(&self) -> bool
true if the Boolean function is plateaued. Read moreSource§fn sum_of_square_indicator(&self) -> usize
fn sum_of_square_indicator(&self) -> usize
Source§fn has_linear_structure(&self) -> bool
fn has_linear_structure(&self) -> bool
true if the Boolean function has a linear structure. Read moreSource§fn is_linear_structure(&self, value: u32) -> bool
fn is_linear_structure(&self, value: u32) -> bool
Source§fn linear_structures(&self) -> Vec<u32>
fn linear_structures(&self) -> Vec<u32>
Source§fn correlation_immunity(&self) -> usize
fn correlation_immunity(&self) -> usize
Source§fn resiliency_order(&self) -> Option<usize>
fn resiliency_order(&self) -> Option<usize>
Source§fn propagation_criterion(&self) -> usize
fn propagation_criterion(&self) -> usize
Source§impl Clone for BigBooleanFunction
impl Clone for BigBooleanFunction
Source§fn clone(&self) -> BigBooleanFunction
fn clone(&self) -> BigBooleanFunction
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BigBooleanFunction
impl Debug for BigBooleanFunction
Source§impl From<BigBooleanFunction> for BooleanFunction
impl From<BigBooleanFunction> for BooleanFunction
Source§fn from(v: BigBooleanFunction) -> BooleanFunction
fn from(v: BigBooleanFunction) -> BooleanFunction
Source§impl Not for BigBooleanFunction
impl Not for BigBooleanFunction
NOT operator for Boolean functions.
This is equivalent to the crate::BooleanFunctionImpl::reverse operation: it reverses each output of the Boolean function.
Source§impl PartialEq for BigBooleanFunction
impl PartialEq for BigBooleanFunction
Source§impl TryInto<BigBooleanFunction> for BooleanFunction
impl TryInto<BigBooleanFunction> for BooleanFunction
impl Eq for BigBooleanFunction
impl StructuralPartialEq for BigBooleanFunction
Auto Trait Implementations§
impl Freeze for BigBooleanFunction
impl RefUnwindSafe for BigBooleanFunction
impl Send for BigBooleanFunction
impl Sync for BigBooleanFunction
impl Unpin for BigBooleanFunction
impl UnwindSafe for BigBooleanFunction
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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