#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Name<'a> {
Lower(&'a str),
SingleQuoted(&'a str),
Integer(&'a str),
}
impl<'a> Name<'a> {
pub fn as_str(&self) -> &'a str {
match self {
Name::Lower(s) => s,
Name::SingleQuoted(s) => s,
Name::Integer(s) => s,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Number<'a> {
Integer(&'a str),
Rational(&'a str),
Real(&'a str),
}
impl<'a> Number<'a> {
pub fn as_str(&self) -> &'a str {
match self {
Number::Integer(s) => s,
Number::Rational(s) => s,
Number::Real(s) => s,
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub enum GeneralTerm<'a> {
Word(AtomicWord<'a>),
Number(Number<'a>),
DistinctObject(&'a str),
Variable(&'a str),
Function(AtomicWord<'a>, Vec<GeneralTerm<'a>>),
List(Vec<GeneralTerm<'a>>),
ColonPair(Box<GeneralTerm<'a>>, Box<GeneralTerm<'a>>),
Formula(Box<GeneralData<'a>>),
}
#[derive(Debug, Clone, PartialEq)]
pub enum GeneralData<'a> {
THF(Box<super::thf::THFFormula<'a>>),
TFF(Box<super::tff::TFFFormula<'a>>),
FOF(Box<super::fof::FOFFormula<'a>>),
CNF(Box<super::cnf::CNFFormula<'a>>),
FOT(Box<super::fof::FOFTerm<'a>>),
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum AtomicWord<'a> {
Lower(&'a str),
SingleQuoted(&'a str),
}
impl<'a> AtomicWord<'a> {
pub fn as_str(&self) -> &'a str {
match self {
AtomicWord::Lower(s) => s,
AtomicWord::SingleQuoted(s) => s,
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct DefinedWord<'a>(pub &'a str);
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct SystemWord<'a>(pub &'a str);
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum BinaryConnective {
Iff,
Impl,
RevImpl,
Xor,
Nor,
Nand,
Or,
And,
}
impl BinaryConnective {
pub fn as_str(&self) -> &'static str {
match self {
BinaryConnective::Iff => "<=>",
BinaryConnective::Impl => "=>",
BinaryConnective::RevImpl => "<=",
BinaryConnective::Xor => "<~>",
BinaryConnective::Nor => "~|",
BinaryConnective::Nand => "~&",
BinaryConnective::Or => "|",
BinaryConnective::And => "&",
}
}
pub fn precedence(&self) -> u8 {
match self {
BinaryConnective::Iff
| BinaryConnective::Impl
| BinaryConnective::RevImpl
| BinaryConnective::Xor
| BinaryConnective::Nor
| BinaryConnective::Nand => 1,
BinaryConnective::Or => 2,
BinaryConnective::And => 3,
}
}
pub fn is_associative(&self) -> bool {
matches!(self, BinaryConnective::Or | BinaryConnective::And)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum UnaryConnective {
Not,
}
impl UnaryConnective {
pub fn as_str(&self) -> &'static str {
match self {
UnaryConnective::Not => "~",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Quantifier {
Forall,
Exists,
}
impl Quantifier {
pub fn as_str(&self) -> &'static str {
match self {
Quantifier::Forall => "!",
Quantifier::Exists => "?",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum InfixEquality {
Equal,
NotEqual,
}
impl InfixEquality {
pub fn as_str(&self) -> &'static str {
match self {
InfixEquality::Equal => "=",
InfixEquality::NotEqual => "!=",
}
}
}