Expand description
A native prover (feature prove): expressions are bit-blasted into an and-inverter graph,
encoded as clauses, and decided by bitwright’s own CDCL SAT solver. A proof of validity comes
with a certificate, the clauses and a DRUP proof of their unsatisfiability, that an
independent checker (Certificate::check) verifies, and that any DRAT checker can read
(Certificate::dimacs, Certificate::drat). A refutation comes with a counterexample:
a value for every symbol, checked by bitwright’s evaluator before it is returned. A question
the search does not settle within its budget says why (Unknown), and a Question
goes on from where the search stopped, under a larger budget, without starting over.
For a small joint output superset above unresolved predicates, domain::analyze
preserves shared Boolean structure under explicit premises without solving reachability.
No other solver is involved. Bit-vector operators are blasted with bitwright’s total
semantics (SMT-LIB’s); floating-point operators with IEEE 754’s and bitwright’s canonical
NaN (crate::fp); extension operations through their expand
definition, if they have one (otherwise the question is not decided).
use bitwright::prove::{Config, Outcome, equal};
use bitwright::{Context, ParseOptions, Width};
let mut cx = Context::new();
let o = ParseOptions::width(Width::W32);
let (a, b) = (cx.parse("(x ^ y) + 2 * (x & y)", &o)?, cx.parse("x + y", &o)?);
let Outcome::Proved(Some(cert)) = equal(&mut cx, a, b, &Config::default().with_certificate(true))? else {
panic!("not proved")
};
assert!(cert.check().is_ok());
let c = cx.parse("x | y", &o)?;
assert!(matches!(equal(&mut cx, a, c, &Config::default())?, Outcome::Refuted(_)));Re-exports§
Modules§
- aig
- An and-inverter graph: every gate a conjunction of two literals, negation free on the
edges, with constant folding, trivial simplifications (
a ∧ a,a ∧ ¬a) and structural hashing, so equal subcircuits are one gate. Clauses are generated (Tseitin) only for the gates a goal reaches. - blast
- Bit-blasting: every bit-vector operator as a circuit over the bits of its operands, with bitwright’s total semantics (SMT-LIB’s): division by zero, shifts past the width, rotations by any count. Bits are little-endian.
- domain
- Bounded joint output supersets above expensive Boolean predicates.
- drup
- A forward checker for DRUP proofs: every added clause must follow from the clauses present before it by reverse unit propagation (assigning its literals false and propagating gives a conflict), deleted clauses leave the database, and the proof must add the empty clause. It shares no code with the solver: its own watched-literal propagation over its own database, so a solver bug cannot vouch for itself.
- finite
- Optional, exhaustively checked finite-domain facts for keyed integer pairs.
- lrat
- LRAT: a proof of unsatisfiability in which every added clause names the clauses it follows from, in the order unit propagation uses them, so that a checker does no search at all.
- sat
- A conflict-driven clause-learning SAT solver: two watched literals with blockers, VSIDS
decisions with phase saving, first-UIP learning with recursive minimization, Luby restarts,
and a learned-clause database reduced by literal block distance. Every learned clause is a
reverse-unit-propagation (RUP) consequence of the clauses before it, so the solver can log
a DRUP proof (additions and deletions) that
super::drupchecks independently.
Structs§
- Certificate
- Clauses and a DRUP proof that they are unsatisfiable, or, for a proof by complete
enumeration (
Config::exhaustive_inputs), the circuit to enumerate. - Config
- How hard to try, and what to keep.
- Exhaustion
- A circuit and the claim that its goal holds wherever its constraints do, at every assignment of its inputs.
- Incremental
- A circuit and a SAT search that outlive a question: each predicate asked about is added to the circuit once, its clauses to the search once, and what the search learns stays, so a sequence of related questions (a path condition that grows, a query against one) costs what is new in each.
- Question
- A question, blasted and encoded once, then decided in as many steps as its caller likes: a
search that ends on its limits stops where it is, keeping what it learned, and the next
solvegoes on from there. Asking under 5,000 conflicts, then 15,000 more, costs what asking under 20,000 once does, and answers the same. - Simplification
- What simplifying a question with bitwright’s own engine took (
Config::simplify). - Simplifiers
- The engines that simplify questions (see
Config::simplify), owned by whoever asks: the deobfuscation strategy with the MBA service, built when first needed, and with them the one thing they remember, the MBA solver’s memo. The entry points of this module that take none use one such set for the process; a caller that wants nothing shared with the rest of the process (its statistics, its memory) makes its own and asks throughQuestion::valid_under_with,valid_under_withor abatch::Session, which owns one. Answers are the same either way: the solver’s memo returns what solving again would, at the same cost. - Stats
- The work a question took, so far. Every count is of work done, not of time, and the same on every run: a question asked the same way (in a context with the same history) reports the same numbers, and the totals of one resumed in steps are those of one asked at once.
- Sweeping
- What sweeping a question’s circuit did (
Config::sweeping). - Width
Report - A rule at every width up to a bound (see
rule_all_widths).
Enums§
- Incremental
Answer - What an
Incrementalanswers. What anIncrementalanswers. - Outcome
- The answer to a question.
- Rule
Outcome - The answer for a rule at one assignment.
- Sample
Mode - How assignments are selected before SAT search. Sampling can find a concrete counterexample. Complete ordered enumeration on the word path can also prove validity; partial coverage and pseudorandom samples cannot.
- Unknown
- Why a question is not decided.
Functions§
- equal
- Whether
aandb(of one width) are equal for every value of their symbols agreeing with their declared known bits. - lean_
theorem - The claim that the 1-bit
predicatesdo not hold together, as a Lean 4 theorem overBitVecwith the proofby bv_decide: a fileleanchecks on its own, with nothing of bitwright in what it trusts.commentis written above the theorem (how the claim was reached, say). - rule
- Proves
ruleatwidths(the width variables’ values, then each mode variable’s index inRoundingMode::ALL). When the solver runs out of conflicts and the rule hasconstparameters, the proof is split into the values of those the guard admits (found by the solver, each blocked once proved), each proved with the parameters fixed, which folds their circuits (a division by a constant), up to 8,192 of them. - rule_
all_ widths - Proves
ruleat every admitted assignment whose widths are at mostmax_width(every width variable), smallest first, stopping at the first refutation; and, for a rule whose shape makes width irrelevant, at every width at once. - satisfy
- A value of the symbols that makes the 1-bit
ptrue, if there is one:Refutedof¬pread back as a model (Ok(Some)),Ok(None)whenpis unsatisfiable, andErrwith the reason when not decided. - simplified
pas the prover’s simplifier leaves it withinConfig::simplify_budget: an expression equal topat every value of the symbols, which is what the prover builds its circuit of. Asked again of an expression a question was posed about, it costs a lookup.- valid
- Whether the 1-bit
pis true for every value of its symbols agreeing with their declared known bits. - valid_
under - Whether
pis true wherever the constraints ofassumptionsand the symbols’ declared known bits hold. - valid_
under_ with valid_under, simplified by the caller’s engines and not the process’s (Simplifiers): the same answer.
Type Aliases§
- Model
- Values of symbols, as a counterexample or a model gives them.