Skip to main content

SeMiTONE

Struct SeMiTONE 

Source
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

Source

pub fn new() -> Self

Creates a new empty solver instance.

Source

pub fn new_lit(&mut self) -> Lit

Allocates a new SAT literal.

Source

pub fn new_bool(&mut self) -> BoolExpr

Allocates a new Boolean variable.

Source

pub fn new_int(&mut self) -> ArithExpr

Allocates a new integer variable.

Source

pub fn new_real(&mut self) -> ArithExpr

Allocates a new real variable.

Source

pub fn new_enum(&mut self, domain: impl IntoIterator<Item = usize>) -> EnumExpr

Allocates a new enum variable with the given finite domain.

Source

pub fn new_dl_var(&mut self) -> DlVar

Allocates a new difference logic variable.

Source

pub fn new_euf_var(&mut self) -> EufExpr

Allocates a new EUF variable.

Source

pub fn new_euf_func(&mut self) -> FuncId

Allocates a new uninterpreted function symbol.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn add_clauses( &mut self, clauses: impl IntoIterator<Item = Vec<Lit>>, ) -> Result<(), (usize, Vec<Lit>)>

Adds multiple clauses. Stops at the first conflict.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn decision_level(&self) -> usize

Returns the current internal decision level.

Level 0 corresponds to the root level (no user decision applied).

Source

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).

Source

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.

Source

pub fn current_trail_len(&self) -> usize

Returns the current size of the SAT assignment trail.

Source

pub fn user_scopes_len(&self) -> usize

Returns the number of currently active user scopes (push/pop).

Source

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.

Source

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, where implied lists all literals assigned above the entry decision level (i.e. consequences of assumptions),
  • Ok(None) if inconsistent with the current branch,
  • Err((bt_level, lemma)) if a conflict forces backtracking below the entry level.
Source

pub fn probe(&mut self, assumptions: &[Lit]) -> Result<bool, (usize, Vec<Lit>)>

Probes the current branch with a set of assumptions.

Source

pub fn get_lit_level(&self, lit: Lit) -> Option<usize>

Returns the decision level at which the literal was assigned, if any.

Source

pub fn get_lit_val(&self, lit: Lit) -> Option<bool>

Returns the assigned value of a literal in the current trail.

Source

pub fn get_lit_antecedents(&self, lit: Lit) -> Option<&[Lit]>

Returns the antecedent literals that caused the assignment of lit, if any.

Source

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.

Source

pub fn vars(&self) -> impl ExactSizeIterator<Item = BoolVar>

Returns an iterator over all Boolean variables in the solver.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn get_dl_val(&self, var: DlVar) -> InfRational

Returns the current value of a difference logic variable.

Source

pub fn get_dl_bounds(&self, var: DlVar) -> (InfRational, InfRational)

Returns the current lower and upper bounds of a difference logic variable.

Source

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.

Source

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).

Source

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.

Source

pub fn simplify(&mut self) -> bool

Simplifies the SAT solver’s internal database of clauses and variables.

Source

pub fn stats(&self) -> SmtStats

Returns a snapshot of internal solver counters and optional phase timings.

Trait Implementations§

Source§

impl Default for SeMiTONE

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Forget for SeMiTONE

§

impl Freeze for SeMiTONE
where *const u8 is !null: Freeze, PhantomData<(BoolVar, TheoryConstraint)>: Freeze, PhantomData<(TheoryConstraint, BoolVar)>: Freeze, PhantomData<Option<bool>>: Freeze, PhantomData<Clause>: Freeze, PhantomData<Vec<Watcher>>: Freeze, PhantomData<Option<usize>>: Freeze, PhantomData<bool>: Freeze, PhantomData<BoolVar>: Freeze, PhantomData<Lit>: Freeze, PhantomData<usize>: Freeze, PhantomData<(usize, usize)>: Freeze, PhantomData<u8>: Freeze, PhantomData<u32>: Freeze, PhantomData<InfRational>: Freeze, PhantomData<(Option<Lit>, InfRational)>: Freeze, PhantomData<Option<SparseRow>>: Freeze, PhantomData<(SparseRow, ArithVar)>: Freeze, PhantomData<HashSet<ArithVar, FxBuildHasher>>: Freeze, *const LeafNode<ArithVar, SetValZST> is !null: Freeze, PhantomData<(Owned, LeafOrInternal)>: Freeze, PhantomData<Box<(ArithVar, SetValZST)>>: Freeze, PhantomData<BoundUpdate>: Freeze, PhantomData<Rational>: Freeze, PhantomData<HashSet<usize, FxBuildHasher>>: Freeze, PhantomData<(EnumVar, usize)>: Freeze, PhantomData<((EnumVar, usize), Lit)>: Freeze, PhantomData<Vec<DlEdge>>: Freeze, PhantomData<(DlVar, DlVar)>: Freeze, PhantomData<Option<(DlVar, Lit)>>: Freeze, PhantomData<DlVar>: Freeze, PhantomData<EufNode>: Freeze, PhantomData<Term>: Freeze, PhantomData<(Signature, EufNode)>: Freeze, PhantomData<Vec<EufNode>>: Freeze, PhantomData<(EufNode, EufNode)>: Freeze, PhantomData<EufUndoOp>: Freeze, PhantomData<Option<ProofEdge>>: Freeze, PhantomData<(EufNode, EufNode, Lit)>: Freeze, PhantomData<(EufNode, usize)>: Freeze,

