Skip to content

Commit 31df091

Browse files
committed
Bug fix in SAT Algo
1 parent 35b680f commit 31df091

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

src/antimirov/subs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ fn merge(substitutions: AnySub) -> Option<SimpleSub> {
713713
}
714714
// Note: We insert c instead of new_c here which means that not all keys are fully resolved. Can be revisted later.
715715
match &*new_c {
716-
CharExpression::CharVar(new_var) => combined_not.insert(c.clone(), modified_not),
716+
CharExpression::CharVar(new_var) => combined_not.insert(new_var.clone(), modified_not),
717717
CharExpression::Literal(_) => todo!(),
718718
};
719719
}

src/solver/antimirov.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use super::Solver;
99

1010
use crate::antimirov::deriv::{derivative, nullable};
1111
use crate::antimirov::subs::{
12-
merge_binary, merge_range_constraints, merge_sets, RangeConstr, SimpleSub,
12+
merge_binary, merge_range_constraints, merge_sets, sub_in, RangeConstr, SimpleSub, SubExpr
1313
};
1414
use crate::types::expr::{CharExpression, CharVar};
1515
use crate::types::regex::GenRegex;
@@ -24,6 +24,7 @@ pub struct AntimirovSolver {}
2424
// Stores a regex and at what depth of derivative it was found.
2525
struct DerivativeDepth {
2626
gre: Rc<GenRegex>,
27+
// TODO: Maybe combine not_sub and range constraints?
2728
not_sub: SimpleSub,
2829
range_constraints: BTreeMap<CharVar, RangeConstr>,
2930
depth: i32,
@@ -119,10 +120,12 @@ impl Solver for AntimirovSolver {
119120
}
120121
println!("Subs: {:?}", ele.get_subs());
121122
println!("Not subs: {:?}", layer.not_sub);
122-
let Some(f) = merge_binary(ele.get_subs(), &layer.not_sub) else {
123-
//println!("death2");
123+
let Some(mut f) = merge_binary(ele.get_subs(), &layer.not_sub) else {
124+
// println!("death2");
124125
continue;
125126
};
127+
*f.get_str_map_mut()= BTreeMap::new();
128+
let new_re=sub_in(ele.get_expr(), &f);
126129
// Potential code for fixing optimized range constraints, commented out due to Union Find index out of bounds issues
127130
//println!("Before Range Update: {:?}",layer.range_constraints);
128131
let mut updated_range = BTreeMap::new();
@@ -143,7 +146,7 @@ impl Solver for AntimirovSolver {
143146
//println!("After range merge: {:?}",r);
144147
println! {"Not constraint pushed: {:?}",f};
145148
sat_stack.push(DerivativeDepth {
146-
gre: ele.get_expr().clone(),
149+
gre: new_re.clone(),
147150
not_sub: SimpleSub::new(
148151
BTreeMap::new(),
149152
BTreeMap::new(),

0 commit comments

Comments
 (0)