Skip to content

Commit 7fa229b

Browse files
Update comments in add_axioms_from_int to reflect changes in the code
1 parent 15e88e7 commit 7fa229b

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/solvers/refinement/string_constraint_generator_valueof.cpp

+14-4
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,18 @@ string_exprt string_constraint_generatort::add_axioms_from_int(
266266

267267
for(size_t size=1; size<=max_size; size++)
268268
{
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)
271281
// a6 : |res| == size && '0' <= res[0] <= '9' => i == sum
272282
// a7 : |res| == size && res[0] == '-' => i == -sum
273283

@@ -300,8 +310,8 @@ string_exprt string_constraint_generatort::add_axioms_from_int(
300310
}
301311

302312
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);
305315

306316
implies_exprt a6(
307317
and_exprt(premise, starts_with_digit), equal_exprt(i, sum));

0 commit comments

Comments
 (0)