Skip to main content

negate_split_expr

Function negate_split_expr 

Source
pub fn negate_split_expr(expr: &PartitionExpr) -> Result<PartitionExpr>
Expand description

Rewrites NOT(expr) into an equivalent PartitionExpr without introducing a unary NOT node.

Why this function exists:

  • PartitionExpr only models binary operators.
  • Cut logic needs R AND NOT(S).
  • We therefore rewrite NOT(S) into an equivalent binary-expression tree.

Rewrite rules:

  • Atomic comparisons:
    • = <-> !=
    • < <-> >=
    • <= <-> >
    • > <-> <=
    • >= <-> <
  • Boolean composition:
    • NOT(A AND B) => NOT(A) OR NOT(B)
    • NOT(A OR B) => NOT(A) AND NOT(B)

Failure behavior:

  • For AND/OR, both sides must be Operand::Expr; otherwise returns NoExprOperand.
  • Any unsupported shape bubbles up as an error and the caller degrades to no-split.