Skip to content

Commit 1eb7d74

Browse files
Uniformising mathematical notations in comments
Use spaces around comparison operators (=, <=, != etc...) Use ==> to denote implication. n:[lb, ub[ for interval between lb (inclusive) and ub (exclusive). |str| for length of string str.
1 parent a4ab7db commit 1eb7d74

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

src/solvers/refinement/string_constraint_generator_indexof.cpp

+25-25
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ exprt string_constraint_generatort::add_axioms_for_index_of(
3434
symbol_exprt contains=fresh_boolean("contains_in_index_of");
3535

3636
// We add axioms:
37-
// a1 : -1 <= index<|str|
37+
// a1 : -1 <= index < |str|
3838
// a2 : !contains <=> index=-1
39-
// a3 : contains => from_index<=index&&str[index]=c
40-
// a4 : forall n, from_index<=n<index. contains => str[n]!=c
41-
// a5 : forall m, from_index<=n<|str|. !contains => str[m]!=c
39+
// a3 : contains ==> from_index <= index && str[index] = c
40+
// a4 : forall n, n:[from_index,index[. contains ==> str[n] != c
41+
// a5 : forall m, n:[from_index,|str|[. !contains ==> str[m] != c
4242

4343
exprt minus1=from_integer(-1, index_type);
4444
and_exprt a1(
@@ -102,14 +102,14 @@ exprt string_constraint_generatort::add_axioms_for_index_of_string(
102102
symbol_exprt contains=fresh_boolean("contains_substring");
103103

104104
// We add axioms:
105-
// a1 : contains => from_index <= offset <= |haystack|-|needle|
105+
// a1 : contains ==> from_index <= offset <= |haystack|-|needle|
106106
// a2 : !contains <=> offset=-1
107107
// a3 : forall n:[0,|substring|[.
108-
// contains => haystack[n+offset]=needle[n]
108+
// contains ==> haystack[n+offset]=needle[n]
109109
// a4 : forall n:[from_index,offset[.
110-
// contains => (exists m:[0,|needle|[. haystack[m+n]!=needle[m]])
110+
// contains ==> (exists m:[0,|needle|[. haystack[m+n] != needle[m]])
111111
// a5: forall n:[from_index,|haystack|-|needle|[.
112-
// !contains => (exists m:[0,|needle|[. haystack[m+n]!=needle[m])
112+
// !contains ==> (exists m:[0,|needle|[. haystack[m+n] != needle[m])
113113

114114
implies_exprt a1(
115115
contains,
@@ -161,9 +161,9 @@ exprt string_constraint_generatort::add_axioms_for_index_of_string(
161161
// Unfold the existential quantifier as a disjunction in case of a constant
162162
// a4 && a5 <=> a6:
163163
// forall n:[from_index,|haystack|-|needle|].
164-
// !contains || n < offset =>
165-
// haystack[n]!=needle[0] || ... ||
166-
// haystack[n+|needle|-1]!=needle[|needle|-1]
164+
// !contains || n < offset ==>
165+
// haystack[n] != needle[0] || ... ||
166+
// haystack[n+|needle|-1] != needle[|needle|-1]
167167
symbol_exprt qvar2=fresh_univ_index("QA_index_of_string_2", index_type);
168168
mp_integer sub_length;
169169
assert(!to_integer(needle.length(), sub_length));
@@ -220,16 +220,16 @@ exprt string_constraint_generatort::add_axioms_for_last_index_of_string(
220220
symbol_exprt contains=fresh_boolean("contains_substring");
221221

222222
// We add axioms:
223-
// a1 : contains => offset <= from_index && offset <= |haystack| - |needle|
224-
// a2 : !contains <=> offset=-1
223+
// a1 : contains ==> offset <= from_index && offset <= |haystack| - |needle|
224+
// a2 : !contains <=> offset = -1
225225
// a3 : forall n:[0, needle.length[,
226-
// contains => haystack[n+offset]=needle[n]
226+
// contains ==> haystack[n+offset] = needle[n]
227227
// a4 : forall n:[offset+1, min(from_index, |haystack| - |needle|)].
228-
// contains =>
229-
// (exists m:[0,|substring|[. haystack[m+n]!=needle[m]])
228+
// contains ==>
229+
// (exists m:[0,|substring|[. haystack[m+n] != needle[m]])
230230
// a5: forall n:[0, min(from_index, |haystack| - |needle|)].
231-
// !contains =>
232-
// (exists m:[0,|substring|[. haystack[m+n]!=needle[m])
231+
// !contains ==>
232+
// (exists m:[0,|substring|[. haystack[m+n] != needle[m])
233233

234234
implies_exprt a1(
235235
contains,
@@ -283,9 +283,9 @@ exprt string_constraint_generatort::add_axioms_for_last_index_of_string(
283283
// Unfold the existential quantifier as a disjunction in case of a constant
284284
// a4 && a5 <=> a6:
285285
// forall n:[0, min(from_index,|haystack|-|needle|)].
286-
// !contains || n > offset =>
287-
// haystack[n]!=needle[0] || ... ||
288-
// haystack[n+|substring|-1]!=needle[|substring|-1]
286+
// !contains || n > offset ==>
287+
// haystack[n] != needle[0] || ... ||
288+
// haystack[n+|substring|-1] != needle[|substring|-1]
289289
symbol_exprt qvar2=fresh_univ_index("QA_index_of_string_2", index_type);
290290
mp_integer sub_length;
291291
assert(!to_integer(needle.length(), sub_length));
@@ -384,10 +384,10 @@ exprt string_constraint_generatort::add_axioms_for_last_index_of(
384384

385385
// We add axioms:
386386
// a1 : -1 <= i <= from_index
387-
// a2 : (i=-1 <=> !contains)
388-
// a3 : (contains => i <= from_index &&s[i]=c)
389-
// a4 : forall n. i+1 <= n < from_index +1 &&contains => s[n]!=c
390-
// a5 : forall m. 0 <= m < from_index +1 &&!contains => s[m]!=c
387+
// a2 : i = -1 <=> !contains
388+
// a3 : contains ==> (i <= from_index && s[i] = c)
389+
// a4 : forall n:[i+1, from_index+1[ && contains ==> s[n] != c
390+
// a5 : forall m:[0, from_index+1[ && !contains ==> s[m] != c
391391

392392
exprt index1=from_integer(1, index_type);
393393
exprt minus1=from_integer(-1, index_type);

0 commit comments

Comments
 (0)