I’ve been learning about CHR recently for this purpose (egraph rewriting https://egraphs-good.github.io/ ) and I think it’s a pretty cool application. I’d be interested to hear tips about how I might make it go faster or references to prior work in this direction.