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
deaf8115
Commit
deaf8115
authored
4 years ago
by
David Bühler
Browse files
Options
Downloads
Patches
Plain Diff
[Eva] Improves the evaluation of ACSL quantifications.
parent
033c5fb0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/plugins/value/legacy/eval_terms.ml
+45
-8
45 additions, 8 deletions
src/plugins/value/legacy/eval_terms.ml
with
45 additions
and
8 deletions
src/plugins/value/legacy/eval_terms.ml
+
45
−
8
View file @
deaf8115
...
...
@@ -335,6 +335,25 @@ let bind_logic_vars env lvs =
let
state
,
logic_vars
=
List
.
fold_left
bind_one
(
state
,
env
.
logic_vars
)
lvs
in
overwrite_current_state
{
env
with
logic_vars
}
state
let
copy_logic_vars
~
src
~
dst
lvars
=
let
copy_one
env
lvar
=
match
Logic_utils
.
unroll_type
lvar
.
lv_type
with
|
Linteger
|
Lreal
->
let
value
=
LogicVarEnv
.
find
lvar
src
.
logic_vars
in
let
logic_vars
=
LogicVarEnv
.
add
lvar
value
env
.
logic_vars
in
{
env
with
logic_vars
}
|
_
->
try
let
base
,
_
=
c_logic_var
lvar
in
match
Model
.
find_base
base
(
env_current_state
src
)
with
|
`Bottom
|
`Top
->
env
|
`Value
offsm
->
let
state
=
Model
.
add_base
base
offsm
(
env_current_state
env
)
in
overwrite_current_state
env
state
with
Cil
.
SizeOfError
_
->
unsupported_lvar
lvar
in
List
.
fold_left
copy_one
dst
lvars
let
unbind_logic_vars
env
lvs
=
let
unbind_one
(
state
,
logic_vars
)
lv
=
match
Logic_utils
.
unroll_type
lv
.
lv_type
with
...
...
@@ -2417,14 +2436,32 @@ and eval_predicate env pred =
|
Pforall
(
varl
,
p'
)
|
Pexists
(
varl
,
p'
)
->
begin
try
let
env
=
bind_logic_vars
env
varl
in
let
r
=
do_eval
env
p'
in
match
p
.
pred_content
with
|
Pexists
_
->
if
r
=
False
then
False
else
Unknown
|
Pforall
_
->
if
r
=
True
then
True
else
Unknown
|
_
->
assert
false
with
LogicEvalError
_ee
->
Unknown
(* No error display? *)
(* If [p'] is true (or false) for all possible values of [varl],
then so is Pforall(varl, p') and Pexists(varl, p'). *)
let
env
=
bind_logic_vars
env
varl
in
let
r
=
do_eval
env
p'
in
if
r
<>
Unknown
then
r
else
(* Otherwise:
- if [p'] evaluates to [false] for at least some values of [varl],
then Pforall (varl, p') is false.
- if [p'] evaluates to [true] for at least some values of [varl],
then Pexists (varl, p') is true.
In order to find such values, we reduce the environment by assuming
[p'] is true (for Pexists) or false (for Pforall), and then we
reevaluate [p'] with these values. *)
let
positive
=
match
p
.
pred_content
with
Pforall
_
->
false
|
_
->
true
in
let
reduced_env
=
reduce_by_predicate
~
alarm_mode
env
positive
p'
in
(* Reduce the values of logical variables [varl] in [env] according to
[reduced_env]. To be more precise, we could reduce them to
singleton values — for instance by using the interval bounds. *)
let
env
=
copy_logic_vars
~
src
:
reduced_env
~
dst
:
env
varl
in
match
p
.
pred_content
,
do_eval
env
p'
with
|
Pexists
_
,
True
->
True
|
Pforall
_
,
False
->
False
|
_
->
Unknown
end
|
Pnot
p
->
begin
match
do_eval
env
p
with
...
...
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