pub struct BVSolution { /* private fields */ }
Expand description

A BVSolution represents a possible solution for one BV in a given model.

Implementations

Get a string of length equal to the bitwidth, where each character in the string is either 0, 1, or x. An x indicates that, in this model, the corresponding bit can be arbitrarily chosen to be 0 or 1 and all constraints would still be satisfied.

Example
let btor = Rc::new(Btor::new());
btor.set_opt(BtorOption::ModelGen(ModelGen::All));

// `bv` starts as an unconstrained 8-bit value
let bv = BV::new(btor.clone(), 8, Some("foo"));

// assert that the first two digits of `bv` are 0
let mask = BV::from_u32(btor.clone(), 0b11000000, 8);
let zero = BV::zero(btor.clone(), 8);
bv.and(&mask)._eq(&zero).assert();

// `as_01x_str()` gives an 8-character string whose first
// two digits are '0'
assert_eq!(btor.sat(), SolverResult::Sat);
let solution = bv.get_a_solution();
assert_eq!(&solution.as_01x_str()[..2], "00");

Turn a string of 0, 1, and/or x characters into a BVSolution. See as_01x_str().

Get a version of this BVSolution that is guaranteed to correspond to exactly one possible value. For instance, as_01x_str() on the resulting BVSolution will contain no xs.

In the event that the input BVSolution did represent multiple possible values (see as_01x_str()), this will simply choose one possible value arbitrarily.

Get a u64 value for the BVSolution. In the event that this BVSolution represents multiple possible values (see as_01x_str()), this will simply choose one possible value arbitrarily.

Returns None if the value does not fit in 64 bits.

For a code example, see BV::new().

Get a bool value for the BVSolution. In the event that this BVSolution represents both true and false (see as_01x_str()), this will return false.

Returns None if the BVSolution is not a 1-bit value.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.