§

impl Move for SeMiTONE

§

impl RefUnwindSafe for SeMiTONE

§

impl Send for SeMiTONE
where RawTable<(BoolVar, TheoryConstraint)>: Send, RawTable<(TheoryConstraint, BoolVar)>: Send, RawVecInner: Send, Rational: Send, RawTable<(SparseRow, ArithVar)>: Send, RawTable<(ArithVar, ())>: Send, NodeRef<Owned, ArithVar, SetValZST, LeafOrInternal>: Send, BoxRaw<(ArithVar, SetValZST)>: Send, RawTable<(usize, ())>: Send, RawTable<((EnumVar, usize), Lit)>: Send, RawTable<(Signature, EufNode)>: Send,

§

impl Sync for SeMiTONE
where RawTable<(BoolVar, TheoryConstraint)>: Sync, RawTable<(TheoryConstraint, BoolVar)>: Sync, RawVecInner: Sync, Rational: Sync, RawTable<(SparseRow, ArithVar)>: Sync, RawTable<(ArithVar, ())>: Sync, NodeRef<Owned, ArithVar, SetValZST, LeafOrInternal>: Sync, BoxRaw<(ArithVar, SetValZST)>: Sync, RawTable<(usize, ())>: Sync, RawTable<((EnumVar, usize), Lit)>: Sync, RawTable<(Signature, EufNode)>: Sync,

§

impl Unpin for SeMiTONE
where *const u8 is !null: Unpin, *const u64 is !null: Unpin, *const LeafNode<ArithVar, SetValZST> is !null: Unpin, Box<(ArithVar, SetValZST)>: Unpin,

§

impl UnsafeUnpin for SeMiTONE
where *const u8 is !null: UnsafeUnpin, PhantomData<(BoolVar, TheoryConstraint)>: UnsafeUnpin, PhantomData<(TheoryConstraint, BoolVar)>: UnsafeUnpin, PhantomData<Option<bool>>: UnsafeUnpin, PhantomData<Clause>: UnsafeUnpin, PhantomData<Vec<Watcher>>: UnsafeUnpin, PhantomData<Option<usize>>: UnsafeUnpin, PhantomData<bool>: UnsafeUnpin, PhantomData<BoolVar>: UnsafeUnpin, PhantomData<Lit>: UnsafeUnpin, PhantomData<usize>: UnsafeUnpin, PhantomData<(usize, usize)>: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, PhantomData<u32>: UnsafeUnpin, PhantomData<InfRational>: UnsafeUnpin, PhantomData<(Option<Lit>, InfRational)>: UnsafeUnpin, PhantomData<Option<SparseRow>>: UnsafeUnpin, PhantomData<(SparseRow, ArithVar)>: UnsafeUnpin, PhantomData<HashSet<ArithVar, FxBuildHasher>>: UnsafeUnpin, *const LeafNode<ArithVar, SetValZST> is !null: UnsafeUnpin, PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin, PhantomData<Box<(ArithVar, SetValZST)>>: UnsafeUnpin, PhantomData<BoundUpdate>: UnsafeUnpin, PhantomData<Rational>: UnsafeUnpin, PhantomData<HashSet<usize, FxBuildHasher>>: UnsafeUnpin, PhantomData<(EnumVar, usize)>: UnsafeUnpin, PhantomData<((EnumVar, usize), Lit)>: UnsafeUnpin, PhantomData<Vec<DlEdge>>: UnsafeUnpin, PhantomData<(DlVar, DlVar)>: UnsafeUnpin, PhantomData<Option<(DlVar, Lit)>>: UnsafeUnpin, PhantomData<DlVar>: UnsafeUnpin, PhantomData<EufNode>: UnsafeUnpin, PhantomData<Term>: UnsafeUnpin, PhantomData<(Signature, EufNode)>: UnsafeUnpin, PhantomData<Vec<EufNode>>: UnsafeUnpin, PhantomData<(EufNode, EufNode)>: UnsafeUnpin, PhantomData<EufUndoOp>: UnsafeUnpin, PhantomData<Option<ProofEdge>>: UnsafeUnpin, PhantomData<(EufNode, EufNode, Lit)>: UnsafeUnpin, PhantomData<(EufNode, usize)>: UnsafeUnpin,

§

impl UnwindSafe for SeMiTONE
where HashMap<BoolVar, TheoryConstraint, FxBuildHasher>: UnwindSafe, HashMap<TheoryConstraint, BoolVar, FxBuildHasher>: UnwindSafe, RawVecInner: UnwindSafe, NonNull<u64>: UnwindSafe, HashMap<SparseRow, ArithVar, FxBuildHasher>: UnwindSafe, NonNull<u8>: UnwindSafe, BTreeMap<ArithVar, SetValZST>: UnwindSafe, HashMap<(EnumVar, usize), Lit, FxBuildHasher>: UnwindSafe, HashMap<Signature, EufNode, FxBuildHasher>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> StrictAs for T

Source§

fn strict_as<Dst>(self) -> Dst
where T: StrictCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> StrictCastFrom<Src> for Dst
where Src: StrictCast<Dst>,

Source§

fn strict_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.