Struct easy_smt::Context

source ·
pub struct Context { /* private fields */ }
Expand description

An SMT-LIB 2 context, usually backed by a solver subprocess.

Created via a ContextBuilder.

Implementations§

source§

impl Context

§Solver Commands and Assertions

These methods send a command or assertion to the context’s underlying solver. As such, they involve I/O with a subprocess and are therefore fallible.

§Panics

These methods will panic when called if the context was not created with an underlying solver (via ContextBuilder::solver).

source

pub fn set_option<K>(&mut self, name: K, value: SExpr) -> Result<()>
where K: Into<String> + AsRef<str>,

source

pub fn check_assuming( &mut self, props: impl IntoIterator<Item = SExpr>, ) -> Result<Response>

Assert check-sat-assuming with the given list of assumptions.

source

pub fn check(&mut self) -> Result<Response>

Assert check-sat for the current context.

source

pub fn declare_const<S: Into<String> + AsRef<str>>( &mut self, name: S, sort: SExpr, ) -> Result<SExpr>

Declare a new constant with the provided sort

source

pub fn declare_datatype<S: Into<String> + AsRef<str>>( &mut self, name: S, decl: SExpr, ) -> Result<SExpr>

source

pub fn declare_datatypes<N, S, D>(&mut self, sorts: S, decls: D) -> Result<()>
where N: Into<String> + AsRef<str>, S: IntoIterator<Item = (N, i32)>, D: IntoIterator<Item = SExpr>,

source

pub fn declare_fun<S: Into<String> + AsRef<str>>( &mut self, name: S, args: Vec<SExpr>, out: SExpr, ) -> Result<SExpr>

Declares a new, uninterpreted function symbol.

source

pub fn define_fun<S: Into<String> + AsRef<str>>( &mut self, name: S, args: Vec<(S, SExpr)>, out: SExpr, body: SExpr, ) -> Result<SExpr>

Defines a new function with a body.

source

pub fn define_const<S: Into<String> + AsRef<str>>( &mut self, name: S, out: SExpr, body: SExpr, ) -> Result<SExpr>

Define a constant with a body with a value. This is a convenience wrapper over Self::define_fun since constants are nullary functions.

source

pub fn declare_sort<S: Into<String> + AsRef<str>>( &mut self, symbol: S, arity: i32, ) -> Result<SExpr>

source

pub fn assert(&mut self, expr: SExpr) -> Result<()>

source

pub fn get_model(&mut self) -> Result<SExpr>

Get a model out from the solver. This is only meaningful after a check-sat query.

source

pub fn get_value(&mut self, vals: Vec<SExpr>) -> Result<Vec<(SExpr, SExpr)>>

Get bindings for values in the model. This is only meaningful after a check-sat query.

source

pub fn get_unsat_core(&mut self) -> Result<SExpr>

Returns the names of the formulas involved in a contradiction.

source

pub fn set_logic<L: Into<String> + AsRef<str>>( &mut self, logic: L, ) -> Result<()>

source

pub fn push(&mut self) -> Result<()>

Push a new context frame in the solver. Same as SMTLIB’s push command.

source

pub fn push_many(&mut self, n: usize) -> Result<()>

source

pub fn pop(&mut self) -> Result<()>

Pop a context frame in the solver. Same as SMTLIB’s pop command.

source

pub fn pop_many(&mut self, n: usize) -> Result<()>

source§

impl Context

§Basic S-Expression Construction and Inspection

These methods provide the foundation of building s-expressions. Even if you end up using higher-level helper methods most of the time, everything bottoms out in calls to these methods.

source

pub fn atom(&self, name: impl Into<String> + AsRef<str>) -> SExpr

Construct a non-list s-expression from the given string.

source

pub fn list(&self, list: Vec<SExpr>) -> SExpr

Construct a list s-expression from the given elements.

source

pub fn numeral(&self, val: impl IntoNumeral) -> SExpr

Create a numeral s-expression.

source

pub fn decimal(&self, val: impl IntoDecimal) -> SExpr

Create a decimal s-expression.

source

pub fn binary(&self, bit_width: usize, val: impl IntoBinary) -> SExpr

Create a binary s-expression of the given bit width.

source

pub fn display(&self, expr: SExpr) -> DisplayExpr<'_>

Get a std::fmt::Display representation of the given s-expression.

This allows you to print, log, or otherwise format an s-expression creating within this context.

You may only pass in SExprs that were created by this Context. Failure to do so is safe, but may trigger a panic or return invalid data.

source

pub fn get(&self, expr: SExpr) -> SExprData<'_>

Get the atom or list data for the given s-expression.

This allows you to inspect s-expressions.

You may only pass in SExprs that were created by this Context. Failure to do so is safe, but may trigger a panic or return invalid data.

source

pub fn atoms(&self) -> &KnownAtoms

Access “known” atoms.

This lets you skip the is-it-already-interned-or-not checks and hash map lookups for certain frequently used atoms.

source§

impl Context

