use alloc::string::String;
use alloc::vec::Vec;
pub type AtomId = u32;
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub struct AtomKey {
pub domain: String,
pub subject: String,
pub predicate: Option<String>,
pub object: Option<String>,
}
impl core::fmt::Display for AtomKey {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}.{}", self.domain, self.subject)?;
if let Some(p) = &self.predicate {
write!(f, " {p}")?;
}
if let Some(o) = &self.object {
write!(f, " {o}")?;
}
Ok(())
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Lit {
pub atom: AtomId,
pub negated: bool,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Value {
True,
False,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Origin {
pub source: String,
pub line: u32,
pub premise: Option<String>,
pub kind: &'static str,
}
pub const KIND_UNSAT: &str = "UNSAT";
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Fact {
pub atom: AtomId,
pub value: Value,
pub origin: Origin,
pub soft: bool,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Clause {
pub lits: Vec<Lit>,
pub origin: Origin,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Rule {
pub antecedent: Vec<Lit>,
pub consequent: Vec<Lit>,
pub origin: Origin,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Check {
pub subject: Option<String>,
pub bidirectional: bool,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Compiled {
pub atoms: Vec<AtomKey>,
pub facts: Vec<Fact>,
pub clauses: Vec<Clause>,
pub rules: Vec<Rule>,
pub checks: Vec<Check>,
pub pending_imports: Vec<String>,
pub unused_imports: Vec<UnusedImport>,
pub consumed: Vec<AtomId>,
pub placeholders: Vec<PlaceholderInfo>,
}
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub struct UnusedImport {
pub file: String,
pub domain: String,
pub alias: Option<String>,
pub line: u32,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct PortBinding {
pub value: bool,
pub origin: String,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum PlaceholderStatus {
Supplied,
DefaultUsed,
Unset,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct PlaceholderInfo {
pub key: String,
pub status: PlaceholderStatus,
pub value: Option<bool>,
pub origin: Option<String>,
}