@@ -349,18 +349,28 @@ module Enums : S with type int_t = Z.t = struct
349
349
10 , QCheck. map pos (BISet. arbitrary () );
350
350
] (* S TODO: decide frequencies *)
351
351
352
+
353
+ (* One needs to be exceedingly careful here to not cause new elements to appear that are not originally tracked by the domain *)
354
+ (* to avoid breaking the termination guarantee that only constants from the program can appear in exclusion or inclusion sets here *)
355
+ (* What is generally safe is shrinking an inclusion set as no new elements appear here. *)
356
+ (* What is not safe is growing an exclusion set or switching from an exclusion set to an inclusion set *)
357
+
352
358
let refine_with_congruence ik a b =
353
359
let contains c m x = if Z. equal m Z. zero then Z. equal c x else Z. equal (Z. rem (Z. sub x c) m) Z. zero in
354
360
match a, b with
355
361
| Inc e , None -> bot_of ik
356
362
| Inc e , Some (c , m ) -> Inc (BISet. filter (contains c m) e)
357
363
| _ -> a
358
364
359
- let refine_with_interval ik a b = a (* TODO: refine inclusion (exclusion?) set *)
365
+ let refine_with_interval ik a b =
366
+ match a, b with
367
+ | Inc _ , None -> bot_of ik
368
+ | Inc e , Some (l , u ) -> Inc (BISet. filter (value_in_range (l,u)) e)
369
+ | _ -> a
360
370
361
371
let refine_with_excl_list ik a b =
362
- match b with
363
- | Some (ls , _ ) -> meet ik a (of_excl_list ik ls) (* TODO: refine with excl range? *)
372
+ match a, b with
373
+ | Inc _ , Some (ls , _ ) -> meet ik a (of_excl_list ik ls) (* TODO: refine with excl range? *)
364
374
| _ -> a
365
375
366
376
let refine_with_incl_list ik a b =
0 commit comments