Skip to content

Commit 50cfe34

Browse files
Clear constraints at each call to dec_solve
constraint_generator is kept as a class member because it is used by get, but we need to make sure it is cleared at each dec_solve call so that we don't keep unecessary or redundant constraints.
1 parent 367ca13 commit 50cfe34

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

src/solvers/refinement/string_constraint_generator.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ class string_constraint_generatort final
110110
const std::vector<string_not_contains_constraintt> &
111111
get_not_contains_constraints() const;
112112

113+
/// Clear all constraints and lemmas
114+
void clear_constraints();
115+
113116
/// Boolean symbols for the results of some string functions
114117
const std::vector<symbol_exprt> &get_boolean_symbols() const;
115118

src/solvers/refinement/string_constraint_generator_main.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,13 @@ string_constraint_generatort::get_string_expr(const exprt &expr)
323323
return char_array_of_pointer(str.content(), str.length());
324324
}
325325

326+
void string_constraint_generatort::clear_constraints()
327+
{
328+
lemmas.clear();
329+
constraints.clear();
330+
not_contains_constraints.clear();
331+
}
332+
326333
/// adds standard axioms about the length of the string and its content: * its
327334
/// length should be positive * it should not exceed max_string_length * if
328335
/// force_printable_characters is true then all characters should belong to the

src/solvers/refinement/string_refinement.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,9 @@ decision_proceduret::resultt string_refinementt::dec_solve()
639639
string_id_symbol_resolve.replace_expr(eq.rhs());
640640
}
641641

642+
// Generator is also used by get, so we have to use it as a class member
643+
// but we make sure it is cleared at each `dec_solve` call.
644+
generator.clear_constraints();
642645
make_char_array_pointer_associations(generator, equations);
643646

644647
#ifdef DEBUG
@@ -658,8 +661,7 @@ decision_proceduret::resultt string_refinementt::dec_solve()
658661
#endif
659662

660663
debug() << "dec_solve: add constraints" << eom;
661-
// Generator is also used by get, that's why we use a class member
662-
dependencies.add_constraints(generator);
664+
dependencies.add_constraints(generator);
663665

664666
#ifdef DEBUG
665667
output_equations(debug(), equations, ns);

0 commit comments

Comments
 (0)