@@ -233,7 +233,7 @@ static void display_index_set(
233
233
static std::vector<exprt> generate_instantiations (
234
234
messaget::mstreamt &stream,
235
235
const namespacet &ns,
236
- string_constraint_generatort &generator,
236
+ const string_constraint_generatort &generator,
237
237
const index_set_pairt &index_set,
238
238
const string_axiomst &axioms)
239
239
{
@@ -638,10 +638,7 @@ decision_proceduret::resultt string_refinementt::dec_solve()
638
638
return res;
639
639
}
640
640
641
- initial_index_set (
642
- index_sets,
643
- ns,
644
- axioms);
641
+ initial_index_set (index_sets, ns, axioms);
645
642
update_index_set (index_sets, ns, current_constraints);
646
643
display_index_set (debug (), ns, index_sets);
647
644
current_constraints.clear ();
@@ -700,7 +697,21 @@ decision_proceduret::resultt string_refinementt::dec_solve()
700
697
if (index_sets.current .empty ())
701
698
{
702
699
debug () << " current index set is empty" << eom;
703
- return resultt::D_ERROR;
700
+ if (axioms.not_contains .empty ())
701
+ {
702
+ debug () << " no not_contains axioms, hence SAT" << eom;
703
+ concretize_lengths (
704
+ found_length,
705
+ get,
706
+ symbol_resolve,
707
+ generator.get_created_strings ());
708
+ return resultt::D_SATISFIABLE;
709
+ }
710
+ else
711
+ {
712
+ debug () << " not_contains axioms exist, hence ERROR" << eom;
713
+ return resultt::D_ERROR;
714
+ }
704
715
}
705
716
706
717
display_index_set (debug (), ns, index_sets);
@@ -1373,9 +1384,28 @@ static std::pair<bool, std::vector<exprt>> check_axioms(
1373
1384
if (use_counter_example)
1374
1385
{
1375
1386
stream << " Adding counter-examples: " << eom;
1376
- // TODO: add counter-examples for universal constraints?
1377
1387
1378
1388
std::vector<exprt> lemmas;
1389
+
1390
+ for (const auto &v : violated)
1391
+ {
1392
+ const exprt &val=v.second ;
1393
+ const string_constraintt &axiom=axioms.universal [v.first ];
1394
+
1395
+ implies_exprt instance (axiom.premise (), axiom.body ());
1396
+ replace_expr (axiom.univ_var (), val, instance);
1397
+ // We are not sure the index set contains only positive numbers
1398
+ exprt bounds=and_exprt (
1399
+ axiom.univ_within_bounds (),
1400
+ binary_relation_exprt (
1401
+ from_integer (0 , val.type ()), ID_le, val));
1402
+ replace_expr (axiom.univ_var (), val, bounds);
1403
+ const implies_exprt counter (bounds, instance);
1404
+
1405
+ stream << " - " << from_expr (ns, " " , counter) << eom;
1406
+ lemmas.push_back (counter);
1407
+ }
1408
+
1379
1409
for (const auto &v : violated_not_contains)
1380
1410
{
1381
1411
const exprt &val=v.second ;
@@ -1390,7 +1420,7 @@ static std::pair<bool, std::vector<exprt>> check_axioms(
1390
1420
const exprt counter=::instantiate_not_contains (
1391
1421
axiom, indices, generator)[0 ];
1392
1422
1393
- stream << " - " << from_expr (ns, " " , counter) << eom;
1423
+ stream << " - " << from_expr (ns, " " , counter) << eom;
1394
1424
lemmas.push_back (counter);
1395
1425
}
1396
1426
return { false , lemmas };
@@ -1696,7 +1726,7 @@ static void initial_index_set(
1696
1726
{
1697
1727
// otherwise we add k-1
1698
1728
exprt e (i);
1699
- minus_exprt kminus1 (
1729
+ const minus_exprt kminus1 (
1700
1730
axiom.upper_bound (),
1701
1731
from_integer (1 , axiom.upper_bound ().type ()));
1702
1732
replace_expr (qvar, kminus1, e);
@@ -1732,7 +1762,7 @@ static void initial_index_set(
1732
1762
++it;
1733
1763
}
1734
1764
1735
- minus_exprt kminus1 (
1765
+ const minus_exprt kminus1 (
1736
1766
axiom.exists_upper_bound (),
1737
1767
from_integer (1 , axiom.exists_upper_bound ().type ()));
1738
1768
add_to_index_set (index_set, ns, axiom.s1 ().content (), kminus1);
0 commit comments