Skip to content

@acrule only uses associativity-commutativity on the top-level operand #586

Open
@Alseidon

Description

@Alseidon

Prompted by this discussion

When using @acrule, I can't "propagate" AC to operands other than the toplevel one. In the example below, a correct factorisation rewriter would be Rewriters.Chain([factor, factor2, factor3]) where I would expect to only have to write the first rule. Maybe there is a way to circumvent this though?

using SymbolicUtils

@syms a b c
expr = a*b + b*c

factor = @acrule +(~x*~y, ~x*~z) => *(~x, ~y+~z)
factor2 = @acrule +(~y*~x, ~z*~x) => *(~x, ~y+~z)

factor(expr) # nothing
factor2(expr) # nothing

factor3 = @acrule +(~x*~y, ~z*~x) => *(~x, ~y+~z)
factor3(expr) # b*(a+c)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions