@@ -398,12 +398,13 @@ exprt string_constraint_generatort::add_axioms_for_char_set(
398
398
399
399
// / Add axioms ensuring that the result `res` is similar to input string `str`
400
400
// / where the character at index `pos` is set to `char`.
401
+ // / If `pos` is out of bounds the string returned unchanged.
401
402
// /
402
403
// / These axioms are:
403
- // / 1. \f$ |{\tt res}| = |{\tt str}|\f$
404
- // / 2. \f$ {\tt res}[{\tt pos}]={\tt char}\f$
405
- // / 3. \f$ \ forall i < min(|{\tt res}| , pos). {\tt res} [i] = {\tt str} [i]\f$
406
- // / 4. \f$ \ forall pos+1 <= i < |{\tt res}|.\ {\tt res} [i] = {\tt str} [i]\f$
404
+ // / 1. res.length = str.length
405
+ // / 2. 0 <= pos < res.length ==> res[ pos]= char
406
+ // / 3. forall i < min(res.length , pos). res[i] = str[i]
407
+ // / 4. forall pos+1 <= i < res.length. res[i] = str[i]
407
408
// / \return an integer expression which is `1` when `pos` is out of bounds and
408
409
// / `0` otherwise
409
410
exprt string_constraint_generatort::add_axioms_for_set_char (
@@ -414,7 +415,13 @@ exprt string_constraint_generatort::add_axioms_for_set_char(
414
415
{
415
416
const binary_relation_exprt out_of_bounds (position, ID_ge, str.length ());
416
417
lemmas.push_back (equal_exprt (res.length (), str.length ()));
417
- lemmas.push_back (equal_exprt (res[position], character));
418
+ lemmas.push_back (
419
+ implies_exprt (
420
+ and_exprt (
421
+ binary_relation_exprt (
422
+ from_integer (0 , position.type ()), ID_le, position),
423
+ binary_relation_exprt (position, ID_lt, res.length ())),
424
+ equal_exprt (res[position], character)));
418
425
constraints.push_back ([&] {
419
426
const symbol_exprt q = fresh_univ_index (" QA_char_set" , position.type ());
420
427
const equal_exprt a3_body (res[q], str[q]);
0 commit comments