pub struct Prepared<'c> { /* private fields */ }Expand description
A fixed family of feasibility questions. Every check requires the same Boolean facts
and binds any subset of the observations (words or predicates) to concrete values.
The family is simplified without target assumptions, blasted and encoded once.
The mutable context borrow freezes declarations and prevents rollback until the family
is dropped. A returned model is checked on the original facts and requested observations.
Unlike Incremental, each search starts with a private copy of the unsearched SAT
state: no learned clause, phase or spent budget leaks from another target. This trades
copying the clause database for target-order independent answers, even at small limits.
Preparation uses one simplify budget and one circuit cap for the whole catalog;
each target gets the configured search limits. This is not the same circuit or search
as a standalone question. If preparation returns Unknown::TooLarge, prepare a smaller
family or ask each original question separately: it says nothing about feasibility.
use bitwright::{BitVec, Context, ParseOptions, Width};
use bitwright::prove::{Config, Prepared, Simplifiers};
let mut cx = Context::new();
let o = ParseOptions::width(Width::W8);
let fact = cx.parse("x + y == 7", &o)?;
let x = cx.parse("x", &o)?;
let goal = cx.parse("y == 4", &o)?;
let cfg = Config::default().with_sweeping(false);
let mut family = Prepared::new(&mut cx, &[fact], &[x, goal], &cfg, &Simplifiers::new())?
.expect("supported family within its circuit cap");
let three = BitVec::from_u64(Width::W8, 3).unwrap();
// Is there a counterexample to `goal` under `fact` and `x == 3`?
assert_eq!(family.check(&[(0, three), (1, BitVec::from_bool(false))])?, Ok(None));
assert!(family.check(&[(0, three)])?.unwrap().is_some());Implementations§
Source§impl<'c> Prepared<'c>
impl<'c> Prepared<'c>
Sourcepub fn new(
cx: &'c mut Context,
facts: &[Expr],
observations: &[Expr],
cfg: &Config,
simplifiers: &Simplifiers,
) -> Result<Result<Self, Unknown>, Error>
pub fn new( cx: &'c mut Context, facts: &[Expr], observations: &[Expr], cfg: &Config, simplifiers: &Simplifiers, ) -> Result<Result<Self, Unknown>, Error>
Prepare exact shared predicates (use Assumptions::predicates for scoped facts)
and observed outputs, in the order used by check. Sampling, if
enabled, only finds witnesses. Certificate requests, sweeping, word sampling,
exhaustive enumeration, shared-sum rewriting and root-conditioned relational lemmas
require the ordinary Question pipeline and return Unknown::Unsupported here.
Sourcepub fn check(
&mut self,
bindings: &[(usize, BitVec)],
) -> Result<Result<Option<Model>, Unknown>, Error>
pub fn check( &mut self, bindings: &[(usize, BitVec)], ) -> Result<Result<Option<Model>, Unknown>, Error>
Whether the facts hold with observations[i] == value for every (i, value).
Ok(Some(model)) is a replayed witness; Ok(None) is unsatisfiable. An unknown
(including budget exhaustion) is not a negative answer. Indices and widths are
checked even if another binding is contradictory.