26
26
27
27
Constructor: string_refinementt
28
28
29
- Inputs: a namespace, a decision procedure, a bound on the number
30
- of refinements and a boolean flag `concretize_result`
29
+ Inputs:
30
+ _ns - a namespace
31
+ _prop - a decision procedure
32
+ refinement_bound - a bound on the number of refinements
31
33
32
34
Purpose: refinement_bound is a bound on the number of refinement allowed.
33
- if `concretize_result` is set to true, at the end of the decision
34
- procedure, the solver try to find a concrete value for each
35
- character
36
35
37
36
\*******************************************************************/
38
37
@@ -167,15 +166,17 @@ void string_refinementt::add_instantiations()
167
166
168
167
Function: string_refinementt::add_symbol_to_symbol_map()
169
168
170
- Inputs: a symbol and the expression to map it to
169
+ Inputs:
170
+ lhs - a symbol expression
171
+ rhs - an expression to map it to
171
172
172
173
Purpose: keeps a map of symbols to expressions, such as none of the
173
174
mapped values exist as a key
174
175
175
176
\*******************************************************************/
176
177
177
- void string_refinementt::add_symbol_to_symbol_map
178
- ( const exprt &lhs, const exprt &rhs)
178
+ void string_refinementt::add_symbol_to_symbol_map (
179
+ const exprt &lhs, const exprt &rhs)
179
180
{
180
181
assert (lhs.id ()==ID_symbol);
181
182
@@ -259,6 +260,21 @@ exprt string_refinementt::substitute_function_applications(exprt expr)
259
260
return expr;
260
261
}
261
262
263
+ /* ******************************************************************\
264
+
265
+ Function: string_refinementt::is_char_array
266
+
267
+ Inputs:
268
+ type - a type
269
+
270
+ Outputs: true if the given type is an array of java characters
271
+
272
+ Purpose: distinguish char array from other types
273
+
274
+ TODO: this is only for java char array and does not work for other languages
275
+
276
+ \*******************************************************************/
277
+
262
278
bool string_refinementt::is_char_array (const typet &type) const
263
279
{
264
280
if (type.id ()==ID_symbol)
@@ -269,18 +285,20 @@ bool string_refinementt::is_char_array(const typet &type) const
269
285
270
286
/* ******************************************************************\
271
287
272
- Function: string_refinementt::boolbv_set_equality_to_true
288
+ Function: string_refinementt::add_axioms_for_string_assigns
273
289
274
- Inputs: the lhs and rhs of an equality expression
290
+ Inputs:
291
+ lhs - left hand side of an equality expression
292
+ rhs - right and side of the equality
275
293
276
294
Outputs: false if the lemmas were added successfully, true otherwise
277
295
278
296
Purpose: add lemmas to the solver corresponding to the given equation
279
297
280
298
\*******************************************************************/
281
299
282
- bool string_refinementt::add_axioms_for_string_assigns (const exprt &lhs,
283
- const exprt &rhs)
300
+ bool string_refinementt::add_axioms_for_string_assigns (
301
+ const exprt &lhs, const exprt &rhs)
284
302
{
285
303
if (is_char_array (rhs.type ()))
286
304
{
@@ -443,6 +461,8 @@ void string_refinementt::set_to(const exprt &expr, bool value)
443
461
{
444
462
debug () << " (sr::set_to) WARNING: ignoring "
445
463
<< from_expr (expr) << " [inconsistent types]" << eom;
464
+ debug () << " lhs has type: " << eq_expr.lhs ().type ().pretty (12 ) << eom;
465
+ debug () << " rhs has type: " << eq_expr.rhs ().type ().pretty (12 ) << eom;
446
466
return ;
447
467
}
448
468
@@ -1037,16 +1057,17 @@ void string_refinementt::substitute_array_access(exprt &expr) const
1037
1057
}
1038
1058
1039
1059
auto op_it=++array_expr.operands ().rbegin ();
1060
+
1040
1061
for (size_t i=last_index-1 ;
1041
1062
op_it!=array_expr.operands ().rend (); ++op_it, --i)
1042
1063
{
1043
1064
equal_exprt equals (index_expr.index (), from_integer (i, java_int_type ()));
1044
- ite=if_exprt (equals, *op_it, ite);
1045
- if (ite.type ()!=char_type)
1065
+ if (op_it->type ()!=char_type)
1046
1066
{
1047
- assert (ite. id ()==ID_unknown);
1048
- ite. type ()=char_type;
1067
+ assert (op_it-> id ()==ID_unknown);
1068
+ op_it-> type ()=char_type;
1049
1069
}
1070
+ ite=if_exprt (equals, *op_it, ite);
1050
1071
}
1051
1072
expr=ite;
1052
1073
}
@@ -1752,7 +1773,7 @@ exprt string_refinementt::substitute_array_lists(exprt expr) const
1752
1773
expr.operands ()[0 ],
1753
1774
expr.operands ()[1 ]);
1754
1775
1755
- for (size_t i=2 ; i<expr.operands ().size ()/2 ; i++)
1776
+ for (size_t i=1 ; i<expr.operands ().size ()/2 ; i++)
1756
1777
{
1757
1778
ret_expr=with_exprt (ret_expr,
1758
1779
expr.operands ()[i*2 ],
0 commit comments