[−][src]Struct boolector::Array
An Array
in Boolector is really just a map from BV
s to BV
s.
Like BV
, Array
is generic in the Btor
reference type.
For instance, you could use Array<Rc<Btor>>
for single-threaded applications,
or Array<Arc<Btor>>
for multi-threaded applications.
Methods
impl<R: AsRef<Btor> + Clone> Array<R>
[src]
pub fn new(
btor: R,
index_width: u32,
element_width: u32,
symbol: Option<&str>
) -> Self
[src]
btor: R,
index_width: u32,
element_width: u32,
symbol: Option<&str>
) -> Self
Create a new Array
which maps BV
s of width index_width
to BV
s of
width element_width
. All values in the Array
will be unconstrained.
The symbol
, if present, will be used to identify the Array
when printing
a model or dumping to file. It must be unique if it is present.
Example
let btor = Rc::new(Btor::new()); // `arr` is an `Array` which maps 8-bit values to 8-bit values let arr = Array::new(btor.clone(), 8, 8, Some("arr")); // Write the value `3` to array index `7` let three = BV::from_u32(btor.clone(), 3, 8); let seven = BV::from_u32(btor.clone(), 7, 8); let arr2 = arr.write(&seven, &three); // Read back out the resulting value let read_bv = arr2.read(&seven); // should be the value `3` assert_eq!(read_bv.as_u64().unwrap(), 3);
pub fn new_initialized(
btor: R,
index_width: u32,
element_width: u32,
symbol: Option<&str>,
val: &BV<R>
) -> Self
[src]
btor: R,
index_width: u32,
element_width: u32,
symbol: Option<&str>,
val: &BV<R>
) -> Self
Create a new Array
which maps BV
s of width index_width
to BV
s of
width element_width
. The Array
will be initialized so that all
indices map to the same constant value val
.
The symbol
, if present, will be used to identify the Array
when
printing a model or dumping to file. It must be unique if it is present.
Note: This function is not available in Boolector 3.0.0 as released, and
will cause linker errors if you attempt to use it with the released
version of Boolector 3.0.0. It was added to Boolector's git master in
September 2019 (commit a1b1408
), and will presumably be part of any
subsequent releases of Boolector. Until the next Boolector release, to
use this function you will need to build an appropriately recent version
of Boolector from source.
Example
let btor = Rc::new(Btor::new()); btor.set_opt(BtorOption::ModelGen(ModelGen::All)); btor.set_opt(BtorOption::Incremental(true)); // `arr` is an `Array` which maps 8-bit values to 8-bit values. // It is initialized such that all entries are the constant `42`. let fortytwo = BV::from_u32(btor.clone(), 42, 8); let arr = Array::new_initialized(btor.clone(), 8, 8, Some("arr"), &fortytwo); // Reading the value at any index should produce `42`. let read_bv = arr.read(&BV::from_u32(btor.clone(), 61, 8)); assert_eq!(btor.sat(), SolverResult::Sat); assert_eq!(read_bv.get_a_solution().as_u64().unwrap(), 42); // Write the value `3` to array index `7` let three = BV::from_u32(btor.clone(), 3, 8); let seven = BV::from_u32(btor.clone(), 7, 8); let arr2 = arr.write(&seven, &three); // Read back out the value at index `7`. It should be `3`. let read_bv = arr2.read(&seven); assert_eq!(read_bv.as_u64().unwrap(), 3); // Reading the value at any other index should still produce `42`. let read_bv = arr2.read(&BV::from_u32(btor.clone(), 99, 8)); assert_eq!(btor.sat(), SolverResult::Sat); //assert_eq!(read_bv.get_a_solution().as_u64().unwrap(), 42);
pub fn get_index_width(&self) -> u32
[src]
Get the bitwidth of the index type of the Array
pub fn get_element_width(&self) -> u32
[src]
Get the bitwidth of the element type of the Array
pub fn get_symbol(&self) -> Option<&str>
[src]
Get the symbol of the Array
, if one was assigned
pub fn is_const(&self) -> bool
[src]
Does the Array
have a constant value?
pub fn has_same_widths(&self, other: &Self) -> bool
[src]
Does self
have the same index and element widths as other
?
pub fn _eq(&self, other: &Self) -> Self
[src]
Array equality. self
and other
must have the same index and element widths.
pub fn _ne(&self, other: &Self) -> Self
[src]
Array inequality. self
and other
must have the same index and element widths.
pub fn read(&self, index: &BV<R>) -> BV<R>
[src]
Array read: get the value in the Array
at the given index
pub fn write(&self, index: &BV<R>, value: &BV<R>) -> Self
[src]
Array write: return a new Array
which has value
at position index
,
and all other elements unchanged.
Trait Implementations
impl<R: AsRef<Btor> + Clone + Sync> Sync for Array<R>
[src]
impl<R: Eq + AsRef<Btor> + Clone> Eq for Array<R>
[src]
impl<R: AsRef<Btor> + Clone> Drop for Array<R>
[src]
impl<R: AsRef<Btor> + Clone + Send> Send for Array<R>
[src]
impl<R: AsRef<Btor> + Clone> Clone for Array<R>
[src]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<R: PartialEq + AsRef<Btor> + Clone> PartialEq<Array<R>> for Array<R>
[src]
impl<R: AsRef<Btor> + Clone> Debug for Array<R>
[src]
Auto Trait Implementations
impl<R> Unpin for Array<R> where
R: Unpin,
R: Unpin,
impl<R> UnwindSafe for Array<R> where
R: UnwindSafe,
R: UnwindSafe,
impl<R> RefUnwindSafe for Array<R> where
R: RefUnwindSafe,
R: RefUnwindSafe,
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,