Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
frama-c
Commits
a09622ff
Commit
a09622ff
authored
8 years ago
by
Julien Signoles
Browse files
Options
Downloads
Patches
Plain Diff
[doc] better introduction for the new modules
parent
cddbb16b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/plugins/e-acsl/interval.mli
+43
-12
43 additions, 12 deletions
src/plugins/e-acsl/interval.mli
src/plugins/e-acsl/typing.mli
+21
-1
21 additions, 1 deletion
src/plugins/e-acsl/typing.mli
with
64 additions
and
13 deletions
src/plugins/e-acsl/interval.mli
+
43
−
12
View file @
a09622ff
...
...
@@ -22,31 +22,62 @@
(** Interval inference for terms.
Compute the smallest interval that fits to contain all the possible values
of a given integer term. *)
Compute the smallest interval that contains all the possible values of a
given integer term. The interval of C variables is directly infered from
their C type. The interval of logic variables must be registered from
outside before computing the interval of a term containing such variables
(see module {!Interval.Env}).
It implement Figure 3 of J. Signoles' JFLA'15 paper "Rester statique pour
devenir plus rapide, plus précis et plus mince".
Example: consider a variable [x] of type [int] on a (strange) architecture
in which values of type [int] belongs to the interval [[-128;127]] and a
logic variable [[y] which was registered in the environment with an interval
[[-32;31]]. Then here are the intervals computed from the term
[1+(x+1)/(y-64)]:
1. x \in [[128;127]];
2. x+1 \in [[129;128]];
3. y \in [[-32;31]];
4. y-64 \in [[-96;-33]];
5. (x+1)/(y-64) \in [[-3;3]];
6. 1+(x+1)/(y-64) \in [[-2;4]] *)
type
interv
=
private
{
lower
:
Integer
.
t
;
upper
:
Integer
.
t
}
include
Datatype
.
S
with
type
t
=
interv
(** Environment for interval computations. *)
module
Env
:
sig
val
clear
:
unit
->
unit
val
add
:
Cil_types
.
logic_var
->
interv
->
unit
(** Map an interval to a given logic variable *)
end
(* ************************************************************************** *)
(** {3 Intervals as a lattice} *)
(* ************************************************************************** *)
val
join
:
t
->
t
->
t
val
meet
:
t
->
t
->
t
(* ************************************************************************** *)
(** {3 Useful operations on intervals} *)
(* ************************************************************************** *)
val
interv_of_typ
:
Cil_types
.
typ
->
t
(** @return the smallest interval which contains the given C type. *)
val
add
:
t
->
Integer
.
t
->
t
(** Extend an interval in order to contain the given integer. *)
(** @return the minimal interval containing both the interval and the integer
given as arguments. *)
(** {3 Intervals as a lattice} *)
(* ************************************************************************** *)
(** {3 Environment for interval computations} *)
(* ************************************************************************** *)
val
join
:
t
->
t
->
t
val
meet
:
t
->
t
->
t
(** Environment which maps logic variables to intervals. This environment must
be extended from outside. *)
module
Env
:
sig
val
clear
:
unit
->
unit
val
add
:
Cil_types
.
logic_var
->
interv
->
unit
end
(* ************************************************************************** *)
(** {3 Inference system} *)
(* ************************************************************************** *)
exception
Not_an_integer
val
infer
:
Cil_types
.
term
->
t
...
...
This diff is collapsed.
Click to expand it.
src/plugins/e-acsl/typing.mli
+
21
−
1
View file @
a09622ff
...
...
@@ -22,7 +22,27 @@
(** Type system which computes the smallest C type that may contain all the
possible values of a given integer term or predicate. Also compute the
required casts. *)
required casts. It is based on interval inference of module {!Interval}.
It implement Figure 4 of J. Signoles' JFLA'15 paper "Rester statique pour
devenir plus rapide, plus précis et plus mince".
Example: consider a variable [x] of type [int] and a variable [y] of type
char on a (strange) architecture in which values of type [int] belongs to
the interval [[-128;127]] and values of type [char] belongs to the interval
[[-32;31]], while there are no other integral types. Then here are some
information computed from the term [1+(x+1)/(y-64)] by the type system:
1. [x+1] must be a GMP (because of the potential overflow)
2. consequently [x], which is an [int], must be coerced into a GMP and the
same for the number 1 in this addition.
3. [y-64] can be computed in an [int] (because the result belongs to the
interval [[-96;-33]]).
4. [(x+1)/(y-64)] must be a GMP operation because the numerator is a
GMP (see 1.). Consequently [y-64] must be coerced into a GMP too. However,
the result belongs to the interval [[-3;3]] and thus can be safely coerced
to an [int].
5. Consequently the addition of the toplevel term [1+(x+1)/(y-64)] can
safely be computed in [int]: its result belongs to [[-2;4]]. *)
open
Cil_types
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment