Skip to content

Commit b555d46

Browse files
cleanup and split rules
1 parent 6d8b081 commit b555d46

File tree

6 files changed

+27
-77
lines changed

6 files changed

+27
-77
lines changed

examples/blocking.rs

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,45 +14,30 @@ fn main() {
1414

1515
let runner_1 = Runner::default()
1616
.with_expr(&mm)
17-
// .with_iter_limit(6)
1817
.with_time_limit(Duration::from_secs(60))
19-
.with_node_limit(1_000_000)
18+
.with_node_limit(10_000_000)
2019
.with_scheduler(SimpleScheduler)
2120
.with_hook(hooks::targe_hook(split_guide.clone()))
22-
.with_hook(hooks::printer_hook)
21+
// .with_hook(hooks::printer_hook)
2322
.run(&rise::rules(Ruleset::Split));
2423

25-
println!("{}", runner_1.report());
24+
// println!("{}\nSPLIT STEP DONE DONE\n-----------\n", runner_1.report());
2625
assert_eq!(
2726
runner_1.roots[0],
2827
runner_1.egraph.lookup_expr(&split_guide).unwrap()
2928
);
3029

31-
// let split_guide_sketch = rise::sketchify(&split_guide, &|_| false);
32-
// let sketch_extracted_split_guide =
33-
// &sketch::eclass_extract(&split_guide_sketch, AstSize, &runner_1.egraph, root_mm)
34-
// .unwrap()
35-
// .1;
36-
37-
// // assert!(
38-
// // utils::find_diff(
39-
// // &rise::canon_nat(sketch_extracted_split_guide),
40-
// // &rise::canon_nat(&split_guide)
41-
// // )
42-
// // .is_none()
43-
// // );
44-
4530
let runner_2 = Runner::default()
4631
.with_expr(&split_guide)
47-
// .with_iter_limit(10)
4832
.with_time_limit(Duration::from_secs(60))
49-
.with_node_limit(1_000_000)
33+
.with_node_limit(10_000_000)
34+
.with_iter_limit(11)
5035
.with_scheduler(SimpleScheduler)
5136
.with_hook(hooks::targe_hook(blocking_goal.clone()))
5237
.with_hook(hooks::printer_hook)
5338
.run(&rise::rules(Ruleset::Reorder));
5439

55-
println!("{}", runner_2.report());
40+
println!("{}\nREORDER STEP DONE\n-----------\n", runner_2.report());
5641

5742
let root_guide = runner_2.egraph.find(runner_2.roots[0]);
5843
let blocking_goal_sketch = rise::sketchify(&blocking_goal, &|n| matches!(n, Rise::NatMul(_)));
@@ -62,8 +47,8 @@ fn main() {
6247
.1,
6348
);
6449
assert!(utils::find_diff(&sketch_extracted_blocking_goal, &blocking_goal).is_none());
65-
// assert_eq!(
66-
// root_guide,
67-
// runner_2.egraph.lookup_expr(&blocking_goal).unwrap()
68-
// );
50+
assert_eq!(
51+
runner_2.roots[0],
52+
runner_2.egraph.lookup_expr(&blocking_goal).unwrap()
53+
);
6954
}

src/rewrite_system/rise/analysis.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ impl Analysis<Rise> for FreeBetaNatAnalysis {
9999
let beta_extract = if empty {
100100
RecExpr::default()
101101
} else {
102-
enode.join_recexprs(|id| egraph[id].data.beta_extract.as_ref())
102+
enode.join_recexprs(|id| &egraph[id].data.beta_extract)
103103
};
104104

105105
let canon_nat_expr = if beta_extract.is_empty() {
@@ -119,14 +119,12 @@ impl Analysis<Rise> for FreeBetaNatAnalysis {
119119
if !egraph[id].data.canon_nat_expr.is_empty()
120120
&& egraph[id].data.canon_nat_expr != egraph[id].data.beta_extract
121121
{
122-
// Remove all other nodes, only the canonical one may remain.
123-
egraph[id].nodes.clear();
124122
// Add the canonical expr
125123
let canon_nat = &egraph[id].data.canon_nat_expr;
126124
let added = egraph.add_expr(&canon_nat.clone());
127125
egraph.union(id, added);
128126

129-
// #[cfg(debug_assertions)]
127+
#[cfg(debug_assertions)]
130128
egraph[id].assert_unique_leaves();
131129
}
132130
}

src/rewrite_system/rise/func.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,9 @@ impl<A: Applier<Rise, FreeBetaNatAnalysis>> Applier<Rise, FreeBetaNatAnalysis>
8888
let mut new_subst = subst.clone();
8989
let added_expr_id = egraph.add_expr(&new_expr);
9090
new_subst.insert(self.vectorized_var, added_expr_id);
91-
let mut ids =
92-
self.applier
93-
.apply_one(egraph, eclass, &new_subst, searcher_ast, rule_name);
94-
ids.push(added_expr_id);
95-
ids
91+
92+
self.applier
93+
.apply_one(egraph, eclass, &new_subst, searcher_ast, rule_name)
9694
} else {
9795
Vec::new()
9896
}

src/rewrite_system/rise/nat/applier.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use egg::{Applier, EGraph, Id, Pattern, PatternAst, Searcher, Subst, Symbol, Var};
22

3-
use super::{Rise, FreeBetaNatAnalysis};
3+
use super::{FreeBetaNatAnalysis, Rise};
44

55
pub struct ComputeNat<A: Applier<Rise, FreeBetaNatAnalysis>> {
66
var: Var,
@@ -36,11 +36,9 @@ impl<A: Applier<Rise, FreeBetaNatAnalysis>> Applier<Rise, FreeBetaNatAnalysis> f
3636
let mut new_subst = subst.clone();
3737
let added_expr_id = egraph.add_expr(&simplified_nat);
3838
new_subst.insert(self.var, added_expr_id);
39-
let mut ids = self
40-
.applier
41-
.apply_one(egraph, eclass, &new_subst, searcher_ast, rule_name);
42-
ids.push(added_expr_id);
43-
ids
39+
40+
self.applier
41+
.apply_one(egraph, eclass, &new_subst, searcher_ast, rule_name)
4442
}
4543
}
4644

@@ -60,7 +58,9 @@ impl<A: Applier<Rise, FreeBetaNatAnalysis>> ComputeNatCheck<A> {
6058
}
6159
}
6260

63-
impl<A: Applier<Rise, FreeBetaNatAnalysis>> Applier<Rise, FreeBetaNatAnalysis> for ComputeNatCheck<A> {
61+
impl<A: Applier<Rise, FreeBetaNatAnalysis>> Applier<Rise, FreeBetaNatAnalysis>
62+
for ComputeNatCheck<A>
63+
{
6464
fn apply_one(
6565
&self,
6666
egraph: &mut EGraph<Rise, FreeBetaNatAnalysis>,

0 commit comments

Comments
 (0)