module Int_val:sig
..end
Integer values abstractions: an abstraction represents a set of integers. Provided with a lattice structure and over-approximations of arithmetic operations.
Abstractions do not represent the empty set. Instead, operations creating empty sets return `Bottom.
include Datatype.S_with_collections
module Widen_Hints: Datatype.Integer.Set
typesize_widen_hint =
Integer.t
typegeneric_widen_hint =
Widen_Hints.t
include Eva_lattice_type.Full_AI_Lattice_with_cardinality
val zero : t
val one : t
val minus_one : t
val zero_or_one : t
val positive_integers : t
All positive integers, including 0.
val negative_integers : t
All negative integers, including 0.
val inject_singleton : Integer.t -> t
Returns an exact abstraction of the given integer.
val inject_range : Integer.t option -> Integer.t option -> t
inject_range min max
returns an abstraction of all integers between
min
and max
included. None
means that the abstraction is unbounded.
val inject_interval : min:Integer.t option ->
max:Integer.t option -> rem:Integer.t -> modu:Integer.t -> t
Builds an abstraction of all integers between min
and max
included and
congruent to rem
modulo modu
. For min
and max
, None
is the
corresponding infinity. Checks that min
<= max
, modu
> 0 and
0 <= rest
< modu
, and fails otherwise. If possible, reduces min
and
max
according to the modulo.
val make : min:Integer.t option ->
max:Integer.t option -> rem:Integer.t -> modu:Integer.t -> t
As inject_interval
, but also checks that min
and max
are congruent to
rem
modulo modu
.
val min_int : t -> Integer.t option
Returns the smallest integer represented by an abstraction. Returns None if it does not exist, i.e. if the abstraction is unbounded.
val max_int : t -> Integer.t option
Returns the highest integer represented by an abstraction. Returns None if it does not exist, i.e. if the abstraction is unbouded.
val min_and_max : t -> Integer.t option * Integer.t option
Returns the smallest and highest integers represented by an abstraction.
val min_max_rem_modu : t -> Integer.t option * Integer.t option * Integer.t * Integer.t
Returns min, max, rem, modu
such that for all integers i
represented by
the given abstraction, i
satisfies min ≤ i ≤ max and i ≅ rem modu
.
exception Not_Singleton
val project_int : t -> Integer.t
Projects a singleton abstraction into an integer.
Not_Singleton
if the cardinal of the argument is not 1.val is_small_set : t -> bool
Is an abstraction internally represented as a small integer set?
val project_small_set : t -> Integer.t list option
val is_singleton : t -> bool
val cardinal_zero_or_one : t -> bool
val cardinal : t -> Integer.t option
val cardinal_estimate : size:Integer.t -> t -> Integer.t
val cardinal_less_than : t -> int -> int
val cardinal_is_less_than : t -> int -> bool
val is_zero : t -> bool
val contains_zero : t -> bool
val contains_non_zero : t -> bool
val add : t -> t -> t
Addition of two integer abstractions.
val add_under : t -> t -> t Bottom.Type.or_bottom
Under-approximation of the addition of two integer abstractions
val add_singleton : Integer.t -> t -> t
Addition of an integer abstraction with a singleton integer. Exact operation.
val neg : t -> t
Negation of an integer abstraction.
val abs : t -> t
Absolute value of an integer abstraction.
val scale : Integer.t -> t -> t
scale f v
returns an abstraction of the integers f * x
for all x
in v
. This operation is exact.
val scale_div : pos:bool -> Integer.t -> t -> t
scale_div f v
is an over-approximation of the elements x / f
for all
elements x
in v
. Uses the computer division (like in C99) if pos
is
false, and the euclidean division if pos
is true.
val scale_div_under : pos:bool -> Integer.t -> t -> t Bottom.Type.or_bottom
Under-approximation of the division.
val scale_rem : pos:bool -> Integer.t -> t -> t
Over-approximation of the remainder of the division. Uses the computer
division (like in C99) if pos
is false, and the euclidean division if
pos
is true.
val mul : t -> t -> t
val div : t -> t -> t Bottom.Type.or_bottom
val c_rem : t -> t -> t Bottom.Type.or_bottom
val shift_left : t -> t -> t Bottom.Type.or_bottom
val shift_right : t -> t -> t Bottom.Type.or_bottom
val bitwise_and : t -> t -> t
val bitwise_or : t -> t -> t
val bitwise_xor : t -> t -> t
val bitwise_signed_not : t -> t
val bitwise_unsigned_not : size:int -> t -> t
val cast_int_to_int : size:Integer.t -> signed:bool -> t -> t
val subdivide : t -> t * t
Splits an abstraction into two abstractions.
val extract_bits : start:Integer.t -> stop:Integer.t -> t -> t
Extracts bits from start
to stop
from the given integer abstraction,
start
and stop
being included.
val create_all_values : signed:bool -> size:int -> t
Builds an abstraction of all integers in a C integer type.
val all_values : size:Integer.t -> t -> bool
all_values ~size v
returns true iff v contains all integer values
representable in size
bits.
val overlaps : partial:bool -> size:Integer.t -> t -> t -> bool
val complement_under : size:int -> signed:bool -> t -> t Bottom.Type.or_bottom
Returns an under-approximation of the integers of the given size and signedness that are *not* represented by the given value.
val fold_int : ?increasing:bool -> (Integer.t -> 'a -> 'a) -> t -> 'a -> 'a
Iterates on all integers represented by an abstraction, in increasing order
by default. If increasing
is set to false, iterate by decreasing order.
Abstract_interp.Error_Top
if the abstraction is unbounded.