pub struct SeMiTONE { /* private fields */ }Expand description
Main solver entry point for propositional and theory constraints.
The solver combines a SAT core with propagation for linear real and integer arithmetic, difference logic, finite-domain enums, and equality with uninterpreted functions.
Implementations§
Source§impl SeMiTONE
impl SeMiTONE
Sourcepub fn new_enum(&mut self, domain: impl IntoIterator<Item = usize>) -> EnumExpr
pub fn new_enum(&mut self, domain: impl IntoIterator<Item = usize>) -> EnumExpr
Allocates a new enum variable with the given finite domain.
Sourcepub fn new_dl_var(&mut self) -> DlVar
pub fn new_dl_var(&mut self) -> DlVar
Allocates a new difference logic variable.
Sourcepub fn new_euf_var(&mut self) -> EufExpr
pub fn new_euf_var(&mut self) -> EufExpr
Allocates a new EUF variable.
Sourcepub fn new_euf_func(&mut self) -> FuncId
pub fn new_euf_func(&mut self) -> FuncId
Allocates a new uninterpreted function symbol.
Sourcepub fn new_euf_app(&mut self, func_id: FuncId, args: Vec<Expr>) -> EufExpr
pub fn new_euf_app(&mut self, func_id: FuncId, args: Vec<Expr>) -> EufExpr
Allocates a new EUF function application with the given function ID and arguments.
Sourcepub fn num_vars(&self) -> usize
pub fn num_vars(&self) -> usize
Returns the current number of SAT variables allocated in the solver core.
This includes user-visible Boolean variables and internal proxy variables introduced while encoding compound constraints.
Sourcepub fn add_clause(
&mut self,
clause: impl IntoIterator<Item = Lit>,
) -> Result<(), (usize, Vec<Lit>)>
pub fn add_clause( &mut self, clause: impl IntoIterator<Item = Lit>, ) -> Result<(), (usize, Vec<Lit>)>
Adds a clause to the SAT core.
Returns Ok(()) when accepted, or Err(Conflict) when the clause
is inconsistent at the current scope or requires a structural backtrack.
Sourcepub fn add_learnt_clause(
&mut self,
clause: impl IntoIterator<Item = Lit>,
) -> Result<(), (usize, Vec<Lit>)>
pub fn add_learnt_clause( &mut self, clause: impl IntoIterator<Item = Lit>, ) -> Result<(), (usize, Vec<Lit>)>
Adds a learnt clause to the SAT core.
Learnt clauses are typically generated by the solver during conflict analysis and are not part of the original problem. This method allows adding such clauses to the solver.
Returns Ok(()) when accepted, or Err(Conflict) when the clause
is inconsistent at the current scope or requires a structural backtrack.
Sourcepub fn add_clauses(
&mut self,
clauses: impl IntoIterator<Item = Vec<Lit>>,
) -> Result<(), (usize, Vec<Lit>)>
pub fn add_clauses( &mut self, clauses: impl IntoIterator<Item = Vec<Lit>>, ) -> Result<(), (usize, Vec<Lit>)>
Adds multiple clauses. Stops at the first conflict.
Sourcepub fn assert(
&mut self,
expr: impl AsRef<BoolExpr>,
) -> Result<(), (usize, Vec<Lit>)>
pub fn assert( &mut self, expr: impl AsRef<BoolExpr>, ) -> Result<(), (usize, Vec<Lit>)>
Adds a Boolean constraint to the current solver context.
Returns Ok(()) if accepted, or Err((backtrack_level, clause)) if it
immediately conflicts with the current assignment. Acceptance does not
imply theory feasibility; call SeMiTONE::propagate to process queued
literals and detect theory conflicts.
Sourcepub fn track_expr(
&mut self,
expr: impl AsRef<BoolExpr>,
) -> Result<Lit, (usize, Vec<Lit>)>
pub fn track_expr( &mut self, expr: impl AsRef<BoolExpr>, ) -> Result<Lit, (usize, Vec<Lit>)>
Encodes a Boolean expression and returns its equivalent SAT literal.
Returns the literal, which may be an internal proxy, or an immediate
conflict as Err((backtrack_level, clause)). Encoding compound
expressions can add auxiliary variables and clauses, but does not assert
the expression. The literal can be inspected with
SeMiTONE::get_lit_val or used with SeMiTONE::decide.
Sourcepub fn decide(&mut self, lit: Lit) -> bool
pub fn decide(&mut self, lit: Lit) -> bool
Adds a decision literal to the current search branch.
This opens a new internal decision level and enqueues lit as a decision.
Returns false only if the literal is immediately inconsistent with the
current assignment.
After a successful decision, call SeMiTONE::propagate to derive its
consequences and detect theory conflicts.
Sourcepub fn decide_enum(&mut self, expr: impl AsRef<EnumExpr>, value: usize) -> bool
pub fn decide_enum(&mut self, expr: impl AsRef<EnumExpr>, value: usize) -> bool
Decides that an enum variable takes a specific value in the current branch.
Convenience wrapper around SeMiTONE::decide. Returns false if the
decision cannot be enqueued consistently.
Sourcepub fn decision_level(&self) -> usize
pub fn decision_level(&self) -> usize
Returns the current internal decision level.
Level 0 corresponds to the root level (no user decision applied).
Sourcepub fn cancel_until(&mut self, level: usize) -> Vec<Lit>
pub fn cancel_until(&mut self, level: usize) -> Vec<Lit>
Cancels all decisions and theory updates at levels deeper than level.
This restores SAT/theory state to the requested level and drops pending notifications beyond the restored trail. Returns the list of retracted literals in reverse chronological order (LIFO).
Sourcepub fn get_trail_delta(&self, from_index: usize) -> &[Lit]
pub fn get_trail_delta(&self, from_index: usize) -> &[Lit]
Returns the trail suffix starting at from_index.
Useful for external heuristics that need to inspect newly assigned literals.
Sourcepub fn current_trail_len(&self) -> usize
pub fn current_trail_len(&self) -> usize
Returns the current size of the SAT assignment trail.
Sourcepub fn user_scopes_len(&self) -> usize
pub fn user_scopes_len(&self) -> usize
Returns the number of currently active user scopes (push/pop).
Sourcepub fn propagate(&mut self) -> Result<(), (usize, Vec<Lit>)>
pub fn propagate(&mut self) -> Result<(), (usize, Vec<Lit>)>
Runs SAT + theory propagation until a fixed point or a conflict.
Returns:
Ok(())if the current branch is feasible after propagation.Err((backtrack_level, no_good))if a conflict is found.
The returned backtrack_level is the suggested non-chronological level to
backtrack to, and no_good is a conflict explanation suitable for learning.
Sourcepub fn probe_implied(
&mut self,
assumptions: &[Lit],
) -> Result<Option<Vec<Lit>>, (usize, Vec<Lit>)>
pub fn probe_implied( &mut self, assumptions: &[Lit], ) -> Result<Option<Vec<Lit>>, (usize, Vec<Lit>)>
Probes the current branch with assumptions.
Returns:
Ok(Some(implied))if consistent, whereimpliedlists all literals assigned above the entry decision level (i.e. consequences ofassumptions),Ok(None)if inconsistent with the current branch,Err((bt_level, lemma))if a conflict forces backtracking below the entry level.
Sourcepub fn probe(&mut self, assumptions: &[Lit]) -> Result<bool, (usize, Vec<Lit>)>
pub fn probe(&mut self, assumptions: &[Lit]) -> Result<bool, (usize, Vec<Lit>)>
Probes the current branch with a set of assumptions.
Sourcepub fn get_lit_level(&self, lit: Lit) -> Option<usize>
pub fn get_lit_level(&self, lit: Lit) -> Option<usize>
Returns the decision level at which the literal was assigned, if any.
Sourcepub fn get_lit_val(&self, lit: Lit) -> Option<bool>
pub fn get_lit_val(&self, lit: Lit) -> Option<bool>
Returns the assigned value of a literal in the current trail.
Sourcepub fn get_lit_antecedents(&self, lit: Lit) -> Option<&[Lit]>
pub fn get_lit_antecedents(&self, lit: Lit) -> Option<&[Lit]>
Returns the antecedent literals that caused the assignment of lit, if any.
Sourcepub fn get_lit_val_and_level(&self, lit: Lit) -> Option<(bool, usize)>
pub fn get_lit_val_and_level(&self, lit: Lit) -> Option<(bool, usize)>
Returns the assigned value and decision level of a literal in the current trail.
Sourcepub fn vars(&self) -> impl ExactSizeIterator<Item = BoolVar>
pub fn vars(&self) -> impl ExactSizeIterator<Item = BoolVar>
Returns an iterator over all Boolean variables in the solver.
Sourcepub fn get_bool_val(&self, expr: impl AsRef<BoolExpr>) -> Option<bool>
pub fn get_bool_val(&self, expr: impl AsRef<BoolExpr>) -> Option<bool>
Returns the assigned value of a Boolean expression when it is fully determined.
Sourcepub fn get_arith_val(&self, expr: impl AsRef<ArithExpr>) -> Option<InfRational>
pub fn get_arith_val(&self, expr: impl AsRef<ArithExpr>) -> Option<InfRational>
Returns the current value of an arithmetic expression when it is fixed by the model.
Sourcepub fn get_arith_bounds(
&self,
expr: impl AsRef<ArithExpr>,
) -> Option<(InfRational, InfRational)>
pub fn get_arith_bounds( &self, expr: impl AsRef<ArithExpr>, ) -> Option<(InfRational, InfRational)>
Returns the current lower and upper bounds of an arithmetic expression when they are fixed by the model.
Sourcepub fn get_enum_val(&self, expr: impl AsRef<EnumExpr>) -> Option<usize>
pub fn get_enum_val(&self, expr: impl AsRef<EnumExpr>) -> Option<usize>
Returns the current value of an enum expression when it is fixed by the model.
Sourcepub fn get_dl_val(&self, var: DlVar) -> InfRational
pub fn get_dl_val(&self, var: DlVar) -> InfRational
Returns the current value of a difference logic variable.
Sourcepub fn get_dl_bounds(&self, var: DlVar) -> (InfRational, InfRational)
pub fn get_dl_bounds(&self, var: DlVar) -> (InfRational, InfRational)
Returns the current lower and upper bounds of a difference logic variable.
Sourcepub fn push(&mut self)
pub fn push(&mut self)
Opens a new incremental user scope for assertions and decisions.
All constraints/decisions added after this call can be discarded by
SeMiTONE::pop.
Sourcepub fn pop(&mut self) -> Option<Vec<Lit>>
pub fn pop(&mut self) -> Option<Vec<Lit>>
Restores the previous user scope and discards assertions added in it.
If no user scope is open, this is a no-op.
Returns the list of retracted literals in reverse chronological order (LIFO).
Sourcepub fn check_ints(&mut self) -> Result<(), (usize, Vec<Lit>)>
pub fn check_ints(&mut self) -> Result<(), (usize, Vec<Lit>)>
Checks integrality of integer variables under the current rational model.
Returns Ok(()) if all integer variables are integral.
Otherwise returns Err((backtrack_level, lemma)) with either a Gomory
cut or a branching disjunction for branch-and-bound.