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

Trig recipe cleanup #217

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/recipe_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub fn run_workload<L: SynthLanguage>(
}

pub fn run_rule_lifting<L: SynthLanguage>(
workload: Workload,
workload: &Workload,
prior: Ruleset<L>,
limits: Limits,
) -> Ruleset<L> {
Expand All @@ -73,6 +73,10 @@ pub fn run_rule_lifting<L: SynthLanguage>(
let chosen = candidates.minimize(prior, Scheduler::Compress(limits)).0;
let time = t.elapsed().as_secs_f64();

if chosen.is_empty() {
panic!("Didn't learn any rules!");
}

println!(
"Learned {} bidirectional rewrites ({} total rewrites) in {} using {} prior rewrites",
chosen.bidir_len(),
Expand Down
52 changes: 0 additions & 52 deletions tests/maxmin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,56 +502,4 @@ mod tests {
println!("{}", r.name)
}
}

#[test]
fn rule_lifting() {
let nat_rules = get_nat_rules();

let mut all_rules: Ruleset<CaddyAndFRep> = Ruleset::default();
all_rules.extend(Ruleset::new(&nat_rules));

let atoms3 = iter_pos(5);
// assert_eq!(atoms3.force().len(), 51);

let rules3 = run_rule_lifting(
atoms3,
all_rules.clone(),
Limits {
iter: 3,
node: 1000000,
match_: 200_000,
},
);
// assert_eq!(rules3.len(), 6);
all_rules.extend(rules3);

let atoms4 = iter_pos(5);
// assert_eq!(atoms4.force().len(), 255);

let rules4 = run_rule_lifting(
atoms4,
all_rules.clone(),
Limits {
iter: 3,
node: 1000000,
match_: 200_000,
},
);
// assert_eq!(rules4.len(), 2);
all_rules.extend(rules4);

let atoms5 = iter_pos(5);
// assert_eq!(atoms5.force().len(), 1527);

let rules4 = run_rule_lifting(
atoms5,
all_rules.clone(),
Limits {
iter: 3,
node: 1000000,
match_: 200_000,
},
);
// assert_eq!(rules4.len(), 1);
}
}
6 changes: 3 additions & 3 deletions tests/pos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ mod tests {
assert_eq!(atoms3.force().len(), 51);

let rules3 = run_rule_lifting(
atoms3,
&atoms3,
all_rules.clone(),
Limits {
iter: 3,
Expand All @@ -215,7 +215,7 @@ mod tests {
assert_eq!(atoms4.force().len(), 255);

let rules4 = run_rule_lifting(
atoms4,
&atoms4,
all_rules.clone(),
Limits {
iter: 3,
Expand All @@ -229,7 +229,7 @@ mod tests {
assert_eq!(atoms5.force().len(), 1527);

let rules4 = run_rule_lifting(
atoms5,
&atoms5,
all_rules.clone(),
Limits {
iter: 3,
Expand Down
12 changes: 6 additions & 6 deletions tests/recipes/exponential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn constant_rules(prev_rules: &Ruleset) -> Ruleset {
"(pow 1 a)",
]);

run_rule_lifting(terms, prev_rules.clone(), limits())
run_rule_lifting(&terms, prev_rules.clone(), limits())
}

fn exp_rules(prev_rules: &Ruleset) -> Ruleset {
Expand All @@ -49,7 +49,7 @@ fn exp_rules(prev_rules: &Ruleset) -> Ruleset {
"(log (log ?a))".parse().unwrap(),
))));

run_rule_lifting(upper_layer, prev_rules.clone(), limits())
run_rule_lifting(&upper_layer, prev_rules.clone(), limits())
}

fn log_rules(prev_rules: &Ruleset) -> Ruleset {
Expand All @@ -69,7 +69,7 @@ fn log_rules(prev_rules: &Ruleset) -> Ruleset {
"(log (log ?a))".parse().unwrap(),
))));

run_rule_lifting(upper_layer, prev_rules.clone(), limits())
run_rule_lifting(&upper_layer, prev_rules.clone(), limits())
}

fn no_pow_rules(prev_rules: &Ruleset) -> Ruleset {
Expand All @@ -95,7 +95,7 @@ fn no_pow_rules(prev_rules: &Ruleset) -> Ruleset {
"(log (log ?a))".parse().unwrap(),
))));

run_rule_lifting(upper_layer, prev_rules.clone(), limits())
run_rule_lifting(&upper_layer, prev_rules.clone(), limits())
}

fn simple_rules(prev_rules: &Ruleset) -> Ruleset {
Expand All @@ -121,7 +121,7 @@ fn simple_rules(prev_rules: &Ruleset) -> Ruleset {
"(log (log ?a))".parse().unwrap(),
))));

run_rule_lifting(upper_layer, prev_rules.clone(), limits())
run_rule_lifting(&upper_layer, prev_rules.clone(), limits())
}

fn div_rules(prev_rules: &Ruleset) -> Ruleset {
Expand All @@ -142,7 +142,7 @@ fn div_rules(prev_rules: &Ruleset) -> Ruleset {
.plug("bop", &bops)
.filter(Filter::Canon(str_vec!["a", "b"]));

run_rule_lifting(upper_layer, prev_rules.clone(), limits())
run_rule_lifting(&upper_layer, prev_rules.clone(), limits())
}

pub fn make_rules() -> Ruleset {
Expand Down
Loading