pub struct BV { /* private fields */ }Expand description
Ast node representing a bitvector value.
Implementations§
Source§impl BV
impl BV
pub fn from_str(sz: u32, value: &str) -> Option<BV>
Sourcepub fn from_bits(bits: &[bool]) -> Option<BV>
pub fn from_bits(bits: &[bool]) -> Option<BV>
Create a BV from an array of bits.
§Examples
// 0b00000010
let bv = BV::from_bits(&[false, true, false, false, false, false, false, false]).unwrap();
let bv_none = BV::from_bits(&[]);
assert_eq!(bv, 2);
assert_eq!(bv_none, None);pub fn new_const<S: Into<Symbol>>(name: S, sz: u32) -> BV
pub fn fresh_const(prefix: &str, sz: u32) -> BV
pub fn from_i64(i: i64, sz: u32) -> BV
pub fn from_u64(u: u64, sz: u32) -> BV
pub fn as_i64(&self) -> Option<i64>
pub fn as_u64(&self) -> Option<u64>
Sourcepub fn from_int(ast: &Int, sz: u32) -> BV
pub fn from_int(ast: &Int, sz: u32) -> BV
Create a bit vector from an integer.
The bit vector will have width sz.
§Examples
let i = ast::Int::new_const("x");
solver.assert(&i.eq(&ast::Int::from_i64(-3)));
let x = ast::BV::from_int(&i, 64);
assert_eq!(64, x.get_size());
assert_eq!(solver.check(), SatResult::Sat);
let model = solver.get_model().unwrap();
assert_eq!(-3, model.eval(&x.to_int(true), true).unwrap().as_i64().expect("as_i64() shouldn't fail"));Sourcepub fn to_int(&self, signed: bool) -> Int
pub fn to_int(&self, signed: bool) -> Int
Create an integer from a bitvector.
This is just a convenience wrapper around
Int::from_bv(); see notes there.
Sourcepub fn bvredand(&self) -> Self
pub fn bvredand(&self) -> Self
Conjunction of all the bits in the vector. Returns a BV with size (bitwidth) 1.
Sourcepub fn bvredor(&self) -> Self
pub fn bvredor(&self) -> Self
Disjunction of all the bits in the vector. Returns a BV with size (bitwidth) 1.
Sourcepub fn bvsrem<T: IntoAst<Self>>(&self, other: T) -> Self
pub fn bvsrem<T: IntoAst<Self>>(&self, other: T) -> Self
Signed remainder (sign follows dividend)
Sourcepub fn bvsmod<T: IntoAst<Self>>(&self, other: T) -> Self
pub fn bvsmod<T: IntoAst<Self>>(&self, other: T) -> Self
Signed remainder (sign follows divisor)
Sourcepub fn bvlshr<T: IntoAst<Self>>(&self, other: T) -> Self
pub fn bvlshr<T: IntoAst<Self>>(&self, other: T) -> Self
Logical shift right (add zeroes in the high bits)
Sourcepub fn bvashr<T: IntoAst<Self>>(&self, other: T) -> Self
pub fn bvashr<T: IntoAst<Self>>(&self, other: T) -> Self
Arithmetic shift right (sign-extend in the high bits)
Sourcepub fn bvneg_no_overflow(&self) -> Bool
pub fn bvneg_no_overflow(&self) -> Bool
Check if negation overflows
Sourcepub fn bvadd_no_overflow(&self, other: &BV, b: bool) -> Bool
pub fn bvadd_no_overflow(&self, other: &BV, b: bool) -> Bool
Check if addition overflows
Sourcepub fn bvsub_no_underflow(&self, other: &BV, b: bool) -> Bool
pub fn bvsub_no_underflow(&self, other: &BV, b: bool) -> Bool
Check if subtraction underflows
Sourcepub fn bvmul_no_overflow(&self, other: &BV, b: bool) -> Bool
pub fn bvmul_no_overflow(&self, other: &BV, b: bool) -> Bool
Check if multiplication overflows
Sourcepub fn bvadd_no_underflow<T: IntoAst<Self>>(&self, other: T) -> Bool
pub fn bvadd_no_underflow<T: IntoAst<Self>>(&self, other: T) -> Bool
Check if addition underflows
Sourcepub fn bvsub_no_overflow<T: IntoAst<Self>>(&self, other: T) -> Bool
pub fn bvsub_no_overflow<T: IntoAst<Self>>(&self, other: T) -> Bool
Check if subtraction overflows
Sourcepub fn bvsdiv_no_overflow<T: IntoAst<Self>>(&self, other: T) -> Bool
pub fn bvsdiv_no_overflow<T: IntoAst<Self>>(&self, other: T) -> Bool
Check if signed division overflows
Sourcepub fn bvmul_no_underflow<T: IntoAst<Self>>(&self, other: T) -> Bool
pub fn bvmul_no_underflow<T: IntoAst<Self>>(&self, other: T) -> Bool
Check if multiplication underflows
Sourcepub fn extract(&self, high: u32, low: u32) -> Self
pub fn extract(&self, high: u32, low: u32) -> Self
Extract the bits high down to low from the bitvector.
Returns a bitvector of size n, where n = high - low + 1.
Source§impl BV
impl BV
pub fn ast_eq<T: IntoAst<Self>>(&self, other: T) -> boolwhere
Self: Sized,
pub fn _eq<T: IntoAst<Self>>(&self, other: T) -> Boolwhere
Self: Sized,
Please use eq instead
pub fn ne<T: IntoAst<Self>>(&self, other: T) -> Boolwhere
Self: Sized,
Sourcepub fn eq<T: IntoAst<Self>>(&self, other: T) -> Boolwhere
Self: Sized,
pub fn eq<T: IntoAst<Self>>(&self, other: T) -> Boolwhere
Self: Sized,
Compare this Ast with another Ast, and get a Bool
representing the result.
This operation works with all possible Asts (int, real, BV, etc), but the two
Asts being compared must be the same type.
pub fn _safe_eq<T: IntoAst<Self>>(&self, other: T) -> Result<Bool, SortDiffers>where
Self: Sized,
Please use safe_eq instead
Trait Implementations§
Source§impl<T: IntoAst<BV>> AddAssign<T> for BV
impl<T: IntoAst<BV>> AddAssign<T> for BV
Source§fn add_assign(&mut self, rhs: T)
fn add_assign(&mut self, rhs: T)
+= operation. Read moreSource§impl Ast for BV
impl Ast for BV
fn eq<T: IntoAst<Self>>(&self, other: T) -> Boolwhere
Self: Sized,
fn ne<T: IntoAst<Self>>(&self, other: T) -> Boolwhere
Self: Sized,
fn get_ctx(&self) -> &Context
fn get_z3_ast(&self) -> Z3_ast
Source§fn simplify(&self) -> Selfwhere
Self: Sized,
fn simplify(&self) -> Selfwhere
Self: Sized,
Ast. Returns a new Ast which is equivalent,
but simplified using algebraic simplification rules, such as
constant propagation.Source§fn substitute<T: Ast>(&self, substitutions: &[(&T, &T)]) -> Selfwhere
Self: Sized,
fn substitute<T: Ast>(&self, substitutions: &[(&T, &T)]) -> Selfwhere
Self: Sized,
Ast. The slice substitutions contains a
list of pairs with a “from” Ast that will be substituted by a “to” Ast.Source§fn num_children(&self) -> usize
fn num_children(&self) -> usize
Ast. Read morefn safe_decl(&self) -> Result<FuncDecl, IsNotApp>
fn check_ctx(&self, ctx: &Context)
Source§impl<T: IntoAst<BV>> BitAndAssign<T> for BV
impl<T: IntoAst<BV>> BitAndAssign<T> for BV
Source§fn bitand_assign(&mut self, rhs: T)
fn bitand_assign(&mut self, rhs: T)
&= operation. Read moreSource§impl<T: IntoAst<BV>> BitOrAssign<T> for BV
impl<T: IntoAst<BV>> BitOrAssign<T> for BV
Source§fn bitor_assign(&mut self, rhs: T)
fn bitor_assign(&mut self, rhs: T)
|= operation. Read moreSource§impl<T: IntoAst<BV>> BitXorAssign<T> for BV
impl<T: IntoAst<BV>> BitXorAssign<T> for BV
Source§fn bitxor_assign(&mut self, rhs: T)
fn bitxor_assign(&mut self, rhs: T)
^= operation. Read moreSource§impl<T: IntoAst<BV>> MulAssign<T> for BV
impl<T: IntoAst<BV>> MulAssign<T> for BV
Source§fn mul_assign(&mut self, rhs: T)
fn mul_assign(&mut self, rhs: T)
*= operation. Read moreSource§impl<T: IntoAst<BV>> ShlAssign<T> for BV
impl<T: IntoAst<BV>> ShlAssign<T> for BV
Source§fn shl_assign(&mut self, rhs: T)
fn shl_assign(&mut self, rhs: T)
<<= operation. Read moreSource§impl Solvable for BV
impl Solvable for BV
Source§fn read_from_model(
&self,
model: &Model,
model_completion: bool,
) -> Option<Self::ModelInstance>
fn read_from_model( &self, model: &Model, model_completion: bool, ) -> Option<Self::ModelInstance>
Source§fn generate_constraint(&self, model: &Self::ModelInstance) -> Bool
fn generate_constraint(&self, model: &Self::ModelInstance) -> Bool
Source§impl<T: IntoAst<BV>> SubAssign<T> for BV
impl<T: IntoAst<BV>> SubAssign<T> for BV
Source§fn sub_assign(&mut self, rhs: T)
fn sub_assign(&mut self, rhs: T)
-= operation. Read more