use std::hash::Hash;
pub trait IdType:
Copy + Clone + PartialEq + Eq + Hash + PartialOrd + Ord + Send + Sync + 'static
{
}
impl<T> IdType for T where
T: Copy + Clone + PartialEq + Eq + Hash + PartialOrd + Ord + Send + Sync + 'static
{
}
pub trait NumInputs {
fn num_inputs(&self) -> usize;
}
pub trait NumOutputs {
fn num_outputs(&self) -> usize;
}
pub trait PartialBooleanSystem: NumInputs + NumOutputs {
type LiteralId: IdType;
type TermId: IdType;
fn evaluate_term_partial(&self, term: &Self::TermId, input_values: &[bool]) -> Option<bool>;
}
pub trait PositionalInputs: NumInputs {
type InputId: IdType;
fn get_input_var(&self, position: usize) -> Option<Self::InputId>;
fn find_input_position(&self, input_id: &Self::InputId) -> Option<usize> {
(0..self.num_inputs()).find(|&i| self.get_input_var(i).as_ref() == Some(input_id))
}
}
pub trait BooleanSystem: PartialBooleanSystem {
fn evaluate_term(&self, term: &Self::TermId, input_values: &[bool]) -> bool;
}
pub trait PartialBooleanFunction: PartialBooleanSystem + StaticNumOutputs<1> {
fn partial_eval(&self, input_values: &[bool]) -> Option<bool>;
}
pub trait BooleanFunction: PartialBooleanFunction {
fn eval(&self, input_values: &[bool]) -> bool;
}
pub trait StaticNumInputs<const NUM_INPUTS: usize> {}
pub trait StaticNumOutputs<const NUM_OUTPUTS: usize> {}
pub trait BooleanSystemEdit: BooleanSystem {
}
pub trait StaticPartialComutative<const NUM_INPUTS: usize> {
const COMMUTATIVE_INPUTS: [usize; NUM_INPUTS];
}
pub trait StaticCommutative {}
pub trait ArithmeticProperties {
fn is_commutative(&self) -> bool;
}
pub trait LogicValue: Copy + Clone + PartialEq + Eq + Hash + 'static {
fn num_values() -> usize;
fn value(idx: usize) -> Self;
fn zero() -> Self;
fn one() -> Self;
}
pub trait LogicOps:
Sized + std::ops::Not + std::ops::BitAnd + std::ops::BitOr + std::ops::BitXor
{
}
impl<T> LogicOps for T where
T: Sized + std::ops::Not + std::ops::BitAnd + std::ops::BitOr + std::ops::BitXor
{
}