Skip to content

Commit 66ce359

Browse files
committed
Address review
1 parent daf0c49 commit 66ce359

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

src/lib/reasoners/bitlist.ml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,10 @@ let fold_domain f b acc =
265265
in
266266
fold_domain_aux 0 b acc
267267

268-
(* simple propagator: only compute known low bits *)
268+
(* simple propagator: only compute known low bits
269+
270+
Example: ???100 * ???000 = ?00000 (trailing zeroes accumulate)
271+
???111 * ????11 = ????01 (min of low bits known) *)
269272
let mul a b =
270273
let sz = width a in
271274
assert (width b = sz);
@@ -278,6 +281,7 @@ let mul a b =
278281
if zeroes_a + zeroes_b >= sz then
279282
exact sz Z.zero ex
280283
else
284+
(* Factor out the low zeroes *)
281285
let low_bits =
282286
if zeroes_a + zeroes_b = 0 then empty
283287
else exact (zeroes_a + zeroes_b) Z.zero ex
@@ -286,7 +290,10 @@ let mul a b =
286290
assert (width a + width low_bits = sz);
287291
let b = extract b zeroes_b (zeroes_b + sz - width low_bits - 1) in
288292
assert (width b + width low_bits = sz);
289-
(* ((ah * 2^n) + al) * ((bh * 2^m) + bl) =
293+
(* a = ah * 2^n + al (0 <= al < 2^n)
294+
b = bh * 2^m + bl (0 <= bl < 2^m)
295+
296+
((ah * 2^n) + al) * ((bh * 2^m) + bl) =
290297
al * bl (mod 2^(min n m)) *)
291298
let low_a_known = Z.trailing_zeros @@ Z.lognot @@ bits_known a in
292299
let low_b_known = Z.trailing_zeros @@ Z.lognot @@ bits_known b in

src/lib/reasoners/bitlist.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ val logxor : t -> t -> t
119119
(** Bitwise xor. *)
120120

121121
val mul : t -> t -> t
122-
(** Multiplication. *)
122+
(** Integer multiplication. *)
123123

124124
val concat : t -> t -> t
125125
(** Bit-vector concatenation. *)

src/lib/reasoners/bitv_rel.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,8 +409,8 @@ end = struct
409409

410410
let propagate_less_than ~ex ~strict dx dy =
411411
let open Interval_domains.Ephemeral in
412-
(* Do not use [update] to make sure that the justification is only stored on
413-
the upper/lower bound. *)
412+
(* Add justification prior to calling [update] to ensure that it is only
413+
stored on the appropriate bound. *)
414414
update ~ex:Ex.empty dx (less_than_sup ~ex ~strict !!dy);
415415
update ~ex:Ex.empty dy (greater_than_inf ~ex ~strict !!dx)
416416

0 commit comments

Comments
 (0)