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
356 stars 47 forks source link

Struct-Valued Analysis Cause Infinite Loop #153

Closed kylebd99 closed 1 year ago

kylebd99 commented 1 year ago

My use case requires a complicated struct for the analysis value. However, when you use a struct, the default equality to compare them is object equality. This causes an infinite loop in the analyze! code because it believes that the analysis value keeps changing.

The fix that I've found is to define a special Egraphs.isequal() function to properly define equality between my structs. This may not be intuitive though for future users, so you may want to update the documentation to include this workaround for struct-valued analyses.

0x0f0f0f commented 1 year ago

Have you tried using AutoHashEquals on the struct?

0x0f0f0f commented 1 year ago

Any news on this?

kylebd99 commented 1 year ago

Sorry for the slow response, I just tested it, and autohashequals worked for me! I'm a little hesitant about it because of the effects that it has on storing objects in dicts, but it works great for now. Thanks for putting the effort into this package by the way. It's been really helpful for my research.