Skip to content

Commit 9584465

Browse files
romainbrenguierJoel Allred
authored and
Joel Allred
committed
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 21eeb29 commit 9584465

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
@@ -36,22 +36,29 @@ string_exprt string_constraint_generatort::add_axioms_for_set_length(
3636

3737
// We add axioms:
3838
// a1 : |res|=k
39-
// a2 : forall i<k. (i<k ==> s[i]=s1[i]) &&(i >= k ==> s[i]=0)
39+
// a2 : forall i<|s1|. i < |res| ==> res[i] = s1[i]
40+
// a3 : forall i<|s1|. i >= |res| ==> res[i] = 0
4041

4142
axioms.push_back(res.axiom_for_has_length(k));
4243

4344
symbol_exprt idx=fresh_univ_index(
4445
"QA_index_set_length", ref_type.get_index_type());
4546
string_constraintt a2(
46-
idx, k, and_exprt(
47-
implies_exprt(
48-
s1.axiom_for_is_strictly_longer_than(idx),
49-
equal_exprt(s1[idx], res[idx])),
50-
implies_exprt(
51-
s1.axiom_for_is_shorter_than(idx),
52-
equal_exprt(s1[idx], constant_char(0, ref_type.get_char_type())))));
47+
idx,
48+
s1.length(),
49+
res.axiom_for_is_strictly_longer_than(idx),
50+
equal_exprt(s1[idx], res[idx]));
5351
axioms.push_back(a2);
5452

53+
symbol_exprt idx2=fresh_univ_index(
54+
"QA_index_set_length2", ref_type.get_index_type());
55+
string_constraintt a3(
56+
idx2,
57+
s1.length(),
58+
res.axiom_for_is_shorter_than(idx2),
59+
equal_exprt(res[idx2], constant_char(0, ref_type.get_char_type())));
60+
axioms.push_back(a3);
61+
5562
return res;
5663
}
5764

0 commit comments

Comments
 (0)