egraphs-good / eggcc

MIT License
51 stars 11 forks source link

[Tree unique] Add `{Expr,ListExpr}IsValid` & update existing optimizations #262

Closed rtjoa closed 9 months ago

rtjoa commented 9 months ago

Adds the following relations, which indicate that we expect some IR to be well-formed (typecheck, proper use of referencing and capturing ids).

(relation ExprIsValid (Expr))
(relation ListExprIsValid (ListExpr))

All optimizations that add to the e-graph should first match on these relations, to make sure we optimize code we care about, and not intermediary terms that still need to be substed or copied. This has the following benefits:

This PR also ports existing optimizations to use these relations.