Skip to main content

Module eqsat

Module eqsat 

Source
Expand description

The equality-saturation search service (feature eqsat, default off). See docs/design.md §10.

A bounded alternative-expression search over immutable graphs, not a phase: the host decides when (output or checkpoint boundaries, never routine maintenance), which roots, and which allowance. Admitted equations are proven, unconditional, of one width, and in the conservative fragment + − * & | ^ neg ~: identities are used in both directions, guard-free rules in their authored direction. An extracted expression is a candidate the host’s own profitability and verification gates decide to use.

use bitwright::eqsat::{SaturateConfig, Saturator, SearchRun};
use bitwright::{Context, ParseOptions, Width};

let (sat, _report) = Saturator::builtin_groups(&["eqsat.distrib"], SaturateConfig::default());
let mut cx = Context::new();
// Factoring needs distributivity backwards, which a directed simplifier never does. The
// search saturates, so the candidate is published.
let e = cx.parse("x * y + x * z", &ParseOptions::width(Width::W32))?;
let out = sat.search(&mut cx, &[e], SearchRun::default())?;
let want = cx.parse("x * (y + z)", &ParseOptions::width(Width::W32))?;
assert_eq!(out.roots[0].candidate, Some(want));

Structs§

AdmissionReport
Which rules were admitted, and why others were not.
EqsatStats
Counters for one search; unproductive search is counted, not hidden.
Fragment
The operators and widths the search accepts.
SaturateConfig
Search configuration.
Saturator
A compiled set of admitted identities and a configuration. Cheap to clone; Send + Sync.
SearchReport
The result of a search.
SearchRoot
The result for one root.
SearchRun
Options of one search.

Enums§

Publication
Whether a batch’s candidates are published.
RootEnd
How one root’s search ended.
UnsupportedPolicy
What to do with subterms outside the fragment.