Expand description
Naive fixpoint evaluator for recursive hypergraph rules.
Builds on PR 2’s super::evaluate_rule: each iteration runs
every supplied rule once against the union of supplied base
relations and the target predicate’s currently-derived rows,
unions new rows into the derived set, sorts and deduplicates,
and stops when an iteration produces zero new rows.
Pure-Rust, deterministic, set-semantics. Built to be the recursive-WCOJ correctness oracle for PR 4+ mixed-execution kernels. Not optimized — a real engine would use semi-naive delta-driven evaluation; this slice prefers simplicity over speed.
§Algorithm
- Validate that every supplied rule’s head predicate equals the target. (The slice ships single-predicate fixpoint; multi-predicate SCCs are a later concern.)
- Compute the target relation’s schema by inferring per-vertex
types from the first iteration’s evaluation: each rule
head’s term shape gives an arity; every cell’s
RefValuevariant gives a [ScalarType]. The first iteration that produces non-empty rows freezes the schema. - Loop up to
max_iterationstimes: a. For each rule, runsuper::evaluate_ruleagainstbase_relations ∪ {target → derived}. Union new rows into a per-iteration scratch buffer. b. Merge scratch intoderived, sort+dedupe. c. Ifderivedis unchanged this iteration, return. d. Otherwise increment the iteration counter and continue. - If the loop exits without convergence, return
FixpointError::MaxIterationsExceeded.
§Schema seeding
On iteration 1, rules referencing the target predicate would
ordinarily fail with RefEvalError::MissingRelation. The
evaluator pre-seeds an empty target relation whose schema is
taken from the head arity of the first rule with a non-empty
head. Once a real iteration produces tuples the schema is
frozen against per-cell variant types — drift in later
iterations surfaces as a
RefEvalError::RelationValueTypeMismatch from PR 2’s
validation.
Structs§
- Fixpoint
Config - Configuration for
evaluate_fixpoint.
Enums§
- Fixpoint
Error - Errors surfaced by
evaluate_fixpoint.
Functions§
- evaluate_
fixpoint - Evaluate a recursive set of rules to a fixpoint over a single target predicate.