Module Cduce_types.Intervals

Sets of integers represented as disjoint intervals.

module V : sig ... end

A module for manipulating integer Values.

include Tset.S with type elem = V.t
include Tset.Tset_base
type elem

The type of the values in the set

The type of the set, with mandatory custom operations.

include Custom.T
type t
val dump : Stdlib.Format.formatter -> t -> unit
val check : t -> unit
val equal : t -> t -> bool
val hash : t -> int
val compare : t -> t -> int
val empty : t

The empty set

val any : t

The full set, containing all possible values for this kind.

val atom : elem -> t

atom e creates a singleton set containing element e.

Set operations :

val cup : t -> t -> t

cup t1 t2 returns the unions of t1 and t2.

val cap : t -> t -> t

cap t1 t2 returns the intersection of t1 and t2.

val diff : t -> t -> t

diff t1 t2 returns the set of elements of t1 not in t2.

val neg : t -> t

neg t returns the set diff any t.

module Infix : sig ... end

Type specific operations:

val bounded : V.t -> V.t -> t

bounded i j returns the closed interval [ i, j ].

val left : V.t -> t

left j returns the left opened interval ( -∞, j ].

val right : V.t -> t

right i returns the right opened interval [ i, +∞ ).

val add : t -> t -> t

add t1 t2 returns the intervals that are the sums of the individual intervals of t1 and t2. For instance :

(1--2 | 5--10)  + (3--4 | 5--6) = 4--6 | 8--14 | 6--8 | 10--16 
                                = 4--16
val negat : t -> t

negat t negates all the bounds of t

val sub : t -> t -> t

sub t1 t2 subtract two intervals. sub t1 t2 is equivalent to add t1 (negat t2).

val mul : t -> t -> t

mul t1 t2 returns the intervals that are the products of the individual intervals of t1 and t2.

val div : t -> t -> t

div t1 t2 returns any (this is a convenience function).

val modulo : t -> t -> t

modulo t1 t2 returns any (this is a convenience function).

val int32 : t

int32 represent the set of integers representable by an OCaml int32

val int64 : t

int64 represent the set of integers representable by an OCaml int64

val is_bounded : t -> bool * bool

is_bounded t returns a pair of boolean indicating whether the interval is left and right bounded.

Membership:

val is_empty : t -> bool

is_empty t checks wheter t is the empty set.

val contains : V.t -> t -> bool

contains i t checks whether the integer a belongs to t

val single : t -> V.t

single t assumes t is a singleton and returns its unique element.

raises [Not_found]

if t is the empty set

raises [Exit]

if t contains more than one element

val disjoint : t -> t -> bool

disjoint t1 t2 checks whether t1 and t2 have an empty intersection.

val sample : t -> V.t

sample t returns an element of t.

raises [Not_found]

if t is empty.

Formatting functions :

val print : t -> (Stdlib.Format.formatter -> unit) list

print t returns, for each interval in the set t, a function that prints the interval. Left (resp. right) opened intervals are printed as *--n (resp. n--*). Singleton intervals are juste printed as n. The intervals are always disjoints and printed in increasing order of their lower-bound, separated by "|". As a special case, any is printed as Int.