LogicNetwork

Struct LogicNetwork 

Source
pub struct LogicNetwork<Node> { /* private fields */ }
Expand description

An implementation of logic networks which is parameterized with the type of the logic node.

Implementations§

Source§

impl<Node> LogicNetwork<Node>

Source

pub fn new() -> Self

Create a new and empty logic network.

Source§

impl<Node> LogicNetwork<Node>

Source

pub fn get_node(&self, node_id: NodeId) -> GeneralNode<&Node>

Get the node value of the given node_id.

Source

pub fn get_logic_node_mut(&mut self, node_id: NodeId) -> Option<&mut Node>

Get a mutable reference to the logic node with the given ID. Returns None if the node is an input, a constant or non-existent.

Trait Implementations§

Source§

impl<Node> BooleanSystem for LogicNetwork<Node>
where Node: NetworkNode<NodeId = NodeId>,

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<Node: Clone> Clone for LogicNetwork<Node>

Source§

fn clone(&self) -> LogicNetwork<Node>

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<Node: Default> Default for LogicNetwork<Node>

Source§

fn default() -> LogicNetwork<Node>

Returns the “default value” for a type. Read more
Source§

impl<Node> Network for LogicNetwork<Node>
where Node: NetworkNode<NodeId = NodeId>,

Source§

type Node = Node

Type of the logic node.
Source§

type NodeId = NodeId

Identifier of a logic node in this network.
Source§

type Signal = NodeId

Type which represents the outputs of network nodes, e.g. signals. In contrast to a NodeId a Signal might also encode a logic inversion.
Source§

type LogicValue = bool

Type of signal values. Typically this might be bool.
Source§

type NodeFunction = SmallTruthTable

Type which represents the logic function of nodes in the network.
Source§

fn num_gates(&self) -> usize

Number of gates present in the network.
Source§

fn num_primary_inputs(&self) -> usize

Number of input into the network.
Source§

fn num_primary_outputs(&self) -> usize

Number of outputs from the network.
Source§

fn foreach_gate(&self, f: impl Fn(Self::Signal))

Visit all network gates in an undefined order. Each gate is visited exactly once.
Source§

fn foreach_node(&self, f: impl Fn(&Self::Node))

Visit all logic nodes.
Source§

fn get_constant(&self, value: Self::LogicValue) -> Self::Signal

Get a graph signal which represents the constant value.
Source§

fn get_constant_value(&self, signal: Self::Signal) -> Option<Self::LogicValue>

Get the value of a signal if it is a constant.
Source§

fn get_node_input( &self, node: &Self::Signal, input_index: usize, ) -> Self::Signal

Get an input value of a node.
Source§

fn get_source_node(&self, signal: &Self::Signal) -> Self::NodeId

Get the node which computes a signal.
Source§

fn get_primary_input(&self, index: usize) -> Self::Signal

Get a primary input by its index.
Source§

fn get_primary_output(&self, index: usize) -> Self::Signal

Get a primary output by its index.
Source§

fn is_constant(&self, signal: Self::Signal) -> bool

Tell if the signal is directly connected to a constant.
Source§

fn is_input(&self, signal: Self::Signal) -> bool

Check if the signal is a primary input.
Source§

fn node_function(&self, node: Self::Signal) -> Self::NodeFunction

Get the logic function implemented by the given node.
Source§

fn num_node_inputs(&self, node: &Self::Signal) -> usize

Number of inputs into the given node.
Source§

fn get_node_output(&self, node: &Self::NodeId) -> Self::Signal

Get the output signal of a node.
Source§

impl<Node> NetworkEdit for LogicNetwork<Node>

Source§

fn create_primary_input(&mut self) -> Self::Signal

Create a new input into the network.
Source§

fn create_primary_output(&mut self, signal: Self::Signal) -> Self::Signal

Create an output of the network.
Source§

fn substitute(&mut self, old: Self::Signal, new: Self::Signal)

Substitute the old signal with the new signal in all nodes.
Source§

fn create_node(&mut self, node: Self::Node) -> Self::NodeId

Insert a new node into the network. Returns the ID of the new node. This function can also return IDs that already existed before. For example if there is already a node with the same inputs.
Source§

fn foreach_node_mut(&mut self, f: impl Fn(&mut Self::Node))

Visit all logic nodes as mutable references.
Source§

impl<Node> NumInputs for LogicNetwork<Node>

Source§

fn num_inputs(&self) -> usize

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

impl<Node> NumOutputs for LogicNetwork<Node>

Source§

fn num_outputs(&self) -> usize

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

impl<Node> PartialBooleanSystem for LogicNetwork<Node>
where Node: NetworkNode<NodeId = NodeId>,

Source§

type LiteralId = NodeId

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

type TermId = NodeId

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<Node> ReferenceCounted for LogicNetwork<Node>

Source§

fn num_references(&self, a: Self::Signal) -> usize

Count the number of nodes which have the signal a in their fan-in.

Auto Trait Implementations§

§

impl<Node> Freeze for LogicNetwork<Node>

§

impl<Node> RefUnwindSafe for LogicNetwork<Node>
where Node: RefUnwindSafe,

§

impl<Node> Send for LogicNetwork<Node>
where Node: Send,

§

impl<Node> Sync for LogicNetwork<Node>
where Node: Sync,

§

impl<Node> Unpin for LogicNetwork<Node>
where Node: Unpin,

§

impl<Node> UnwindSafe for LogicNetwork<Node>
where Node: 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> 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<T> NetworkEditShortcuts for T
where T: NetworkEdit,

Source§

fn create_primary_inputs<const NUM_INPUTS: usize>( &mut self, ) -> [Self::Signal; NUM_INPUTS]

Create many inputs at once.
Source§

impl<T> NetworkShortcuts for T
where T: Network,

Source§

fn primary_inputs(&self) -> Box<dyn Iterator<Item = Self::NodeId> + '_>

Iterator over all primary inputs of the network.
Source§

fn primary_outputs(&self) -> Box<dyn Iterator<Item = Self::Signal> + '_>

Iterator over all primary outputs of the network.
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.