pub struct NativeProver { /* private fields */ }Expand description
bitwright’s own exact equivalence checks as an EquivalenceProver: the refutation sample,
then the cheapest certificate that applies (the corner signature, single bit positions, at
most d bit positions for degree d, the pure-polynomial grid, exhaustive evaluation; equal
polynomials over symbols first where that test would take far longer), over abstracted
atoms when a side leaves the polynomial fragment. The same checks are the evidence gate’s
own, so an engine needs this prover only when its host uses the MBA module directly.
Work is counted in node evaluations against MbaBudget::steps, the symbolic comparison
at 256 per monomial operation (what one costs) and within what is left; a certificate over
the budget is not run, and one stopped by it is not finished (Unknown). Refuted comes
with a concrete counterexample.
use bitwright::mba::{EquivalenceProver, MOp, MbaBudget, MbaExpr, NativeProver, Verdict};
use bitwright::Width;
// (x & y)·(x | y) + (x & ~y)·(~x & y) == x·y, a degree-2 identity, at 64 bits: the same
// polynomial over x, y and x & y, so it takes none of the degree-2 test's 18,337 points.
let w = Width::W64;
let mut a = MbaExpr::new(vec![w, w]);
let (x, y) = (a.push(MOp::Var(0), &[])?, a.push(MOp::Var(1), &[])?);
let (and, or) = (a.push(MOp::And, &[x, y])?, a.push(MOp::Or, &[x, y])?);
let p = a.push(MOp::Mul, &[and, or])?;
let (nx, ny) = (a.push(MOp::Not, &[x])?, a.push(MOp::Not, &[y])?);
let (l, r) = (a.push(MOp::And, &[x, ny])?, a.push(MOp::And, &[nx, y])?);
let q = a.push(MOp::Mul, &[l, r])?;
a.push(MOp::Add, &[p, q])?;
let mut b = MbaExpr::new(vec![w, w]);
let (x, y) = (b.push(MOp::Var(0), &[])?, b.push(MOp::Var(1), &[])?);
b.push(MOp::Mul, &[x, y])?;
let prover = NativeProver::default();
assert_eq!(prover.prove_equal(&a, &b, &MbaBudget::default()), Verdict::Proved);
assert_eq!((prover.stats().symbolic, prover.stats().sparse), (1, 0));