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

Add multiset-sum primitive #471

Merged

Conversation

RiscInside
Copy link
Contributor

@RiscInside RiscInside commented Nov 11, 2024

multiset-sum combines values from both multisets together, allowing for rules such as

(rewrite (Add (Sum  xs) (Sum ys)) (Sum (multiset-sum xs ys)))

In my understanding, this primitive is crucial for modelling associative + commutative operations with multisets, but I might be missing something.

@RiscInside RiscInside requested a review from a team as a code owner November 11, 2024 17:29
@RiscInside RiscInside requested review from ezrosent and removed request for a team November 11, 2024 17:29
Copy link
Member

@saulshanabrook saulshanabrook left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this!

Yeah it was not intentional... I just surfaces the primitives necessary to recreate an example to start and figured they could grow based on user need.

So happy for more PRs to expose more things, including more holistically.

Copy link

codspeed-hq bot commented Nov 11, 2024

CodSpeed Performance Report

Merging #471 will not alter performance

Comparing RiscInside:multiset-new-primitives (53c8f01) with main (2c8d947)

Summary

✅ 8 untouched benchmarks

@RiscInside
Copy link
Contributor Author

RiscInside commented Nov 11, 2024

I did also consider adding other operations (union, intersection, and difference), but I don't immediately see a use-case for any of them (intersection/union also have a problem of being fragile to new equalities, e.g. {e1, e1, e2} union {e1, e2, e2} before and after e1 and e2 merge).

@saulshanabrook
Copy link
Member

Sounds good.

Multiset should work with rebuilding canonicalization, but it would be good to add test for this (not related to the work in this PR necessarily). Meaning that if you have {a: 1, b: 1} and then a and b are unioned, the resulting multiset should be {(a | b): 2}. That is handled in canonicalize.

@saulshanabrook saulshanabrook merged commit 9360431 into egraphs-good:main Nov 11, 2024
5 checks passed
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.

2 participants