SymbolicUtils.jl icon indicating copy to clipboard operation
SymbolicUtils.jl copied to clipboard

`substitute` doesn't substitute `x*z` in `x*z*k`?

Open hwpang opened this issue 3 years ago • 4 comments

I expect substitute to substitute the xz in xz*k, but it doesn't? Is there a workaround? I'm using version 0.19.7. Here's a minimal working example:

using SymbolicUtils

@syms x y z k

y = x*z*k

eq = 0.0 ~ y

println(eq.rhs) #got x*z*k
println(substitute(eq.rhs,Dict(x*z=>0))) #expecting to get 0, but got x*z*k

hwpang avatar May 04 '22 21:05 hwpang

substitute doesn't do commutative-associative matching. Have you tried to use @rule?

YingboMa avatar May 05 '22 14:05 YingboMa

I think @rule is also inadequate or annoying here... I've been thinking about this a bit and i think we need better predicates for AC operations.

shashi avatar May 06 '22 14:05 shashi

I think @rule is also inadequate or annoying here... I've been thinking about this a bit and i think we need better predicates for AC operations.

Could e-matching with Metatheory.jl help out?

0x0f0f0f avatar Mar 13 '24 14:03 0x0f0f0f

I've been thinking a lot about supporting AC operations in e-graphs.

0x0f0f0f avatar Mar 13 '24 14:03 0x0f0f0f