pub mod ac_repr;
pub mod actions;
pub mod census;
#[cfg(test)]
mod dump;
pub mod egraph_api;
pub mod estimates;
pub mod exact;
mod exact_fixed;
pub mod exact_memo;
pub mod mcgs;
pub mod pretty;
pub mod results;
pub mod reward;
pub mod session;
pub mod space;
pub mod terms;
pub mod transport;
use crate::containers;
containers::define_id31! {
pub struct AuClassId / StoredAuClassId, "auc";
}
containers::define_id31! {
pub struct SccId / StoredSccId, "scc";
}
containers::define_id31! { pub struct SnapshotMemberId / StoredSnapshotMemberId, "sm"; }
containers::define_id31! { pub struct ContextElemId / StoredContextElemId, "ce"; }
containers::define_id31! { pub struct TermChildId / StoredTermChildId, "tc"; }
containers::define_id31! { pub struct ReachBlockId / StoredReachBlockId, "rb"; }
containers::define_id31! { pub struct OrStatsId / StoredOrStatsId, "os"; }
containers::define_id31! { pub struct AndStatsId / StoredAndStatsId, "as"; }
containers::define_id31! { pub struct OrEdgeStatId / StoredOrEdgeStatId, "oes"; }
containers::define_id31! { pub struct AndChildStatId / StoredAndChildStatId, "acs"; }
pub struct AuIds31;
impl crate::config::AuIds for AuIds31 {
type Index = u32;
type Class = AuClassId;
type Scc = SccId;
type Or = space::OrId;
type Action = space::ActionId;
type Context = space::CtxId;
type Term = terms::TermId;
type OrStats = OrStatsId;
type AndStats = AndStatsId;
type OrEdgeStat = OrEdgeStatId;
type AndChildStat = AndChildStatId;
type SnapshotMember = SnapshotMemberId;
type ContextElem = ContextElemId;
type TermChild = TermChildId;
type ReachBlock = ReachBlockId;
}
containers::define_id63! { pub struct AuClassId64 / StoredAuClassId64, "auc64"; }
containers::define_id63! { pub struct SccId64 / StoredSccId64, "scc64"; }
containers::define_id63! { pub struct OrId64 / StoredOrId64, "or64"; }
containers::define_id63! { pub struct ActionId64 / StoredActionId64, "act64"; }
containers::define_id63! { pub struct CtxId64 / StoredCtxId64, "ctx64"; }
containers::define_id63! { pub struct TermId64 / StoredTermId64, "t64"; }
containers::define_id63! { pub struct OrStatsId64 / StoredOrStatsId64, "os64"; }
containers::define_id63! { pub struct AndStatsId64 / StoredAndStatsId64, "as64"; }
containers::define_id63! { pub struct OrEdgeStatId64 / StoredOrEdgeStatId64, "oes64"; }
containers::define_id63! { pub struct AndChildStatId64 / StoredAndChildStatId64, "acs64"; }
containers::define_id63! { pub struct SnapshotMemberId64 / StoredSnapshotMemberId64, "sm64"; }
containers::define_id63! { pub struct ContextElemId64 / StoredContextElemId64, "ce64"; }
containers::define_id63! { pub struct TermChildId64 / StoredTermChildId64, "tc64"; }
containers::define_id63! { pub struct ReachBlockId64 / StoredReachBlockId64, "rb64"; }
pub struct AuIds64;
impl crate::config::AuIds for AuIds64 {
type Index = u64;
type Class = AuClassId64;
type Scc = SccId64;
type Or = OrId64;
type Action = ActionId64;
type Context = CtxId64;
type Term = TermId64;
type OrStats = OrStatsId64;
type AndStats = AndStatsId64;
type OrEdgeStat = OrEdgeStatId64;
type AndChildStat = AndChildStatId64;
type SnapshotMember = SnapshotMemberId64;
type ContextElem = ContextElemId64;
type TermChild = TermChildId64;
type ReachBlock = ReachBlockId64;
}
pub type ClassOf<Cfg> = <<Cfg as crate::config::EGraphConfig>::Au as crate::config::AuIds>::Class;
pub type OrOf<Cfg> = <<Cfg as crate::config::EGraphConfig>::Au as crate::config::AuIds>::Or;
pub type TermOf<Cfg> = <<Cfg as crate::config::EGraphConfig>::Au as crate::config::AuIds>::Term;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub struct Span<I: containers::DenseId> {
pub start: I,
pub len: I::Index,
}
impl<I: containers::DenseId> Span<I> {
#[inline]
pub fn new(start: usize, len: usize) -> Self {
use crate::containers::IndexLike;
Span {
start: I::try_new(start)
.unwrap_or_else(|| panic!("span start {start} exceeds the configured AU capacity")),
len: I::Index::try_from_usize(len).expect("span length exceeds configured AU capacity"),
}
}
#[inline]
pub fn start_usize(&self) -> usize {
self.start.to_usize()
}
#[inline]
pub fn len_usize(&self) -> usize {
use crate::containers::IndexLike;
self.len.as_usize()
}
#[inline]
pub fn end_usize(&self) -> usize {
self.start_usize() + self.len_usize()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum AuError {
NoFiniteRepresentative(u64),
CycleModeMismatch,
}
impl core::fmt::Display for AuError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
AuError::NoFiniteRepresentative(c) => {
write!(f, "class auc{c} has no admissible finite member")
}
AuError::CycleModeMismatch => write!(
f,
"config cycle mode differs from the session's search-space mode"
),
}
}
}
impl std::error::Error for AuError {}