Expand description
Expression canonicalization for improved cache hit rates.
Puts TLExpr into a canonical structural form so that semantically equivalent expressions (e.g., AND(a,b) vs AND(b,a)) have identical fingerprints. This is purely structural normalization — not constant folding or algebraic simplification (those exist in separate passes).
Three canonicalization rules:
- Double negation elimination: NOT(NOT(x)) → x
- Nested same-op flattening: AND(AND(a,b), c) → AND(a, AND(b,c)) sorted
- Commutative sorting: AND/OR operands sorted by canonical_order_key
Structs§
- Canonical
Stats - Statistics from canonicalization.
- Canonicalizer
- Expression canonicalizer with configurable rules.
Functions§
- canonical_
order_ key - Compute a canonical ordering key for sorting commutative children.
- canonicalize
- Convenience function: canonicalize and return the result.