Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E-Analysis in test/Sym.hs #35

Open
Tarmean opened this issue Mar 5, 2024 · 0 comments
Open

E-Analysis in test/Sym.hs #35

Tarmean opened this issue Mar 5, 2024 · 0 comments

Comments

@Tarmean
Copy link

Tarmean commented Mar 5, 2024

I believe the Sym.hs test has some weird corners. Not sure if the test has to be fixed, it seems to test everything it should. Maybe a comment for folks who are looking for examples is fine?

The Maybe Double E-Analysis is basically a coarse grained set. Either it represents all Double's or a singleton set of a specific Double.
The join should be set-intersection, but then we should have joinA Nothing x = x and joinA x Nothing = x.
The current implementation is not unsound, but it loses a lot of accuracy and results depend on the ordering of rules and merges.

Secondly, some rules have the conditional

is_not_zero :: Pattern Expr -> RewriteCondition (Maybe Double) Expr
is_not_zero v subst egr =
    egr^._class (unsafeGetSubst v subst)._data /= Just 0

This is very dangerous because Nothing stands for all Doubles. With a fixed joinA, Nothing can be refined to Just 0 later. Fixing the condition to not fire on Nothing makes the test-suite fail, though. In datalogs with lattices this is sometimes solved with stratification, so the stratified rules run only after all rules that could refine the e-analysis finished. But because congruence and e-analysis always run this doesn't seem feasible, so is_not_zero should only fire if the e-class has a known distinct value. Optionally the lattice could be enriched with a specific non-zero case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant