@@ -349,18 +349,28 @@ module Enums : S with type int_t = Z.t = struct
349349 10 , QCheck. map pos (BISet. arbitrary () );
350350 ] (* S TODO: decide frequencies *)
351351
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+
352358 let refine_with_congruence ik a b =
353359 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
354360 match a, b with
355361 | Inc e , None -> bot_of ik
356362 | Inc e , Some (c , m ) -> Inc (BISet. filter (contains c m) e)
357363 | _ -> a
358364
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
360370
361371 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? *)
364374 | _ -> a
365375
366376 let refine_with_incl_list ik a b =
0 commit comments