use std::borrow::Borrow;
use crate::{
db::ClauseKey,
structures::{
atom::Atom,
literal::{CLiteral, Literal},
},
};
#[derive(Clone, Copy, PartialEq, Eq)]
#[allow(clippy::upper_case_acronyms)]
pub enum Source {
PureLiteral,
BCP(ClauseKey),
}
#[derive(Clone)]
pub struct Consequence {
pub literal: CLiteral,
pub source: Source,
}
impl Consequence {
pub fn from(literal: impl Borrow<CLiteral>, source: Source) -> Self {
Consequence {
literal: literal.borrow().canonical(),
source,
}
}
pub fn from_bind(atom: Atom, value: bool, source: Source) -> Self {
Consequence {
literal: CLiteral::new(atom, value),
source,
}
}
pub fn atom(&self) -> Atom {
self.literal.atom()
}
pub fn value(&self) -> bool {
self.literal.polarity()
}
pub fn literal(&self) -> &CLiteral {
&self.literal
}
pub fn source(&self) -> &Source {
&self.source
}
}