§Generic and Polymorphic Helpers

Helpers for constructing s-expressions that are not specific to one sort.

source

pub fn par<N, S, D>(&self, symbols: S, decls: D) -> SExpr
where N: Into<String> + AsRef<str>, S: IntoIterator<Item = N>, D: IntoIterator<Item = SExpr>,

source

pub fn attr( &self, expr: SExpr, name: impl Into<String> + AsRef<str>, val: SExpr, ) -> SExpr

source

pub fn named(&self, name: impl Into<String> + AsRef<str>, expr: SExpr) -> SExpr

source

pub fn let_<N: Into<String> + AsRef<str>>( &self, name: N, e: SExpr, body: SExpr, ) -> SExpr

A let-declaration with a single binding.

source

pub fn let_many<N, I>(&self, bindings: I, body: SExpr) -> SExpr
where I: IntoIterator<Item = (N, SExpr)>, N: Into<String> + AsRef<str>,

A let-declaration of multiple bindings.

source

pub fn forall<N, I>(&self, vars: I, body: SExpr) -> SExpr
where I: IntoIterator<Item = (N, SExpr)>, N: Into<String> + AsRef<str>,

Universally quantify sorted variables in an expression.

source

pub fn exists<N, I>(&self, vars: I, body: SExpr) -> SExpr
where I: IntoIterator<Item = (N, SExpr)>, N: Into<String> + AsRef<str>,

Existentially quantify sorted variables in an expression.

source

pub fn match_<I: IntoIterator<Item = (SExpr, SExpr)>>( &self, term: SExpr, arms: I, ) -> SExpr

Perform pattern matching on values of an algebraic data type.

source

pub fn ite(&self, c: SExpr, t: SExpr, e: SExpr) -> SExpr

Construct an if-then-else expression.

source§

impl Context

§Bool Helpers

These methods help you construct s-expressions for various bool operations.

source

pub fn bool_sort(&self) -> SExpr

The Bool sort.

source

pub fn true_(&self) -> SExpr

The true constant.

source

pub fn false_(&self) -> SExpr

The false constant.

source

pub fn not(&self, val: SExpr) -> SExpr

source

pub fn imp(&self, lhs: SExpr, rhs: SExpr) -> SExpr

source

pub fn imp_many<I: IntoIterator<Item = SExpr>>(&self, items: I) -> SExpr

source

pub fn and(&self, lhs: SExpr, rhs: SExpr) -> SExpr

source

pub fn and_many<I: IntoIterator<Item = SExpr>>(&self, items: I) -> SExpr

source

pub fn or(&self, lhs: SExpr, rhs: SExpr) -> SExpr

source

pub fn or_many<I: IntoIterator<Item = SExpr>>(&self, items: I) -> SExpr

source

pub fn xor(&self, lhs: SExpr, rhs: SExpr) -> SExpr

source

pub fn xor_many<I: IntoIterator<Item = SExpr>>(&self, items: I) -> SExpr

source

pub fn eq(&self, lhs: SExpr, rhs: SExpr) -> SExpr

source

pub fn eq_many<I: IntoIterator<Item = SExpr>>(&self, items: I) -> SExpr

source

pub fn distinct(&self, lhs: SExpr, rhs: SExpr) -> SExpr

source

pub fn distinct_many<I: IntoIterator<Item = SExpr>>(&self, items: I) -> SExpr

source§

impl Context

§Int Helpers

These methods help you construct s-expressions for various int operations.

source

pub fn int_sort(&self) -> SExpr

The Int sort.

source

pub fn negate(&self, val: SExpr) -> SExpr

source

pub fn sub(&self, lhs: SExpr, rhs: SExpr) -> SExpr

source

pub fn sub_many<I: IntoIterator<Item = SExpr>>(&self, items: I) -> SExpr

source

pub fn plus(&self, lhs: SExpr, rhs: SExpr) -> SExpr

source

pub fn plus_many<I: IntoIterator<Item = SExpr>>(&self, items: I) -> SExpr

source

pub fn times(&self, lhs: SExpr, rhs: SExpr) -> SExpr

source

pub fn times_many<I: IntoIterator<Item = SExpr>>(&self, items: I) -> SExpr

source

pub fn div(&self, lhs: SExpr, rhs: SExpr) -> SExpr

source

pub fn div_many<I: IntoIterator<Item = SExpr>>(&self, items: I) -> SExpr

source

pub fn modulo(&self, lhs: SExpr, rhs: SExpr) -> SExpr

source

pub fn modulo_many<I: IntoIterator<Item = SExpr>>(&self, items: I) -> SExpr

source

pub fn rem(&self, lhs: SExpr, rhs: SExpr) -> SExpr

source

pub fn rem_many<I: IntoIterator<Item = SExpr>>(&self, items: I) -> SExpr

source

pub fn lte(&self, lhs: SExpr, rhs: SExpr) -> SExpr

source

pub fn lte_many<I: IntoIterator<Item = SExpr>>(&self, items: I) -> SExpr

