Skip to main content

Solvable

Trait Solvable 

Source
pub trait Solvable: Sized + Clone {
    type ModelInstance: Solvable;

    // Required methods
    fn read_from_model(
        &self,
        model: &Model,
        model_completion: bool,
    ) -> Option<Self::ModelInstance>;
    fn generate_constraint(&self, model: &Self::ModelInstance) -> Bool;
}
Expand description

Indicates that a type can be evaluated from a Model and produce a Bool counterexample, allowing usage in the Solver::solutions iterator pattern.

Specifically, types implementing this trait:

  • Can read a Z3 Model in a structured way to produce an instance of the type with its inner Asts constrained by the Model
  • Can generate a counter-example assertion from its internal Asts to constrain a Solver (usually just a disjunction of “not-equal“s)

Required Associated Types§

Source

type ModelInstance: Solvable

The type to be extracted from the Solver’s Model.

It will usually just be Self and must be Solvable. This is only an associated type and not just hard-coded to Self to allow for passing both owned and borrowed values into Solver::solutions, and to allow implementing this trait for types like &[T].

Required Methods§

Source

fn read_from_model( &self, model: &Model, model_completion: bool, ) -> Option<Self::ModelInstance>

Defines how to derive data derived from the implementing type (usually just a Self) and a given Model.

Usually this just invokes Model::eval on some Asts and wraps it up into the proper type.

Source

fn generate_constraint(&self, model: &Self::ModelInstance) -> Bool

Produce a Bool assertion ruling out the given model from the valuation of self.

This is used to advance the Solver in Solver::solutions. This is usually just a disjunction (in case of multiple terms) of “not equal” assertions between self and model.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<A: Solvable, B: Solvable> Solvable for (A, B)

Source§

type ModelInstance = (<A as Solvable>::ModelInstance, <B as Solvable>::ModelInstance)

Source§

fn read_from_model( &self, model: &Model, model_completion: bool, ) -> Option<Self::ModelInstance>

Source§

fn generate_constraint(&self, model: &Self::ModelInstance) -> Bool

Source§

impl<A: Solvable, B: Solvable, C: Solvable> Solvable for (A, B, C)

Source§

type ModelInstance = (<A as Solvable>::ModelInstance, <B as Solvable>::ModelInstance, <C as Solvable>::ModelInstance)

Source§

fn read_from_model( &self, model: &Model, model_completion: bool, ) -> Option<Self::ModelInstance>

Source§

fn generate_constraint(&self, model: &Self::ModelInstance) -> Bool

Source§

impl<T: Solvable + Clone, const N: usize> Solvable for [T; N]

Source§

type ModelInstance = [<T as Solvable>::ModelInstance; N]

Source§

fn read_from_model( &self, model: &Model, model_completion: bool, ) -> Option<Self::ModelInstance>

Source§

fn generate_constraint(&self, model: &Self::ModelInstance) -> Bool

Source§

impl<T: Solvable> Solvable for &[T]

Source§

type ModelInstance = Vec<<T as Solvable>::ModelInstance>

Source§

fn read_from_model( &self, model: &Model, model_completion: bool, ) -> Option<Self::ModelInstance>

Source§

fn generate_constraint(&self, model: &Self::ModelInstance) -> Bool

Source§

impl<T: Solvable> Solvable for &T

Source§

type ModelInstance = <T as Solvable>::ModelInstance

Source§

fn read_from_model( &self, model: &Model, model_completion: bool, ) -> Option<Self::ModelInstance>

Source§

fn generate_constraint(&self, model: &Self::ModelInstance) -> Bool

Source§

impl<T: Solvable> Solvable for Vec<T>

Source§

type ModelInstance = Vec<<T as Solvable>::ModelInstance>

Source§

fn read_from_model( &self, model: &Model, model_completion: bool, ) -> Option<Self::ModelInstance>

Source§

fn generate_constraint(&self, model: &Self::ModelInstance) -> Bool

Implementors§