pub trait Solver {
// Required methods
fn new_var(&mut self) -> Var;
fn add_clause(&mut self, clause: &[Lit]);
fn solve(&mut self, assumptions: &[Lit], budget: &Budget) -> Solved;
fn value(&self, var: Var) -> bool;
// Provided methods
fn conflicts(&self) -> u64 { ... }
fn unsat_core(&self) -> Vec<Lit> { ... }
fn unknown_reason(&self) -> Option<BudgetExhausted> { ... }
}Expand description
A SAT solver: the one public trait without two implementations, because R9 asks for it (AGENTS.md law 25).
use elinvar_engine::sat::{Budget, Cdcl, Lit, Solved, Solver};
let mut solver = Cdcl::new();
let a = solver.new_var();
let b = solver.new_var();
solver.add_clause(&[Lit::positive(a), Lit::positive(b)]);
solver.add_clause(&[Lit::negative(a)]);
assert_eq!(solver.solve(&[], &Budget::conflicts(100)), Solved::Sat);
assert!(!solver.value(a));
assert!(solver.value(b));Required Methods§
Sourcefn add_clause(&mut self, clause: &[Lit])
fn add_clause(&mut self, clause: &[Lit])
Adds a clause: at least one of its literals is true.
Provided Methods§
Sourcefn conflicts(&self) -> u64
fn conflicts(&self) -> u64
Total conflicts spent by this solver, for statistics. Returns 0
when a solver does not report conflict counts.
Sourcefn unsat_core(&self) -> Vec<Lit>
fn unsat_core(&self) -> Vec<Lit>
After Solved::Unsat, a subset of the assumptions passed to solve
whose conjunction with the clauses is unsatisfiable. Returns an empty
vector when the clauses alone are unsatisfiable or when a solver does
not extract cores.
Sourcefn unknown_reason(&self) -> Option<BudgetExhausted>
fn unknown_reason(&self) -> Option<BudgetExhausted>
After Solved::Unknown, which limit of the Budget ended the search,
if the solver tracks it (N26).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".