Skip to content

Fix issue #244 - add_axioms_for_set_length #841

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion regression/strings-smoke-tests/java_append_char/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FUTURE
CORE
test_append_char.class
--refine-strings
^EXIT=0$
Expand Down
2 changes: 1 addition & 1 deletion regression/strings-smoke-tests/java_append_int/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FUTURE
CORE
test_append_int.class
--refine-strings
^EXIT=0$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ test_append_object.class
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
Issue: diffblue/test-gen#82
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FUTURE
CORE
test_append_string.class
--refine-strings
^EXIT=0$
Expand Down
2 changes: 1 addition & 1 deletion regression/strings-smoke-tests/java_case/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FUTURE
CORE
test_case.class
--refine-strings
^EXIT=0$
Expand Down
2 changes: 1 addition & 1 deletion regression/strings-smoke-tests/java_char_array/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FUTURE
CORE
test_char_array.class
--refine-strings
^EXIT=0$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ test_init.class
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
cbmc/test-gen#259
2 changes: 1 addition & 1 deletion regression/strings-smoke-tests/java_char_at/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FUTURE
CORE
test_char_at.class
--refine-strings
^EXIT=0$
Expand Down
2 changes: 1 addition & 1 deletion regression/strings-smoke-tests/java_code_point/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FUTURE
CORE
test_code_point.class
--refine-strings
^EXIT=0$
Expand Down
2 changes: 1 addition & 1 deletion regression/strings-smoke-tests/java_compare/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FUTURE
CORE
test_compare.class
--refine-strings
^EXIT=0$
Expand Down
2 changes: 1 addition & 1 deletion regression/strings-smoke-tests/java_concat/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FUTURE
CORE
test_concat.class
--refine-strings
^EXIT=10$
Expand Down
3 changes: 2 additions & 1 deletion regression/strings-smoke-tests/java_contains/test.desc
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
FUTURE
KNOWNBUG
test_contains.class
--refine-strings
^EXIT=10$
^SIGNAL=0$
^\[.*assertion.1\].* line 8.* SUCCESS$
^\[.*assertion.2\].* line 9.* FAILURE$
--
Issue: diffblue/test-gen#201
2 changes: 1 addition & 1 deletion regression/strings-smoke-tests/java_delete/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FUTURE
CORE
test_delete.class
--refine-strings
^EXIT=0$
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FUTURE
CORE
test_delete_char_at.class
--refine-strings
^EXIT=0$
Expand Down
2 changes: 1 addition & 1 deletion regression/strings-smoke-tests/java_empty/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FUTURE
CORE
test_empty.class
--refine-strings
^EXIT=0$
Expand Down
2 changes: 1 addition & 1 deletion regression/strings-smoke-tests/java_endswith/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FUTURE
CORE
test_endswith.class
--refine-strings
^EXIT=10$
Expand Down
4 changes: 2 additions & 2 deletions regression/strings-smoke-tests/java_equal/test.desc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FUTURE
CORE
test_equal.class
--refine-strings
--refine-strings --string-max-length 100 --string-max-length 100
^EXIT=10$
^SIGNAL=0$
^\[.*assertion.1\].* line 8.* FAILURE$
Expand Down
2 changes: 1 addition & 1 deletion regression/strings-smoke-tests/java_float/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FUTURE
CORE
test_float.class
--refine-strings
^EXIT=0$
Expand Down
2 changes: 1 addition & 1 deletion regression/strings-smoke-tests/java_hash_code/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FUTURE
CORE
test_hash_code.class
--refine-strings
^EXIT=10$
Expand Down
3 changes: 2 additions & 1 deletion regression/strings-smoke-tests/java_index_of/test.desc
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
FUTURE
KNOWNBUG
test_index_of.class
--refine-strings
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
Issue: cbmc/test-gen#77
3 changes: 2 additions & 1 deletion regression/strings-smoke-tests/java_index_of_char/test.desc
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
FUTURE
CORE
test_index_of_char.class
--refine-strings
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
Issue: cbmc/test-gen#77
2 changes: 1 addition & 1 deletion regression/strings-smoke-tests/java_insert_char/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FUTURE
CORE
test_insert_char.class
--refine-strings
^EXIT=0$
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FUTURE
CORE
test_insert_char_array.class
--refine-strings
^EXIT=0$
Expand Down
2 changes: 1 addition & 1 deletion regression/strings-smoke-tests/java_insert_int/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FUTURE
CORE
test_insert_int.class
--refine-strings
^EXIT=0$
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FUTURE
CORE
test_insert_multiple.class
--refine-strings
^EXIT=0$
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FUTURE
CORE
test_insert_string.class
--refine-strings
^EXIT=0$
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FUTURE
CORE
test_int.class
--refine-strings
^EXIT=0$
Expand Down
2 changes: 1 addition & 1 deletion regression/strings-smoke-tests/java_intern/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FUTURE
CORE
test_intern.class
--refine-strings
^EXIT=0$
Expand Down
3 changes: 2 additions & 1 deletion regression/strings-smoke-tests/java_last_index_of/test.desc
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
FUTURE
KNOWNBUG
test_last_index_of.class
--refine-strings
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
Issue: diffblue/test-gen#77
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FUTURE
CORE
test_last_index_of_char.class
--refine-strings
^EXIT=0$
Expand Down
2 changes: 1 addition & 1 deletion regression/strings-smoke-tests/java_length/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FUTURE
CORE
test_length.class
--refine-strings
^EXIT=0$
Expand Down
2 changes: 1 addition & 1 deletion regression/strings-smoke-tests/java_parseint/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FUTURE
CORE
test_parseint.class
--refine-strings
^EXIT=10$
Expand Down
3 changes: 2 additions & 1 deletion regression/strings-smoke-tests/java_replace/test.desc
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
FUTURE
test_replace.class
--refine-strings
--refine-strings --string-max-length 100
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
diffblue/test-gen#256
2 changes: 1 addition & 1 deletion regression/strings-smoke-tests/java_replace_char/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FUTURE
CORE
test_replace_char.class
--refine-strings
^EXIT=0$
Expand Down
2 changes: 1 addition & 1 deletion regression/strings-smoke-tests/java_set_char_at/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FUTURE
CORE
test_set_char_at.class
--refine-strings
^EXIT=0$
Expand Down
4 changes: 2 additions & 2 deletions regression/strings-smoke-tests/java_set_length/test.desc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FUTURE
CORE
test_set_length.class
--refine-strings
--refine-strings --string-max-length 100
^EXIT=10$
^SIGNAL=0$
^\[.*assertion.1\].* line 8.* SUCCESS$
Expand Down
2 changes: 1 addition & 1 deletion regression/strings-smoke-tests/java_starts_with/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FUTURE
CORE
test_starts_with.class
--refine-strings
^EXIT=10$
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FUTURE
CORE
test_sb_length.class
--refine-strings
^EXIT=0$
Expand Down
2 changes: 1 addition & 1 deletion regression/strings-smoke-tests/java_subsequence/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FUTURE
CORE
test_subsequence.class
--refine-strings
^EXIT=0$
Expand Down
2 changes: 1 addition & 1 deletion regression/strings-smoke-tests/java_substring/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FUTURE
CORE
test_substring.class
--refine-strings
^EXIT=0$
Expand Down
4 changes: 2 additions & 2 deletions regression/strings-smoke-tests/java_trim/test.desc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FUTURE
CORE
test_trim.class
--refine-strings
--refine-strings --string-max-length 100
^EXIT=10$
^SIGNAL=0$
^\[.*assertion.1\].* line 6.* SUCCESS$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,29 @@ string_exprt string_constraint_generatort::add_axioms_for_set_length(

// We add axioms:
// a1 : |res|=k
// a2 : forall i<k. (i<k ==> s[i]=s1[i]) &&(i >= k ==> s[i]=0)
// a2 : forall i<|s1|. i < |res| ==> res[i] = s1[i]
// a3 : forall i<|s1|. i >= |res| ==> res[i] = 0

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

symbol_exprt idx=fresh_univ_index(
"QA_index_set_length", ref_type.get_index_type());
string_constraintt a2(
idx, k, and_exprt(
implies_exprt(
s1.axiom_for_is_strictly_longer_than(idx),
equal_exprt(s1[idx], res[idx])),
implies_exprt(
s1.axiom_for_is_shorter_than(idx),
equal_exprt(s1[idx], constant_char(0, ref_type.get_char_type())))));
idx,
s1.length(),
res.axiom_for_is_strictly_longer_than(idx),
equal_exprt(s1[idx], res[idx]));
axioms.push_back(a2);

symbol_exprt idx2=fresh_univ_index(
"QA_index_set_length2", ref_type.get_index_type());
string_constraintt a3(
idx2,
s1.length(),
res.axiom_for_is_shorter_than(idx2),
equal_exprt(res[idx2], constant_char(0, ref_type.get_char_type())));
axioms.push_back(a3);

return res;
}

Expand Down