real constant folder: actually add higher domain consts
@@ -334,8 +334,8 @@ impl SynthLanguage for Math {
// custom constant folder
fn constant_fold(egraph: &mut EGraph<Self, SynthAnalysis>, id: Id) {
- let mut to_add = vec![];
if !egraph[id].data.in_domain { // lower domain
+ let mut to_add = vec![];
if !egraph[id].nodes.iter().any(|x| x.is_constant()) { // cannot already have a constant
for x in &egraph[id].nodes {
match x {
@@ -369,7 +369,6 @@ impl SynthLanguage for Math {
}
}
}
- }
for (n, s) in to_add {
let mut to_update = vec![];
@@ -403,6 +402,18 @@ impl SynthLanguage for Math {
let r_id = egraph.find(r_id);
egraph[r_id].data.exact = true;
}
+ } else {
+ let lim_ids: Vec<Id> = egraph[id].nodes.iter()
+ .filter_map(|n| match n {
+ Math::Lim(v) => Some(*v),
+ _ => None,
+ })
+ .collect();
+
+ for i in lim_ids {
+ Self::constant_fold(egraph, i);
+ }
+ }
}
}
