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

issue for ematching literals

Open jaakkor2 opened this issue 3 years ago • 6 comments

Metatheory 1.3.3, SymbolicUtils 0.19.1

using SymbolicUtils
@syms x::Real
r = @rule exp(-1 * im * ~x) => cos(~x) - im*sin(~x)

gives

┌ Error: This shouldn't be printed. Report an issue for ematching literals
└ @ Metatheory.EMatchCompiler C:\Users\jaakkor2\.julia\packages\Metatheory\XcKKW\src\ematch_compiler.jl:206
┌ Error: This shouldn't be printed. Report an issue for ematching literals
└ @ Metatheory.EMatchCompiler C:\Users\jaakkor2\.julia\packages\Metatheory\XcKKW\src\ematch_compiler.jl:206
exp(-1 * im * ~x) => cos(~x) - im * sin(~x)

An earlier Issue about the rule at https://github.com/JuliaSymbolics/SymbolicUtils.jl/issues/289.

jaakkor2 avatar Jan 12 '22 16:01 jaakkor2

Seems it is an issue when building the pattern for the EGraphs backend. Will investigate ASAP.

0x0f0f0f avatar Jan 12 '22 18:01 0x0f0f0f

Seems like complex literals -1 + 0im are not e-graph friendly at the moment.

0x0f0f0f avatar Jan 12 '22 18:01 0x0f0f0f

Thanks for reporting this bug

0x0f0f0f avatar Jan 12 '22 18:01 0x0f0f0f

@jaakkor2 is the rule working as you expected?

0x0f0f0f avatar Jan 13 '22 18:01 0x0f0f0f

This works

r1 = @rule exp(im * ~x) => cos(~x) + im*sin(~x)

but this does not

r2 = @rule exp(-im * ~x) => cos(~x) - im*sin(~x)

as said in issue JuliaSymbolics/SymbolicUtils.jl#289.

jaakkor2 avatar Jan 13 '22 20:01 jaakkor2

Should have fixed the compilation bug. Not sure about the pattern matching against complex numbers. That requires a bit more investigation

0x0f0f0f avatar Jan 19 '22 09:01 0x0f0f0f

Closing as the compilation bug was fixed more than two years ago.

jaakkor2 avatar Apr 05 '24 01:04 jaakkor2