If, like me, you have never heard of e-graphs, this takes you straight to an introduction:<p><a href="https://docs.rs/egg/0.6.0/egg/tutorials/_01_background/index.html" rel="nofollow">https://docs.rs/egg/0.6.0/egg/tutorials/_01_background/index...</a>
Glad to see this getting play on here. Egg presents a very compelling algorithm and library for equational reasoning over syntax trees that I've been pretty fascinated with over the past couple months.<p>These e-graph data structures are in the heart of SMT solvers but giving easier access to end users and specializing the algorithm to the different needs of optimizing rewrites really changes the game.<p>There's some cool applications linked on the site that I recommend people check out. A kind of neat thing about it being in rust is that you can compile to WASM to throw stuff on the web. I had a little demo of using egg to rewrite some category theory on my blog here <a href="https://www.philipzucker.com/rust-category/" rel="nofollow">https://www.philipzucker.com/rust-category/</a>
So theory is not my strongest suit, maybe someone can clarify some things for me here. It seems like these equalities that we're looking for are things like the identity laws, but also extended by mathematical operations like bitshift being faster than division by 2.<p>Do these equalities carry all the way into general programming, to the point where we could for example say a short loop is equivalent to an unrolled loop, and thus suggest that optimization? Would we have to come up with an exhaustive list of equivalences, or is the list actually short and well known like they are in logic (Identity Laws)?<p>Will we at some point basically plug Egg into LLVM and have it find new optimization passes?
I love this paper. Beyond including an interesting contribution, they give a fantastic introduction to the underlying ideas and algorithm that forms the background. Even if you only have time for the first few pages, it's a worthwhile read.
ooh this is serendipitous, I'm going to need to do some deep research into term rewriting soon.<p>mentally, I'm modelling term rewriting as a state space search where each edge transition is a single possible rewrite. As always with state space search, the goal is to find the global optimum.<p>It's funny how many problems come back to search heuristics.