JuliaSymbolics / Metatheory.jl

Makes Julia reason with equations. General purpose metaprogramming, symbolic computation and algebraic equational reasoning library for the Julia programming language: E-Graphs & equality saturation, term rewriting and more.
https://juliasymbolics.github.io/Metatheory.jl/dev/
MIT License
355 stars 46 forks source link

Pretty printing, fix for graph plots & minor docs improvement #195

Closed nmheim closed 5 months ago

nmheim commented 5 months ago

This fixes the GraphViz.jl visualizations and makes printing egraphs a bit more friendly:

julia> EGraph(:(a-a))
EGraph{Expr, Nothing} with 2 e-classes:
  2 => [:(%1 - %1)]
  1 => [:a]

I could also add a couple of lines to the EGraph/EClass doc strings to describe how to get eclasses/enodes printed as their expressions and not as IDs from the VexExpr, what do you think @0x0f0f0f ?

nmheim commented 5 months ago

@0x0f0f0f should the VECEXPR_FLAG_ISTREE be called VEXEXPR_FLAT_ISEXPR to follow TI?

nmheim commented 5 months ago

Updated EClass printing as well, let me know what you think:

EClass #7 with 3 e-nodes:
 data: nothing
 nodes:
    UInt64[0x40bf97fbe165fe33, 0x0000000000000011, 0x6b268fa6aca9af40, 0x0000000000000003, 0x0000000000000001]
    UInt64[0x1f151e2f9e110a6f, 0x0000000000000011, 0x6b268fa6aca9af40, 0x0000000000000001, 0x0000000000000003]
    UInt64[0xbf224d67bfbdd6b4, 0x0000000000000011, 0x124165ec9b19c768, 0x0000000000000001, 0x0000000000000001]