Skip to content

Commit 7586f76

Browse files
Only add counter examples when index set exhausted
Adding counter examples during the solver procedure make it very sensitive to small changes: if the counter examples are different between two executions then the lemmas will be different, which make the execution diverge. It is best to avoid them when possible, that is as long as the index set is not exhausted.
1 parent f3cb5bb commit 7586f76

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

src/solvers/refinement/string_refinement.cpp

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -772,17 +772,12 @@ decision_proceduret::resultt string_refinementt::dec_solve()
772772
config_.use_counter_example,
773773
supert::config_.ui,
774774
symbol_resolve);
775-
if(!satisfied)
776-
{
777-
for(const auto &counter : counter_examples)
778-
add_lemma(counter);
779-
debug() << "check_SAT: got SAT but the model is not correct" << eom;
780-
}
781-
else
775+
if(satisfied)
782776
{
783777
debug() << "check_SAT: the model is correct" << eom;
784778
return resultt::D_SATISFIABLE;
785779
}
780+
debug() << "check_SAT: got SAT but the model is not correct" << eom;
786781
}
787782
else
788783
{
@@ -821,19 +816,15 @@ decision_proceduret::resultt string_refinementt::dec_solve()
821816
config_.use_counter_example,
822817
supert::config_.ui,
823818
symbol_resolve);
824-
if(!satisfied)
825-
{
826-
for(const auto &counter : counter_examples)
827-
add_lemma(counter);
828-
debug() << "check_SAT: got SAT but the model is not correct" << eom;
829-
}
830-
else
819+
if(satisfied)
831820
{
832821
debug() << "check_SAT: the model is correct" << eom;
833822
return resultt::D_SATISFIABLE;
834823
}
835824

836-
debug() << "refining..." << eom;
825+
debug() << "check_SAT: got SAT but the model is not correct, refining..."
826+
<< eom;
827+
837828
// Since the model is not correct although we got SAT, we need to refine
838829
// the property we are checking by adding more indices to the index set,
839830
// and instantiating universal formulas with this indices.
@@ -852,7 +843,12 @@ decision_proceduret::resultt string_refinementt::dec_solve()
852843
return resultt::D_ERROR;
853844
}
854845
else
855-
debug() << "dec_solve: current index set is empty" << eom;
846+
{
847+
debug() << "dec_solve: current index set is empty, "
848+
<< "adding counter examples" << eom;
849+
for(const auto &counter : counter_examples)
850+
add_lemma(counter);
851+
}
856852
}
857853
current_constraints.clear();
858854
for(const auto &instance :

0 commit comments

Comments
 (0)