1. 34
    1. 7

      This is a nice literate walkthrough. If one wants to know specifically how to implement egg, I apparently hacked up a literate Monte module explaining that in detail. The paper to read is de Moura & Bjørner 2007 which introduces a virtual machine that can efficiently search e-classes.

      1. 3

        De Moura & Bjorner of Z3 fame?

        1. 2

          Very nice, my previous implementation turned out to be incredibly messy, and you seem to have put some thought into making it non-messy: I especially like the idea of sealing the batching directly into the API. Super, will reimplement this and let you know how it goes!

          1. 2

            In what language are you implementing this? Would you be open to sharing?

            1. 3

              Sure, I’ll probably do it in lean4 and C++ : https://github.com/bollu/lean.egraphs

              The repo contains two implementations, one in C++, and the other in Lean :)

                1. 1

                  Have you poked at this at all? The reimplementation?

            2. 2

              Oh very cool!! I wonder if this helps with the built-in matching DSL that I didn’t bother to implement. How close is Monte to Python?

              1. 3

                Monte is easily transliterable to Python; each object literal needs its own class, and the pattern-matching one-liners have to be expanded into two or three lines of imperative actions. The resulting code will be missing most of the safety checks we built into the language, though.

                1. 2

                  Very cool. Thank you

            3. 2

              Sorry, if I wrote compilers I guess I would know, but what is an IR?

              1. 4

                Intermediate representation - any compiler internal way to store a program for transformations and analysis