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 multisets #446

Merged
merged 7 commits into from
Oct 25, 2024
Merged

Add multisets #446

merged 7 commits into from
Oct 25, 2024

Conversation

saulshanabrook
Copy link
Member

This PR adds a multiset sort. It is based on a data structure that implements functional sharing. Using that sort, an example is added to show how you can use it to express associative & commutative operations like addition in multiplication with multisets, so that their canonical forms don't need to re-encoded for every ordering. See these threads on zulip for some more background.

@saulshanabrook saulshanabrook requested a review from a team as a code owner October 18, 2024 19:55
@saulshanabrook saulshanabrook requested review from mwillsey and removed request for a team October 18, 2024 19:55
src/multiset.rs Outdated Show resolved Hide resolved
This PR adds a multiset sort. It is based on a data structure that implements
functional sharing. Using that sort, an example is added to show how you
can use it to express associative & commutative operations like addition
in multiplication with multisets, so that their canonical forms don't need
to re-encoded for every ordering. See [these](https://egraphs.zulipchat.com/#narrow/channel/328972-general/topic/Reducing.20node.20explosion.20through.20algebraic.20representations.3F)
[threads](https://egraphs.zulipchat.com/#narrow/channel/328972-general/topic/Linear.20and.20Polynomial.20Equations) on zulip for some more background.
Copy link

codspeed-hq bot commented Oct 18, 2024

CodSpeed Performance Report

Merging #446 will not alter performance

Comparing saulshanabrook:multiset (0042f72) with main (b9f4c58)

Summary

✅ 8 untouched benchmarks

🆕 2 new benchmarks

Benchmarks breakdown

Benchmark main saulshanabrook:multiset Change
🆕 eqsat-basic-multiset N/A 4 ms N/A
🆕 multiset N/A 2.3 ms N/A

Cargo.toml Outdated Show resolved Hide resolved
src/multiset.rs Outdated Show resolved Hide resolved
src/sort/multiset.rs Show resolved Hide resolved
src/sort/fn.rs Outdated Show resolved Hide resolved
src/sort/multiset.rs Outdated Show resolved Hide resolved
@oflatt
Copy link
Member

oflatt commented Oct 18, 2024

I'm a little hesitant to add new containers given the churn on the API and the new backend coming soon.

Can this be done in egglog already by using a Map and mapping keys to the number of that element?

@yihozhang
Copy link
Collaborator

I'm in favor of merging this after some cleanups (e.g., merge the two multiset.rs files), since this is no worse than the containers and higher-order functions we currently have, and we have not had a clear idea about what will and won't be supported for containers in the future. I especially like the implementation of map of this PR. Let's talk about this in the dev meeting this week!

@saulshanabrook saulshanabrook requested review from yihozhang and removed request for yihozhang October 24, 2024 16:39
Copy link
Collaborator

@yihozhang yihozhang left a comment

Choose a reason for hiding this comment

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

Looks good to me!

Cargo.toml Show resolved Hide resolved
@saulshanabrook saulshanabrook merged commit 993582f into egraphs-good:main Oct 25, 2024
5 checks passed
@saulshanabrook saulshanabrook deleted the multiset branch October 25, 2024 15:40
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.

4 participants