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

Subsumption confusing semantics #462

Open
oflatt opened this issue Nov 7, 2024 · 4 comments
Open

Subsumption confusing semantics #462

oflatt opened this issue Nov 7, 2024 · 4 comments

Comments

@oflatt
Copy link
Member

oflatt commented Nov 7, 2024

Subsumption currently works kind of like a query and kind of like an action. For example, this code:

(Subsume (Add (Add 2 3) 4))

Adds (Add 2 3) to the database. However, if (Add (Add 2 3) 4) isn't present, it errors out because it couldn't find an existing entry.

Is this the behavior we want? Perhaps we wanted subsumption to first add the tuple, then subsume it?

@saulshanabrook
Copy link
Member

I don't have a strong opinion on which semantics is preferable. I do agree maybe it would make sense to add it.

I am curious, is this from just experimenting, or in your use case do you often try to subsume things that don't yet exist?

@oflatt
Copy link
Member Author

oflatt commented Nov 13, 2024

I ran into a bug in eggcc that was a result of me misusing subsumption. I actually thought the semantics was to add it

@yihozhang
Copy link
Collaborator

I'm actually surprised about this behavior, because delete works fine even if the tuple does not exist, and we rely on this behavior at some places.

(datatype E (A))
(delete (A)) ;; works fine
(subsume (A)) ;; panics

I believe subsume should follow the behavior of delete. As another example, switching the order of the two rules below will cause egglog to panic

(datatype E (A))

(rule () ((A)))
(rule () ((subsume (A))))

(run 1) ;; works fine, but switching causes panic.

@saulshanabrook
Copy link
Member

Sounds good to fix it. I would assume it works like delete/set as well.

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

3 participants