Skip to content

Commit ac42912

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 05a3426 commit ac42912

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
@@ -771,17 +771,12 @@ decision_proceduret::resultt string_refinementt::dec_solve()
771771
config_.use_counter_example,
772772
supert::config_.ui,
773773
symbol_resolve);
774-
if(!satisfied)
775-
{
776-
for(const auto &counter : counter_examples)
777-
add_lemma(counter);
778-
debug() << "check_SAT: got SAT but the model is not correct" << eom;
779-
}
780-
else
774+
if(satisfied)
781775
{
782776
debug() << "check_SAT: the model is correct" << eom;
783777
return resultt::D_SATISFIABLE;
784778
}
779+
debug() << "check_SAT: got SAT but the model is not correct" << eom;
785780
}
786781
else
787782
{
@@ -819,19 +814,15 @@ decision_proceduret::resultt string_refinementt::dec_solve()
819814
config_.use_counter_example,
820815
supert::config_.ui,
821816
symbol_resolve);
822-
if(!satisfied)
823-
{
824-
for(const auto &counter : counter_examples)
825-
add_lemma(counter);
826-
debug() << "check_SAT: got SAT but the model is not correct" << eom;
827-
}
828-
else
817+
if(satisfied)
829818
{
830819
debug() << "check_SAT: the model is correct" << eom;
831820
return resultt::D_SATISFIABLE;
832821
}
833822

834-
debug() << "refining..." << eom;
823+
debug() << "check_SAT: got SAT but the model is not correct, refining..."
824+
<< eom;
825+
835826
// Since the model is not correct although we got SAT, we need to refine
836827
// the property we are checking by adding more indices to the index set,
837828
// and instantiating universal formulas with this indices.
@@ -850,7 +841,12 @@ decision_proceduret::resultt string_refinementt::dec_solve()
850841
return resultt::D_ERROR;
851842
}
852843
else
853-
debug() << "dec_solve: current index set is empty" << eom;
844+
{
845+
debug() << "dec_solve: current index set is empty, "
846+
<< "adding counter examples" << eom;
847+
for(const auto &counter : counter_examples)
848+
add_lemma(counter);
849+
}
854850
}
855851
current_constraints.clear();
856852
for(const auto &instance :

0 commit comments

Comments
 (0)