AlgebraicJulia / AlgebraicRewriting.jl

Implementations of algebraic rewriting techniques like DPO, SPO, SqPO.
https://algebraicjulia.github.io/AlgebraicRewriting.jl/
MIT License
25 stars 5 forks source link

Rewriting every matching pattern in a graph #9

Closed GeorgeR227 closed 8 months ago

GeorgeR227 commented 2 years ago

So I'm running into a problem where I want to rewrite all of the matching patterns in this graph: original

This is the pattern that I'm matching for: match

And this is the rewrite pattern, with equivalence on the respective, outermost nodes on the matching pattern and edges discarded: sub

After the first rewrite, the graph looks like this: rewrite1

But when I apply it for a second time, it performs it in the same place: rewrite2 Instead I would want into to perform it on the other two original patterns before it finishes.

What would be the best way to complete this kind of total rewrite?

anandijain commented 1 year ago

Yeah, I'm also running into this. My very primitive understanding is that the matching only seems to happen when vertex ids line up. If you want some very bad code that will handle this, see https://github.com/anandijain/HypergraphRewriting.jl/blob/main/test/runtests.jl I'm almost sure that your case will work with HR.jl

I very much want to rewrite this package to use Algebraic Julia machinery, but this may be sufficient for the time being

kris-brown commented 8 months ago

This is now addressed by Query blocks in a rewriting recipe. See examples in the docs (Game of Life, Lotka Volterra) or in test/schedules/Eval.jl though I'll be working on actual docs (rather than just examples) in the future!