Frama-C API - Int_val
Integer values abstractions: an abstraction represents a set of integers. Provided with a lattice structure and over-approximations of arithmetic operations.
include Datatype.S_with_collections
include Datatype.S
include Datatype.S_no_copy
include Datatype.Ty
module Set : Datatype.Set with type elt = t
module Map : Datatype.Map with type key = t
module Hashtbl : Datatype.Hashtbl with type key = t
include Eva_lattice_type.Full_AI_Lattice_with_cardinality with type t := t
include Eva_lattice_type.AI_Lattice_with_cardinal_one with type t := t
include Eva_lattice_type.Join_Semi_Lattice with type t := t
datatype of element of the lattice
include Datatype.S with type t := t
include Datatype.S_no_copy with type t := t
include Datatype.Ty with type t := t
val packed_descr : Structural_descr.pack
Packed version of the descriptor.
val reprs : t list
List of representants of the descriptor.
val hash : t -> int
Hash function: same spec than Hashtbl.hash
.
val pretty : Stdlib.Format.formatter -> t -> unit
Pretty print each value in an user-friendly way.
val mem_project : (Project_skeleton.t -> bool) -> t -> bool
mem_project f x
must return true
iff there is a value p
of type Project.t
in x
such that f p
returns true
.
include Eva_lattice_type.With_Top with type t := t
val top : t
largest element
include Eva_lattice_type.With_Cardinal_One with type t := t
include Eva_lattice_type.With_Narrow with type t := t
val narrow : t -> t -> t Lattice_bounds.or_bottom
over-approximation of intersection
include Eva_lattice_type.With_Under_Approximation with type t := t
val meet : t -> t -> t Lattice_bounds.or_bottom
under-approximation of intersection
include Eva_lattice_type.With_Intersects with type t := t
include Eva_lattice_type.With_Diff with type t := t
val diff : t -> t -> t Lattice_bounds.or_bottom
diff t1 t2
is an over-approximation of t1-t2
. t2
must be an under-approximation or exact.
include Eva_lattice_type.With_Diff_One with type t := t
val diff_if_one : t -> t -> t Lattice_bounds.or_bottom
diff_if_one t1 t2
is an over-approximation of t1-t2
.
include Eva_lattice_type.With_Enumeration with type t := t
Fold on the elements of the value one by one if possible. Raises Abstract_interp.Not_less_than
when there is an infinite number of elements to enumerate.
type widen_hint = Datatype.Integer.Set.t
Hints for the widening: set of relevant thresholds.
val widen : ?size:Integer.t -> ?hint:widen_hint -> t -> t -> t
widen ~size ~hint t1 t2
is an over-approximation of join t1 t2
. size
is the size (in bits) of the widened value, and hint
is a set of relevant thresholds.
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.
Building.
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.
As inject_interval
, but also checks that min
and max
are congruent to rem
modulo modu
.
Accessors.
Returns the smallest integer represented by an abstraction. Returns None if it does not exist, i.e. if the abstraction is unbounded.
Returns the highest integer represented by an abstraction. Returns None if it does not exist, i.e. if the abstraction is unbouded.
Returns the smallest and highest integers represented by an abstraction.
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
.
val is_small_set : t -> bool
Is an abstraction internally represented as a small integer set?
Cardinality.
val is_singleton : t -> bool
val cardinal_zero_or_one : t -> bool
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
Arithmetics.
val add_under : t -> t -> t Lattice_bounds.or_bottom
Under-approximation of the addition of two integer abstractions
Addition of an integer abstraction with a singleton integer. Exact operation.
scale f v
returns an abstraction of the integers f * x
for all x
in v
. This operation is exact.
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 Lattice_bounds.or_bottom
Under-approximation of the division.
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 div : t -> t -> t Lattice_bounds.or_bottom
val c_rem : t -> t -> t Lattice_bounds.or_bottom
val shift_left : t -> t -> t Lattice_bounds.or_bottom
val shift_right : t -> t -> t Lattice_bounds.or_bottom
Comparisons
val forward_comp : Abstract_interp.Comp.t -> t -> t -> Abstract_interp.Comp.result
forward_comp op l r
returns the result of the comparison l op r
.
val backward_comp_left : Abstract_interp.Comp.t -> t -> t -> t Lattice_bounds.or_bottom
backward_comp_left op l r
reduces l
by assuming l op r
holds.
Misc
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.
all_values ~size v
returns true iff v contains all integer values representable in size
bits.
val complement_under : size:int -> signed:bool -> t -> t Lattice_bounds.or_bottom
Returns an under-approximation of the integers of the given size and signedness that are *not* represented by the given value.
Iterates on all integers represented by an abstraction, in increasing order by default. If increasing
is set to false, iterate by decreasing order.