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

Canonicalize all commutative operators in Expr #684

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

msooseth
Copy link
Collaborator

@msooseth msooseth commented Mar 13, 2025

Description

Canonicalize all commutative operators in Expr. Much more powerful than some of the rewrite rules we had before.

This helps us with Eq x1 x1. In cases when x1 == x2 modulo commutativity, the Eq x1 x2 could actually be dispatched to the SMT solver. However, if we canonicalize x1 and x2, then this will not happen. This significantly improves solving. Note that this canonicalization is 100% compatible with us wanting Lit as the 1st argument. Lit is the lowest in the order, and so will always be the 1st.

This also means that some old rewrite rules need to change. The Add (Add ((Lit x) y) (Lit z)) can no longer stay that way, as Lit is smaller than Add, so it becomes Add (Lit x) (Add (Lit z) y. This is a good thing, because it brings all Lit-s to the LHS. This is now done for all commutative operators. The new setup is cleaner and also more principled than before. I adjusted the tests, and they showcase quite well that we are doing good indeed.

This change necessitated one small, logical change in our array decomposition. However, this thankfully helped us pass one more test that I have been meaning to pass! Yay.

Checklist

  • tested locally
  • added automated tests
  • updated the docs
  • updated the changelog

@msooseth msooseth changed the title Canonicalize all commutative operators in Expr [DRAFT] Canonicalize all commutative operators in Expr Mar 13, 2025
@msooseth msooseth force-pushed the more-simplifications branch from fc8433e to 08b313e Compare March 13, 2025 17:40
@msooseth msooseth changed the title [DRAFT] Canonicalize all commutative operators in Expr Canonicalize all commutative operators in Expr Mar 13, 2025
@msooseth msooseth force-pushed the more-simplifications branch from 08b313e to e32c08b Compare March 13, 2025 17:43
@msooseth msooseth marked this pull request as ready for review March 13, 2025 17:43
@msooseth msooseth requested a review from blishko March 13, 2025 17:43
Update

MOre te

Also order all commutative

Improve

Update Changelog

More simp

Fixing

Update changelog

Cleanup

No need to check
@msooseth msooseth force-pushed the more-simplifications branch from e32c08b to 41825cd Compare March 13, 2025 17:46
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

Successfully merging this pull request may close these issues.

1 participant