pub enum ClassicalExpr {
In(u32),
Const(bool),
Not(Box<ClassicalExpr>),
Xor(Box<[ClassicalExpr]>),
And(Box<[ClassicalExpr]>),
Or(Box<[ClassicalExpr]>),
Select(Box<[ClassicalExpr; 3]>),
Parity {
inputs: Box<[u32]>,
constant: bool,
},
}Expand description
Combinational logic over a classical node’s incoming Value edges.
ClassicalExpr::In reads the edge whose slot equals its index
(SSA-by-slot): the slot is carried on the edge, so the binding survives edge
reordering under edits rather than depending on iteration order.
Variants§
In(u32)
Read one incoming edge slot.
Const(bool)
A compile-time-constant bit — an input-less producer. Carries a deterministic feedback sign (constant-sign folds to no op).
Not(Box<ClassicalExpr>)
Boolean negation.
Xor(Box<[ClassicalExpr]>)
Ordered parity operands; the empty parity is false.
And(Box<[ClassicalExpr]>)
Ordered conjunction operands; the empty conjunction is true.
Or(Box<[ClassicalExpr]>)
Ordered disjunction operands; the empty disjunction is false.
Select(Box<[ClassicalExpr; 3]>)
[condition, when_false, when_true]. All three operands must be known,
including the unselected value; this is combinational dataflow (SEM-EXPR).
Parity
Affine parity of ordered input slots and a constant XOR term. Repeated slots stay present: every input must be known even when its Boolean contributions cancel (SEM-EXPR). No expression nodes per slot.
Implementations§
Source§impl ClassicalExpr
impl ClassicalExpr
Sourcepub fn parity(inputs: impl IntoIterator<Item = u32>, constant: bool) -> Self
pub fn parity(inputs: impl IntoIterator<Item = u32>, constant: bool) -> Self
Build an affine parity, retaining input order and multiplicity.
Sourcepub fn xor(operands: impl IntoIterator<Item = Self>) -> Self
pub fn xor(operands: impl IntoIterator<Item = Self>) -> Self
Build a parity list, collapsing empty and singleton lists. Preserves operand order, duplicates, and nested expressions.
§Panics
Panics only if the collected operand count changes before extraction.
Sourcepub fn select(condition: Self, when_false: Self, when_true: Self) -> Self
pub fn select(condition: Self, when_false: Self, when_true: Self) -> Self
Select a value with explicit false/true operand order (SEM-EXPR). Literal branches use smaller operators without dropping unknown inputs.
Sourcepub fn operands(&self) -> &[Self]
pub fn operands(&self) -> &[Self]
Direct expression children in evaluation order. Compact Self::Parity
stores slots directly; use Self::for_each_input to visit all inputs.
Sourcepub fn eval(&self, input: &mut impl FnMut(u32) -> Option<bool>) -> Option<bool>
pub fn eval(&self, input: &mut impl FnMut(u32) -> Option<bool>) -> Option<bool>
Fold the expression over three-valued inputs: None (an input that is
unevaluable in the caller’s context) propagates. The reference
evaluator every consumer shares.
Sourcepub fn for_each_input(&self, f: &mut impl FnMut(u32))
pub fn for_each_input(&self, f: &mut impl FnMut(u32))
Visit every In(slot) leaf, left to right.
Trait Implementations§
Source§impl Clone for ClassicalExpr
impl Clone for ClassicalExpr
Source§fn clone(&self) -> ClassicalExpr
fn clone(&self) -> ClassicalExpr
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ClassicalExpr
impl Debug for ClassicalExpr
Source§impl<'de> Deserialize<'de> for ClassicalExpr
impl<'de> Deserialize<'de> for ClassicalExpr
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for ClassicalExpr
Source§impl Hash for ClassicalExpr
impl Hash for ClassicalExpr
Source§impl PartialEq for ClassicalExpr
impl PartialEq for ClassicalExpr
Source§impl Serialize for ClassicalExpr
impl Serialize for ClassicalExpr
impl StructuralPartialEq for ClassicalExpr
Auto Trait Implementations§
impl Freeze for ClassicalExpr
impl RefUnwindSafe for ClassicalExpr
impl Send for ClassicalExpr
impl Sync for ClassicalExpr
impl Unpin for ClassicalExpr
impl UnsafeUnpin for ClassicalExpr
impl UnwindSafe for ClassicalExpr
Blanket Implementations§
§impl<T, BorrowedSelf> BitwiseMutViaBorrow<BorrowedSelf> for T
impl<T, BorrowedSelf> BitwiseMutViaBorrow<BorrowedSelf> for T
fn assign_index(&mut self, index: usize, to: bool)
fn negate_index(&mut self, index: usize)
fn clear_bits(&mut self)
fn assign_random(
&mut self,
bit_count: usize,
random_number_generator: &mut impl RngExt,
)where
BorrowedSelf: BitLength,
§impl<Bits, Other, BorrowedSelf, BorrowedOther> BitwisePairMutViaBorrow<Other, BorrowedSelf, BorrowedOther> for Bits
impl<Bits, Other, BorrowedSelf, BorrowedOther> BitwisePairMutViaBorrow<Other, BorrowedSelf, BorrowedOther> for Bits
fn assign(&mut self, other: &Other)
fn bitxor_assign(&mut self, other: &Other)
fn bitand_assign(&mut self, other: &Other)
fn bitor_assign(&mut self, other: &Other)
§impl<T, Other, BorrowedSelf, BorrowedOther> BitwisePairViaBorrow<Other, BorrowedSelf, BorrowedOther> for T
impl<T, Other, BorrowedSelf, BorrowedOther> BitwisePairViaBorrow<Other, BorrowedSelf, BorrowedOther> for T
§impl<T, BorrowedSelf> BitwiseViaBorrow<BorrowedSelf> for T
impl<T, BorrowedSelf> BitwiseViaBorrow<BorrowedSelf> for T
fn index(&self, index: usize) -> bool
fn weight(&self) -> usize
fn parity(&self) -> bool
fn is_zero(&self) -> bool
fn is_unit(&self, index: usize) -> bool
fn support<'a>(&'a self) -> impl SortedIteratorwhere
BorrowedSelf: 'a,
fn max_support(&self) -> Option<usize>
fn min_support(&self) -> Option<usize>
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.