14
14
#include < solvers/refinement/string_refinement_invariant.h>
15
15
#include < solvers/refinement/string_constraint_generator.h>
16
16
17
- // / add axioms to say that the returned string expression has length given by
18
- // / the second argument and whose characters are equal to those of the first
19
- // / argument for the positions which are defined in both strings
20
- // / \par parameters: function application with two arguments, the first of which
21
- // / is
22
- // / a string and the second an integer which should have same type has
23
- // / return by get_index_type()
24
- // / \return a new string expression
17
+ // / add axioms to say that the returned string expression `res` has length `k`
18
+ // / and characters at position `i` in `res` are equal to the character at
19
+ // / position `i` in `s1` if `i` is smaller that the length of `s1`, otherwise
20
+ // / it is the null character `\u0000`.
21
+ // / \param f: function application with two arguments, the first of which
22
+ // / is a string `s1` and the second an integer `k` which should have
23
+ // / same type as the string length
24
+ // / \return a new string expression `res`
25
25
string_exprt string_constraint_generatort::add_axioms_for_set_length (
26
26
const function_application_exprt &f)
27
27
{
@@ -32,26 +32,26 @@ string_exprt string_constraint_generatort::add_axioms_for_set_length(
32
32
33
33
// We add axioms:
34
34
// a1 : |res|=k
35
- // a2 : forall i<|s1 |. i < |res | ==> res[i] = s1[i]
36
- // a3 : forall i<|s1 |. i >= |res | ==> res[i] = 0
35
+ // a2 : forall i<|res |. i < |s1 | ==> res[i] = s1[i]
36
+ // a3 : forall i<|res |. i >= |s1 | ==> res[i] = 0
37
37
38
38
axioms.push_back (res.axiom_for_has_length (k));
39
39
40
40
symbol_exprt idx=fresh_univ_index (
41
41
" QA_index_set_length" , ref_type.get_index_type ());
42
42
string_constraintt a2 (
43
43
idx,
44
- s1 .length (),
45
- res .axiom_for_is_strictly_longer_than (idx),
44
+ res .length (),
45
+ s1 .axiom_for_is_strictly_longer_than (idx),
46
46
equal_exprt (s1[idx], res[idx]));
47
47
axioms.push_back (a2);
48
48
49
49
symbol_exprt idx2=fresh_univ_index (
50
50
" QA_index_set_length2" , ref_type.get_index_type ());
51
51
string_constraintt a3 (
52
52
idx2,
53
- s1 .length (),
54
- res .axiom_for_is_shorter_than (idx2),
53
+ res .length (),
54
+ s1 .axiom_for_is_shorter_than (idx2),
55
55
equal_exprt (res[idx2], constant_char (0 , ref_type.get_char_type ())));
56
56
axioms.push_back (a3);
57
57
0 commit comments