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

API-supported way for translating between Values in an egglog::EGraph and ClassIDs in an egraph_serialize::EGraph #392

Closed
gussmith23 opened this issue Jul 13, 2024 · 1 comment · Fixed by #396
Assignees

Comments

@gussmith23
Copy link
Contributor

For a number of reasons which are generally summed up by this issue, I often need to work with both egglog::EGraphs and egraph_serialize::EGraphs. It would be great to have an API-supported, stable way of translating between Values in an EGraph and EClass IDs in a serialized EGraph. As @saulshanabrook pointed out to me, it seems like the process of serialization uses a Value's index into the hashcons to generate its corresponding EClass ID, so that's a hacky way of going back and forth:

egglog/src/serialize.rs

Lines 104 to 105 in 0da3209

let canonical: usize = self.unionfind.find(Id::from(id)).into();
let canonical_id: egraph_serialize::ClassId = canonical.to_string().into();

However, it would give me peace of mind to have a way of doing this that's library-supported!

Thanks all!

@saulshanabrook
Copy link
Member

saulshanabrook commented Jul 15, 2024

I can work on adding to the public API functions to go from the e-class ID to Value and vice versa.

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 a pull request may close this issue.

2 participants