Struct Sort

Source
pub struct Sort<'ctx> { /* private fields */ }
Expand description

Sorts represent the various ‘types’ of Asts.

Implementations§

Source§

impl<'ctx> Sort<'ctx>

Source

pub fn uninterpreted(ctx: &'ctx Context, name: Symbol) -> Sort<'ctx>

Source

pub fn bool(ctx: &'ctx Context) -> Sort<'ctx>

Source

pub fn int(ctx: &'ctx Context) -> Sort<'ctx>

Source

pub fn real(ctx: &'ctx Context) -> Sort<'ctx>

Source

pub fn float(ctx: &'ctx Context, ebits: u32, sbits: u32) -> Sort<'ctx>

Source

pub fn float32(ctx: &'ctx Context) -> Sort<'ctx>

Source

pub fn double(ctx: &'ctx Context) -> Sort<'ctx>

Source

pub fn string(ctx: &'ctx Context) -> Sort<'ctx>

Source

pub fn bitvector(ctx: &'ctx Context, sz: u32) -> Sort<'ctx>

Source

pub fn array( ctx: &'ctx Context, domain: &Sort<'ctx>, range: &Sort<'ctx>, ) -> Sort<'ctx>

Source

pub fn set(ctx: &'ctx Context, elt: &Sort<'ctx>) -> Sort<'ctx>

Source

pub fn enumeration( ctx: &'ctx Context, name: Symbol, enum_names: &[Symbol], ) -> (Sort<'ctx>, Vec<FuncDecl<'ctx>>, Vec<FuncDecl<'ctx>>)

Create an enumeration sort.

Creates a Z3 enumeration sort with the given name. The enum variants will have the names in enum_names. Three things are returned:

  • the created Sort,
  • constants to create the variants,
  • and testers to check if a value is equal to a variant.
§Examples
let (colors, color_consts, color_testers) = Sort::enumeration(
    &ctx,
    "Color".into(),
    &[
        "Red".into(),
        "Green".into(),
        "Blue".into(),
    ],
);

let red_const = color_consts[0].apply(&[]);
let red_tester = &color_testers[0];
let eq = red_tester.apply(&[&red_const]);

assert_eq!(solver.check(), SatResult::Sat);
let model = solver.get_model().unwrap();;

assert!(model.eval(&eq, true).unwrap().as_bool().unwrap().as_bool().unwrap());
Source

pub fn kind(&self) -> SortKind

Source

pub fn float_exponent_size(&self) -> Option<u32>

Returns Some(e) where e is the number of exponent bits if the sort is a FloatingPoint and None otherwise.

Source

pub fn float_significand_size(&self) -> Option<u32>

Returns Some(s) where s is the number of significand bits if the sort is a FloatingPoint and None otherwise.

Source

pub fn is_array(&self) -> bool

Return if this Sort is for an Array or a Set.

§Examples
let bool_sort = Sort::bool(&ctx);
let int_sort = Sort::int(&ctx);
let array_sort = Sort::array(&ctx, &int_sort, &bool_sort);
let set_sort = Sort::set(&ctx, &int_sort);
assert!(array_sort.is_array());
assert!(set_sort.is_array());
assert!(!int_sort.is_array());
assert!(!bool_sort.is_array());
Source

pub fn array_domain(&self) -> Option<Sort<'_>>

Return the Sort of the domain for Arrays of this Sort.

If this Sort is an Array or Set, it has a domain sort, so return it. If this is not an Array or Set Sort, return None.

§Examples
let bool_sort = Sort::bool(&ctx);
let int_sort = Sort::int(&ctx);
let array_sort = Sort::array(&ctx, &int_sort, &bool_sort);
let set_sort = Sort::set(&ctx, &int_sort);
assert_eq!(array_sort.array_domain().unwrap(), int_sort);
assert_eq!(set_sort.array_domain().unwrap(), int_sort);
assert!(int_sort.array_domain().is_none());
assert!(bool_sort.array_domain().is_none());
Source

pub fn array_range(&self) -> Option<Sort<'_>>

Return the Sort of the range for Arrays of this Sort.

If this Sort is an Array it has a range sort, so return it. If this Sort is a Set, it has an implied range sort of Bool. If this is not an Array or Set Sort, return None.

§Examples
let bool_sort = Sort::bool(&ctx);
let int_sort = Sort::int(&ctx);
let array_sort = Sort::array(&ctx, &int_sort, &bool_sort);
let set_sort = Sort::set(&ctx, &int_sort);
assert_eq!(array_sort.array_range().unwrap(), bool_sort);
assert_eq!(set_sort.array_range().unwrap(), bool_sort);
assert!(int_sort.array_range().is_none());
assert!(bool_sort.array_range().is_none());

Trait Implementations§

Source§

impl<'ctx> Clone for Sort<'ctx>

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'ctx> Debug for Sort<'ctx>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'ctx> Display for Sort<'ctx>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'ctx> Drop for Sort<'ctx>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<'ctx> PartialEq for Sort<'ctx>

Source§

fn eq(&self, other: &Sort<'ctx>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'ctx> Eq for Sort<'ctx>

Auto Trait Implementations§

§

impl<'ctx> Freeze for Sort<'ctx>

§

impl<'ctx> RefUnwindSafe for Sort<'ctx>

§

impl<'ctx> !Send for Sort<'ctx>

§

impl<'ctx> !Sync for Sort<'ctx>

§

impl<'ctx> Unpin for Sort<'ctx>

§

impl<'ctx> UnwindSafe for Sort<'ctx>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

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>,

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.