Skip to content

Commit 99d1539

Browse files
romainbrenguiertautschnig
authored andcommitted
Correction in add_axioms_for_set_length
This corrects issue diffblue/test-gen#244 There was a an error in add_axioms_for_set_length: |s1| was compared to idx instead of comparing k to idx. The second assertion was splitted into two to make constraints clearer. Applied changes requested by Matthias
1 parent 93bbf21 commit 99d1539

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

src/solvers/refinement/string_constraint_generator_transformation.cpp

+15-8
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,29 @@ string_exprt string_constraint_generatort::add_axioms_for_set_length(
3131

3232
// We add axioms:
3333
// a1 : |res|=k
34-
// a2 : forall i<k. (i<k ==> s[i]=s1[i]) &&(i >= k ==> s[i]=0)
34+
// a2 : forall i<|s1|. i < |res| ==> res[i] = s1[i]
35+
// a3 : forall i<|s1|. i >= |res| ==> res[i] = 0
3536

3637
axioms.push_back(res.axiom_for_has_length(k));
3738

3839
symbol_exprt idx=fresh_univ_index(
3940
"QA_index_set_length", ref_type.get_index_type());
4041
string_constraintt a2(
41-
idx, k, and_exprt(
42-
implies_exprt(
43-
s1.axiom_for_is_strictly_longer_than(idx),
44-
equal_exprt(s1[idx], res[idx])),
45-
implies_exprt(
46-
s1.axiom_for_is_shorter_than(idx),
47-
equal_exprt(s1[idx], constant_char(0, ref_type.get_char_type())))));
42+
idx,
43+
s1.length(),
44+
res.axiom_for_is_strictly_longer_than(idx),
45+
equal_exprt(s1[idx], res[idx]));
4846
axioms.push_back(a2);
4947

48+
symbol_exprt idx2=fresh_univ_index(
49+
"QA_index_set_length2", ref_type.get_index_type());
50+
string_constraintt a3(
51+
idx2,
52+
s1.length(),
53+
res.axiom_for_is_shorter_than(idx2),
54+
equal_exprt(res[idx2], constant_char(0, ref_type.get_char_type())));
55+
axioms.push_back(a3);
56+
5057
return res;
5158
}
5259

0 commit comments

Comments
 (0)