pub struct Variable<S: ToSort = Sort>(/* private fields */);Expand description
A free variable.
Variable represents a free variable in a term that can be bound by let expressions,
quantified by forall or exists quantifiers, or bound to function parameters.
Variable objects can be created using the Variable::new() constructor or with the var! or vars! macros.
For example:
let config = Config::default();
let mut solver = Solver::new(&config)?;
solver.define(Definition::function("f", [var!(x Int)], sort!(Int), term!(* x 2)));
solver.require(term!(not (= (f 21) 42)))?;
assert_eq!(solver.check()?, Answer::No);
The Variable type is parametric in a ToSort type S used to represent the sort of the
variable, such as Sort itself or the result of the sort! macro. See the documentation of
ToSort for details.
Comparison of Variable objects is nominal, that is, equality and hashing operate on the
identity of the objects, not on their values. In other words, two Variable objects with
exactly the same fields (and in particular the same name) created by two different calls to
Variable::new() will compare different and have a possibly different hash. Moreover,
cloning a Variable object is a cheap operation and produces a second object which compares
equal to the first. Under the hood, this is the behavior of Nominal<Arc<T>> for some inner
type T, so we also refer to the Nominal type for details.
Implementations§
Trait Implementations§
impl<S: Eq + ToSort> Eq for Variable<S>
Source§impl From<Variable> for FunctionRef
impl From<Variable> for FunctionRef
impl<S: PartialEq + ToSort> StructuralPartialEq for Variable<S>
Auto Trait Implementations§
impl<S> Freeze for Variable<S>
impl<S> RefUnwindSafe for Variable<S>
impl<S> Send for Variable<S>
impl<S> Sync for Variable<S>
impl<S> Unpin for Variable<S>
impl<S> UnsafeUnpin for Variable<S>
impl<S> UnwindSafe for Variable<S>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more