use super::formula::Formula;
pub use super::symbol::Atom;
use super::symbol::{Match, Symbol, Symbolic};
use std::fmt::Display;
#[derive(PartialEq, Eq, PartialOrd, Ord, Debug, Clone, Copy, Hash, Default)]
pub enum PropUnary {
#[default]
Not,
}
impl Display for PropUnary {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
PropUnary::Not => write!(f, "¬"),
}
}
}
impl Symbolic for PropUnary {}
impl Match for PropUnary {
fn get_match(s: &str) -> Option<Self> {
match s {
"¬" | "!" | "~" | "not" => Some(Self::Not),
_ => None,
}
}
}
#[derive(PartialEq, Eq, PartialOrd, Ord, Debug, Clone, Copy, Hash, Default)]
pub enum PropBinary {
Iff,
#[default]
Implies,
Or,
And,
}
impl Display for PropBinary {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
PropBinary::Iff => write!(f, " ↔ "),
PropBinary::Implies => write!(f, " → "),
PropBinary::And => write!(f, " ∧ "),
PropBinary::Or => write!(f, " ∨ "),
}
}
}
impl Symbolic for PropBinary {}
impl Match for PropBinary {
fn get_match(s: &str) -> Option<Self> {
match s {
"<->" | "↔" | "iff" => Some(Self::Iff),
"->" | "→" | "implies" => Some(Self::Implies),
"\\/" | "∨" | "or" => Some(Self::Or),
"/\\" | "∧" | "and" => Some(Self::And),
_ => None,
}
}
}
pub type PropFormula = Formula<PropBinary, PropUnary, Atom>;
pub type PropSymbol = Symbol<PropBinary, PropUnary, Atom>;