Skip to main content

normalise_evaluator_local

Function normalise_evaluator_local 

Source
pub fn normalise_evaluator_local(expr: &Expression) -> Option<Expression>
Expand description

Applies the evaluator normalisation hook to a focused expression.

Evaluators are privileged simplifications, not ordinary rewrite rules. The rewriter invokes this hook before normal rule scheduling and immediately after a successful ordinary rule, walking upward while evaluation keeps simplifying parents. This exploits the semantic property that local constant and partial evaluation is always preferable to trying lower-priority rules, while avoiding millions of failed universal constant_evaluator rule attempts.

Away from Expr::Root, the hook is pure and local: it does not create auxiliaries, mutate the symbol table, or recursively inspect arbitrary descendants. Children are expected to have been normalised by the scheduler before their parent is evaluated.

At Expr::Root, a selective deep pass runs over top-level constraints (skipping solver-flat forms). Callers that know which root child changed should prefer normalise_root_selective_deep_expr with only_constraint so sibling constraints are not re-traversed. Local root-list reshaping (flatten top-level and) is intentionally deferred to finish_root_evaluator_normalisation: doing it mid-loop materialises huge root lists and explodes worklist rule attempts.