BooleanOptimizer

scalus.sir.BooleanOptimizer

Provides optimization functionality for boolean expressions in SIR. Applies standard boolean algebra transformations to reduce the number of nodes and simplify expressions.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

def optimize(sir: SIR): SIR

Optimizes boolean expressions in SIR by applying various boolean algebra laws.

Optimizes boolean expressions in SIR by applying various boolean algebra laws.

Implemented optimizations:

  • Double negation elimination: Not(Not(a)) => a
  • Reverse De Morgan's laws (reduces node count):
    • Or(Not(a), Not(b)) => Not(And(a, b))
    • And(Not(a), Not(b)) => Not(Or(a, b))
  • Negation of conditionals: If(Not(cond), t, f) => If(cond, f, t)
  • Constant folding for boolean operations
  • Identity and annihilation properties
  • Idempotent operations
  • Complementation law

Value parameters

sir

The SIR expression to optimize

Attributes

Returns

The optimized SIR expression