@@ -266,8 +266,18 @@ string_exprt string_constraint_generatort::add_axioms_from_int(
266
266
267
267
for (size_t size=1 ; size<=max_size; size++)
268
268
{
269
- // For each possible size, we add axioms:
270
- // a5 : forall 1 <= j < size. '0' <= res[j] <= '9' && sum == 10 * (sum/10)
269
+ // For each possible size, we have:
270
+ // sum_0 = starts_with_digit ? res[0]-'0' : 0
271
+ // sum_j = 10 * sum_{j-1} + res[i] - '0'
272
+ // and add axioms:
273
+ // a5 : |res| == size =>
274
+ // forall 1 <= j < size.
275
+ // is_number && (j >= max_size-2 => no_overflow)
276
+ // where is_number := '0' <= res[j] <= '9'
277
+ // and no_overflow := sum_{j-1} = (10 * sum_{j-1} / 10)
278
+ // && sum_j >= sum_{j - 1}
279
+ // (the first part avoid overflows in multiplication and
280
+ // the second one in additions)
271
281
// a6 : |res| == size && '0' <= res[0] <= '9' => i == sum
272
282
// a7 : |res| == size && res[0] == '-' => i == -sum
273
283
@@ -300,8 +310,8 @@ string_exprt string_constraint_generatort::add_axioms_from_int(
300
310
}
301
311
302
312
equal_exprt premise=res.axiom_for_has_length (size);
303
- exprt a5= conjunction (digit_constraints);
304
- axioms.push_back (implies_exprt (premise, a5) );
313
+ implies_exprt a5 (premise, conjunction (digit_constraints) );
314
+ axioms.push_back (a5 );
305
315
306
316
implies_exprt a6 (
307
317
and_exprt (premise, starts_with_digit), equal_exprt (i, sum));
0 commit comments