Struct NativeBooleanFunction

Source
pub struct NativeBooleanFunction<F, const NUM_INPUTS: usize, const NUM_OUTPUTS: usize>
where F: Fn([bool; NUM_INPUTS]) -> [bool; NUM_OUTPUTS],
{ /* private fields */ }
Expand description

A boolean system which is implemented by a Rust function.

Implementations§

Source§

impl<F, const NUM_INPUTS: usize, const NUM_OUTPUTS: usize> NativeBooleanFunction<F, NUM_INPUTS, NUM_OUTPUTS>
where F: Fn([bool; NUM_INPUTS]) -> [bool; NUM_OUTPUTS],

Source

pub fn new(f: F) -> Self

Create a new boolean system from a native boolean function.

§Example
use libreda_logic::traits::*;
use libreda_logic::native_boolean_functions::*;

let f = NativeBooleanFunction::new(|[a, b, c]| [a ^ b ^ c]);

assert_eq!(true, f.evaluate_term(&0, &[true, true, true]));
assert_eq!(false, f.evaluate_term(&0, &[true, true, false]));

Trait Implementations§

Source§

impl<F, const NUM_INPUTS: usize, const NUM_OUTPUTS: usize> BooleanSystem for NativeBooleanFunction<F, NUM_INPUTS, NUM_OUTPUTS>
where F: Fn([bool; NUM_INPUTS]) -> [bool; NUM_OUTPUTS],

Source§

fn evaluate_term(&self, term: &Self::TermId, input_values: &[bool]) -> bool

Compute the value of the term. The values of all needed literals must be defined by the input_values function.
Source§

impl<F, const NUM_INPUTS: usize, const NUM_OUTPUTS: usize> From<F> for NativeBooleanFunction<F, NUM_INPUTS, NUM_OUTPUTS>
where F: Fn([bool; NUM_INPUTS]) -> [bool; NUM_OUTPUTS],

Source§

fn from(f: F) -> Self

Converts to this type from the input type.
Source§

impl<F, const NUM_INPUTS: usize, const NUM_OUTPUTS: usize> NumInputs for NativeBooleanFunction<F, NUM_INPUTS, NUM_OUTPUTS>
where F: Fn([bool; NUM_INPUTS]) -> [bool; NUM_OUTPUTS],

Source§

fn num_inputs(&self) -> usize

Get the number of inputs of the boolean function.
Source§

impl<F, const NUM_INPUTS: usize, const NUM_OUTPUTS: usize> NumOutputs for NativeBooleanFunction<F, NUM_INPUTS, NUM_OUTPUTS>
where F: Fn([bool; NUM_INPUTS]) -> [bool; NUM_OUTPUTS],

Source§

fn num_outputs(&self) -> usize

Get the number of outputs of the boolean function.
Source§

impl<F, const NUM_INPUTS: usize, const NUM_OUTPUTS: usize> PartialBooleanSystem for NativeBooleanFunction<F, NUM_INPUTS, NUM_OUTPUTS>
where F: Fn([bool; NUM_INPUTS]) -> [bool; NUM_OUTPUTS],

Source§

type LiteralId = usize

An identifier for an input of the boolean formula.
Source§

type TermId = usize

An identifier of an intermediate value or output.
Source§

fn evaluate_term_partial( &self, term: &Self::TermId, input_values: &[bool], ) -> Option<bool>

Compute the value of the term. The values of all needed literals must be defined by the input_values function. Returns None if the value is not specified for the given inputs.
Source§

impl<F, const NUM_INPUTS: usize, const NUM_OUTPUTS: usize> StaticNumInputs<NUM_INPUTS> for NativeBooleanFunction<F, NUM_INPUTS, NUM_OUTPUTS>
where F: Fn([bool; NUM_INPUTS]) -> [bool; NUM_OUTPUTS],

Source§

impl<F, const NUM_INPUTS: usize, const NUM_OUTPUTS: usize> StaticNumOutputs<NUM_OUTPUTS> for NativeBooleanFunction<F, NUM_INPUTS, NUM_OUTPUTS>
where F: Fn([bool; NUM_INPUTS]) -> [bool; NUM_OUTPUTS],

Auto Trait Implementations§

§

impl<F, const NUM_INPUTS: usize, const NUM_OUTPUTS: usize> Freeze for NativeBooleanFunction<F, NUM_INPUTS, NUM_OUTPUTS>
where F: Freeze,

§

impl<F, const NUM_INPUTS: usize, const NUM_OUTPUTS: usize> RefUnwindSafe for NativeBooleanFunction<F, NUM_INPUTS, NUM_OUTPUTS>
where F: RefUnwindSafe,

§

impl<F, const NUM_INPUTS: usize, const NUM_OUTPUTS: usize> Send for NativeBooleanFunction<F, NUM_INPUTS, NUM_OUTPUTS>
where F: Send,

§

impl<F, const NUM_INPUTS: usize, const NUM_OUTPUTS: usize> Sync for NativeBooleanFunction<F, NUM_INPUTS, NUM_OUTPUTS>
where F: Sync,

§

impl<F, const NUM_INPUTS: usize, const NUM_OUTPUTS: usize> Unpin for NativeBooleanFunction<F, NUM_INPUTS, NUM_OUTPUTS>
where F: Unpin,

§

impl<F, const NUM_INPUTS: usize, const NUM_OUTPUTS: usize> UnwindSafe for NativeBooleanFunction<F, NUM_INPUTS, NUM_OUTPUTS>
where F: UnwindSafe,

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