Skip to main content

Module fixpoint

Module fixpoint 

Source
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

  1. Validate that every supplied rule’s head predicate equals the target. (The slice ships single-predicate fixpoint; multi-predicate SCCs are a later concern.)
  2. 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 RefValue variant gives a [ScalarType]. The first iteration that produces non-empty rows freezes the schema.
  3. Loop up to max_iterations times: a. For each rule, run super::evaluate_rule against base_relations ∪ {target → derived}. Union new rows into a per-iteration scratch buffer. b. Merge scratch into derived, sort+dedupe. c. If derived is unchanged this iteration, return. d. Otherwise increment the iteration counter and continue.
  4. 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§

FixpointConfig
Configuration for evaluate_fixpoint.

Enums§

FixpointError
Errors surfaced by evaluate_fixpoint.

Functions§

evaluate_fixpoint
Evaluate a recursive set of rules to a fixpoint over a single target predicate.