Expand description
The soundness checker: evidence that every rule is a valid rewrite, and the proof ledger.
Obligation. For every width assignment satisfying the rule’s constraints at which the
pattern can match, and every value of the parameters: if the guard holds, the pattern and
the template evaluate to the same value. Guards may only talk about facts through positive
proof predicates (proves, zero_bits, one_bits, nonzero, disjoint), which are
monotone in fact precision; so evaluating them on the concrete values (the most precise
facts possible) proves the rule sound for every sound fact engine.
Evidence is derived, never declared: exhaustive enumeration over every width
assignment up to max_exhaustive_width whose parameter space fits in
max_exhaustive_bits, plus boundary-biased random sampling at wide widths, half of it
steered toward values that satisfy the guard.
This is testing, not proof: above the exhaustive widths a rule is only sampled. A verdict
of Verdict::Sound therefore requires the guard to have held in both tiers (unless
every width at which the rule applies was covered exhaustively), so a rule whose guard only
holds at unsampled values cannot pass. Proof at wide widths is the SMT export’s job.
Structs§
- Check
Config - How thoroughly to check.
- Counterexample
- Inputs on which the two sides of a rule differ.
- Evidence
- What the checker established about one rule.
- Preemption
- An instance of a rule’s pattern the engine takes elsewhere.
- Rewrite
Check Config - How thoroughly
rewritechecks. - Rewrite
Report - What a passing check covered.
- Rule
Check - The result of checking one rule.
Enums§
- Example
Failure - An
#[example("input" => "output")]that does not hold. - Preemption
Kind - What the engine does instead of a rule.
- Rewrite
Failure - Why a check failed. Expressions are shown in the expression syntax.
- Verdict
- The verdict for one rule.
Functions§
- check_
examples - Applies
ruleonce, at the root, to each of its#[example]inputs and compares the result with the expected output, both parsed with a default width of 8 bits (ascribe widths, as inp:32, for others). Guards are answered by the facts of the example’s own input. The failures, in example order. - check_
program - Checks every rule of a program, in parallel across threads.
- check_
rule - Checks one rule.
- preempted
- The rules of
programthatenginepreempts: at most one finding per rule, an instance it simplifies to something larger than the rule’s own result would simplify to (PreemptionKind::Lost, the first found), or else, when the engine applies the rule to none of the instances the rule applies to, the first of those (PreemptionKind::Shadowed).enginemust link the program’s groups. Rules for floats as values and identities the directed engine does not use are skipped. - preempted_
rule preemptedfor one rule.- rewrite
- Checks host rewrite
roninputs(text in the expression syntax): a report of what was covered, or the first failure found. The evidence a host gathers in its own test suite before it links the rewrite withEngineBuilder::trusted_rewrite.