elinvar-engine 0.1.0

The engine of Elinvar, a relational model finder: models, translation, the SAT solver, and verdicts
Documentation
//! Elinvar: find the holes in a design before you build it.
//!
//! A relational model finder: given bounds on relations and a formula,
//! `run` finds an instance and `check` finds a counterexample, through a
//! boolean circuit and a SAT solver. Every instance is refereed by the
//! evaluator of `elinvar-logic` before it is returned (AGENTS.md law 13).
//!
//! ```
//! use elinvar_engine::prelude::*;
//!
//! let mut m = Model::new();
//! let person = m.set("Person");
//! let knows = m.field("knows", &person, &person);
//!
//! // Nobody knows themselves: broken by a self-loop.
//! let no_self = knows.intersection(&Expr::iden()).no();
//! let report = m.check(&no_self).named("NoSelf").scope(3).report();
//! assert_eq!(report.verdict, Some(Verdict::Counterexample));
//!
//! // Add the missing rule and check again.
//! m.fact(no_self.clone());
//! let report = m.check(&no_self).named("NoSelf").scope(3).report();
//! assert_eq!(report.verdict, Some(Verdict::Holds));
//! ```

#[cfg(feature = "bitslice")]
mod bitslice;
mod circuit;
mod coi;
mod diff;
mod model;
pub mod prelude;
mod render;
mod report;
pub mod sat;
mod skolem;
mod solve;
mod symmetry;
mod tests_gen;
mod translate;

#[cfg(feature = "bitslice")]
pub use bitslice::count_bitsliced;
pub use diff::{DiffReport, DiffVerdict, diff_functions, diff_models, diff_models_with_bitwidth};
pub use elinvar_logic as logic;
pub use model::{
    Action, Command, InstanceIter, MODEL_CODES, Model, Ordering, Step, StepGuard, StepSpec,
};
pub use render::{
    DiagramFormat, render_instance, render_instance_sql_with_values, render_model, render_report,
    render_report_sql_with_values, render_states, render_states_sql_with_values, render_trace,
};
pub use report::{
    Change, RESULT_SCHEMA, RESULT_VERSION, Report, SHRINK_CONFLICTS, Sizes, StepReport,
    TraceReport, story, story_brief,
};
pub use tests_gen::{TestCase, TestKind};

/// The explanation of an error code, from the logic's codes or the
/// engine's (AGENTS.md law 21).
pub fn explain(code: &str) -> Option<&'static logic::Code> {
    logic::explain(code).or_else(|| MODEL_CODES.iter().find(|c| c.code == code))
}

/// Every error code, the logic's then the engine's.
pub fn codes() -> impl Iterator<Item = &'static logic::Code> {
    logic::CODES.iter().chain(MODEL_CODES)
}
pub use solve::{
    Finder, HoldsCore, Next, Options, Outcome, Stats, StepLabel, Verdict, check, check_with_solver,
    count, count_with_solver, explain_core, run, run_with_solver, tuples_named,
};
pub use symmetry::partition as symmetry_partition;