Skip to content

Instant Unions#165

Merged
mwillsey merged 8 commits intoegraphs-good:mainfrom
oflatt:undelayed-unions
Feb 14, 2022
Merged

Instant Unions#165
mwillsey merged 8 commits intoegraphs-good:mainfrom
oflatt:undelayed-unions

Conversation

@oflatt
Copy link
Copy Markdown
Member

@oflatt oflatt commented Feb 11, 2022

[#115] Introduces explanations- proofs of equality between two terms in the egraph. To support the PR, egg was modified so that all unions were delayed until rebuild is called. This made explanations easier to implement because there is an up-to-date hashcons (memo for enodes in the egraph).

However, it turns out that carefully re-writing how enodes are added to the egraph avoids this issue. This PR restores egg's functionality to perform unions immediately. It also restores the rebuild algorithm to what it was before proofs were added. The core idea of the PR is to make sure that proofs have access to the correct uncanonicalized enode.

self[child].parents.push(tup);
});
// now that we updated explanations, run the analysis for the new eclass
N::modify(self, id);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@mwillsey it is key that we do modify after all the explanations stuff, so this version is different than the one we discussed.

// TODO is this needed?
self.pending.push((enode.clone(), id));
/// This function makes a new eclass in the egraph (but doesn't touch explanations)
fn make_new_eclass(&mut self, enode: L) -> Id {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is roughly the same as the old add

rule_name: impl Into<Symbol>,
) -> (Id, bool) {
let id1 = self.add_instantiation(from_pat, subst);
let id1 = self.add_instantiation_internal(from_pat, subst);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

"Internal" functions now return uncanonicalized ids so we can track which enode explanations use.

@mwillsey mwillsey merged commit 6c352ec into egraphs-good:main Feb 14, 2022
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