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

Randomly extract a RecExpr from a EGraph #264

Closed
ntcmp2u opened this issue Aug 11, 2023 · 1 comment
Closed

Randomly extract a RecExpr from a EGraph #264

ntcmp2u opened this issue Aug 11, 2023 · 1 comment

Comments

@ntcmp2u
Copy link

ntcmp2u commented Aug 11, 2023

Hi. Is there a simple way to implement an Extractor that can randomly extract a RecExpr that is equal to the initial expression of a EGraph? I hope that we can use this extractor like this:

let start = "(+ 0 (* 1 a))".parse().unwrap();
let runner = Runner::default().with_expr(&start).run(rules);

let extractor = RandomExtractor::new(&runner.egraph);
let equal_expr: RecExpr<Language> = extractor.randomly_find(runner.roots[0]);

I think it is a very useful function that can help us quickly obtain a equal expression without specifying a cost function. Could someone give me some hint that can implement this extractor in a simple way?

@mwillsey
Copy link
Member

No, nothing is built in for this. The build_recexpr function might be useful to implement this instead of an extractor. Basically you could randomly pick an enode, call build_recexpr on it, and recurse.

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

2 participants