@@ -228,42 +228,39 @@ string_exprt string_constraint_generatort::add_axioms_from_bool(
228
228
const exprt &b, const refined_string_typet &ref_type)
229
229
{
230
230
string_exprt res=fresh_string (ref_type);
231
- const typet &index_type =ref_type.get_index_type ();
231
+ const typet &char_type =ref_type.get_char_type ();
232
232
233
233
assert (b.type ()==bool_typet () || b.type ().id ()==ID_c_bool);
234
234
235
235
typecast_exprt eq (b, bool_typet ());
236
236
237
- string_exprt true_string=add_axioms_for_constant (" true" , ref_type);
238
- string_exprt false_string=add_axioms_for_constant (" false" , ref_type);
239
-
240
237
// We add axioms:
241
238
// a1 : eq => res = |"true"|
242
239
// a2 : forall i < |"true"|. eq => res[i]="true"[i]
243
240
// a3 : !eq => res = |"false"|
244
241
// a4 : forall i < |"false"|. !eq => res[i]="false"[i]
245
242
246
- implies_exprt a1 (eq, res.axiom_for_has_same_length_as (true_string));
243
+ std::string str_true=" true" ;
244
+ implies_exprt a1 (eq, res.axiom_for_has_length (str_true.length ()));
247
245
axioms.push_back (a1);
248
- symbol_exprt qvar=fresh_univ_index (" QA_equal_true" , index_type);
249
- string_constraintt a2 (
250
- qvar,
251
- true_string.length (),
252
- eq,
253
- equal_exprt (res[qvar], true_string[qvar]));
254
- axioms.push_back (a2);
255
246
256
- implies_exprt a3 (
257
- not_exprt (eq), res.axiom_for_has_same_length_as (false_string));
247
+ for (std::size_t i=0 ; i<str_true.length (); i++)
248
+ {
249
+ exprt chr=from_integer (str_true[i], char_type);
250
+ implies_exprt a2 (eq, equal_exprt (res[i], chr));
251
+ axioms.push_back (a2);
252
+ }
253
+
254
+ std::string str_false=" false" ;
255
+ implies_exprt a3 (not_exprt (eq), res.axiom_for_has_length (str_false.length ()));
258
256
axioms.push_back (a3);
259
257
260
- symbol_exprt qvar1=fresh_univ_index (" QA_equal_false" , index_type);
261
- string_constraintt a4 (
262
- qvar,
263
- false_string.length (),
264
- not_exprt (eq),
265
- equal_exprt (res[qvar1], false_string[qvar1]));
266
- axioms.push_back (a4);
258
+ for (std::size_t i=0 ; i<str_false.length (); i++)
259
+ {
260
+ exprt chr=from_integer (str_false[i], char_type);
261
+ implies_exprt a4 (not_exprt (eq), equal_exprt (res[i], chr));
262
+ axioms.push_back (a4);
263
+ }
267
264
268
265
return res;
269
266
}
0 commit comments