egraphs-good / egglog

egraphs + datalog!
https://egraphs-good.github.io/egglog/
MIT License
459 stars 54 forks source link

Move splitting primitives to serialize library #407

Closed saulshanabrook closed 2 months ago

saulshanabrook commented 3 months ago

This PR moves the ability to split primitive nodes into the serialize library from this library and also extends it to support splitting arbitrary nodes. See https://github.com/egraphs-good/egraph-serialize/pull/14 for the upstream PR that corresponds to this one, which includes an example using this new behavior.

By default, this should result in the same behavior as before, but just with the ability to split more e-classes besides just primitive nodes if desired.

In order to move the splitting logic upstream, I exposed a way to check if a serialized node ID is a primitive. In a way, this extends https://github.com/egraphs-good/egglog/pull/396 by also now supporting public deserialization/serialization for serialized node IDs as well as class IDs. This should also be useful if you do extraction externally and then want to convert back to egglog values.