source

pub fn lt(&self, lhs: SExpr, rhs: SExpr) -> SExpr

source

pub fn lt_many<I: IntoIterator<Item = SExpr>>(&self, items: I) -> SExpr

source

pub fn gt(&self, lhs: SExpr, rhs: SExpr) -> SExpr

source

pub fn gt_many<I: IntoIterator<Item = SExpr>>(&self, items: I) -> SExpr

source

pub fn gte(&self, lhs: SExpr, rhs: SExpr) -> SExpr

source

pub fn gte_many<I: IntoIterator<Item = SExpr>>(&self, items: I) -> SExpr

source§

impl Context

§Array Helpers

These methods help you construct s-expressions for various array operations.

source

pub fn array_sort(&self, index: SExpr, element: SExpr) -> SExpr

Construct the array sort with the given index and element types.

source

pub fn select(&self, ary: SExpr, index: SExpr) -> SExpr

Select the element at the given index in the array.

source

pub fn store(&self, ary: SExpr, index: SExpr, value: SExpr) -> SExpr

Store the value into the given index in the array, yielding a new array.

source§

impl Context

§Bit Vector Helpers

These methods help you construct s-expressions for various bit vector operations.

source

pub fn bit_vec_sort(&self, width: SExpr) -> SExpr

Construct a BitVec sort with the given width.

source

pub fn concat(&self, lhs: SExpr, rhs: SExpr) -> SExpr

Concatenate two bit vectors.

source

pub fn extract(&self, i: i32, j: i32, bv: SExpr) -> SExpr

Extract a range from a bit vector.

source

pub fn bvnot(&self, val: SExpr) -> SExpr

source

pub fn bvor(&self, lhs: SExpr, rhs: SExpr) -> SExpr

source

pub fn bvor_many<I: IntoIterator<Item = SExpr>>(&self, items: I) -> SExpr

source

pub fn bvand(&self, lhs: SExpr, rhs: SExpr) -> SExpr

source

pub fn bvand_many<I: IntoIterator<Item = SExpr>>(&self, items: I) -> SExpr

source

pub fn bvnand(&self, lhs: SExpr, rhs: SExpr) -> SExpr

source

pub fn bvnand_many<I: IntoIterator<Item = SExpr>>(&self, items: I) -> SExpr

source

pub fn bvxor(&self, lhs: SExpr, rhs: SExpr) -> SExpr

source

pub fn bvxor_many<I: IntoIterator<Item = SExpr>>(&self, items: I) -> SExpr

source

pub fn bvxnor(&self, lhs: SExpr, rhs: SExpr) -> SExpr

source

pub fn bvxnor_many<I: IntoIterator<Item = SExpr>>(&self, items: I) -> SExpr

source

pub fn bvneg(&self, val: SExpr) -> SExpr

source

pub fn bvadd(&self, lhs: SExpr, rhs: SExpr) -> SExpr

source

pub fn bvadd_many<I: IntoIterator<Item = SExpr>>(&self, items: I) -> SExpr

source

pub fn bvsub(&self, lhs: SExpr, rhs: SExpr) -> SExpr

source

pub fn bvmul(&self, lhs: SExpr, rhs: SExpr) -> SExpr

source

pub fn bvmul_many<I: IntoIterator<Item = SExpr>>(&self, items: I) -> SExpr

source

pub fn bvudiv(&self, lhs: SExpr, rhs: SExpr) -> SExpr

source

pub fn bvurem(&self, lhs: SExpr, rhs: SExpr) -> SExpr

source

pub fn bvsrem(&self, lhs: SExpr, rhs: SExpr) -> SExpr

source

pub fn bvshl(&self, lhs: SExpr, rhs: SExpr) -> SExpr

source

pub fn bvlshr(&self, lhs: SExpr, rhs: SExpr) -> SExpr

source

pub fn bvashr(&self, lhs: SExpr, rhs: SExpr) -> SExpr

source

pub fn bvule(&self, lhs: SExpr, rhs: SExpr) -> SExpr

source

pub fn bvult(&self, lhs: SExpr, rhs: SExpr) -> SExpr

source

pub fn bvuge(&self, lhs: SExpr, rhs: SExpr) -> SExpr

source

pub fn bvugt(&self, lhs: SExpr, rhs: SExpr) -> SExpr

source

pub fn bvsle(&self, lhs: SExpr, rhs: SExpr) -> SExpr

source

pub fn bvslt(&self, lhs: SExpr, rhs: SExpr) -> SExpr

source

pub fn bvsge(&self, lhs: SExpr, rhs: SExpr) -> SExpr

source

pub fn bvsgt(&self, lhs: SExpr, rhs: SExpr) -> SExpr

Auto Trait Implementations§

§

impl !Freeze for Context

§

impl !RefUnwindSafe for Context

§

impl !Send for Context

§

impl !Sync for Context

§

impl Unpin for Context

§

impl !UnwindSafe for Context

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> 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<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.