JuliaSymbolics/Metatheory.jl

Monoid macro in Metatheory.Library missing interpolation

schrauf opened this issue · 4 comments

Hi,

I might be wrong, but it appears the macro for defining a monoid is currently missing the interpolation ($) for it's arguments.
Right now it's currently defined like this (in src/Library.jl):

macro monoid(op, id)
    quote 
        [
            (left_associative(op)), 
            (right_associative(op)),
            (identity_left(op, id)), 
            (identity_right(op, id))
        ]
    end
end

But shouldn't it be defined as follows ?

macro monoid(op, id)
    quote 
        [
            (left_associative($op)), 
            (right_associative($op)),
            (identity_left($op, $id)), 
            (identity_right($op, $id))
        ]
    end
end

This way it rewrites expressions as intended:

m = @monoid (*) 1
expr = :(a * 1 * a * 1 * 1);
g = EGraph(expr);
saturate!(g, m);
ex = extract!(g, astsize)
# :(a * a)

BTW, fantastic package!

Thank you! Yep, you're right. You can open a MR if you want.

I can do that.

Only one thing, just to check, should I also add interpolation for the arguments in commutativity
and for the left and right variants of associative, identity, inverse and distrib?

I think yes, but I haven't tested them nor inspected them carefully.

I can do that.

Only one thing, just to check, should I also add interpolation for the arguments in commutativity and for the left and right variants of associative, identity, inverse and distrib?

I think yes, but I haven't tested them nor inspected them carefully.

Yep

#100 merged