Module Int_set

module Int_set: sig .. end

Small sets of integers.

Above a certain limit fixed by set_small_cardinal, these sets must be converted into intervals. The functions that make the set grow returns a set_or_top type : either the resulting sets is small enough, or it is converted into an interval.

Sets are always non-empty. The functions reducing the sets returns a set or_bottom type: either the result is non-empty, or it is `Bottom.


val get_small_cardinal : unit -> int

Returns the limit above which integer sets are converted into intervals.

val set_small_cardinal : int -> unit

Sets the limit above which integer sets are converted into intervals. This is used by the Eva plugin according to the -eva-ilevel option. Do not use.

include Datatype.S_with_collections
val inject_singleton : Integer.t -> t

Creates the set containing only the given integer.

val inject_periodic : from:Integer.t -> period:Integer.t -> number:Integer.t -> t

Creates the set with integers from + k*period for k in

... number-1

. The resulting set contains number integers. There is no verification about number, but it should be stritly positive.

val inject_list : Integer.t list -> t

Creates a set from an integer list. The list must not be empty, and the list length must not exceed the small cardinal limit.

val to_list : t -> Integer.t list

Returns the set as an integer list.

val remove : t -> Integer.t -> t Bottom.Type.or_bottom

Removes an integer from a set. Returns Bottom if the resulting set is empty.

val mem : Integer.t -> t -> bool

mem i s is true iff the set s contains the integer i.

val one : t
val zero : t
val minus_one : t
val zero_or_one : t
val min : t -> Integer.t

Returns the smallest integer of a set.

val max : t -> Integer.t

Returns the highest integer of a set.

val cardinal : t -> int

Returns the number of integers in a set.

Iterators on the integers of a set.

val for_all : (Integer.t -> bool) -> t -> bool
val exists : (Integer.t -> bool) -> t -> bool
val iter : (Integer.t -> unit) -> t -> unit
val fold : ?increasing:bool -> (Integer.t -> 'a -> 'a) -> t -> 'a -> 'a
val map : (Integer.t -> Integer.t) -> t -> t
val filter : (Integer.t -> bool) -> t -> t Bottom.Type.or_bottom
val map_reduce : (Integer.t -> 'a) -> ('a -> 'a -> 'a) -> t -> 'a
type set_or_top = [ `Set of t | `Top of Integer.t * Integer.t * Integer.t ] 

Sets whose cardinal exceeds a certain limit must be converted into intervals. Functions that make sets grow returns either a set small enough, or the information needed to construct the corresponding interval: the smallest and highest elements, and the periodicity of the integers of the set.

type set_or_top_or_bottom = [ `Bottom | `Set of t | `Top of Integer.t * Integer.t * Integer.t ] 
val apply2 : (Integer.t -> Integer.t -> Integer.t) -> t -> t -> set_or_top

apply2 f s1 s2 applies f i1 i2 for all integers i1 in s1 and i2 in s2.

Lattice structure.

val is_included : t -> t -> bool
val join : t -> t -> set_or_top
val link : t -> t -> set_or_top
val meet : t -> t -> t Bottom.Type.or_bottom
val narrow : t -> t -> t Bottom.Type.or_bottom
val intersects : t -> t -> bool
val diff_if_one : t -> t -> t Bottom.Type.or_bottom
val complement_under : min:Integer.t -> max:Integer.t -> t -> set_or_top_or_bottom

Semantics.

See Int_val for more details.

val add_singleton : Integer.t -> t -> t
val add : t -> t -> set_or_top
val add_under : t -> t -> set_or_top
val neg : t -> t
val abs : t -> t
val mul : t -> t -> set_or_top
val c_rem : t -> t -> set_or_top_or_bottom
val scale : Integer.t -> t -> t
val scale_div : pos:bool -> Integer.t -> t -> t
val scale_rem : pos:bool -> Integer.t -> t -> t
val bitwise_signed_not : t -> t

Misc

val subdivide : t -> t * t