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
cbce1008
Commit
cbce1008
authored
3 years ago
by
Patrick Baudin
Browse files
Options
Downloads
Patches
Plain Diff
[WP] fixes Cint.is_positive_or_null for mult
parent
12b43205
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/plugins/wp/Cint.ml
+7
-5
7 additions, 5 deletions
src/plugins/wp/Cint.ml
with
7 additions
and
5 deletions
src/plugins/wp/Cint.ml
+
7
−
5
View file @
cbce1008
...
@@ -147,12 +147,13 @@ let rec is_positive_or_null e = match F.repr e with
...
@@ -147,12 +147,13 @@ let rec is_positive_or_null e = match F.repr e with
|
Logic
.
Fun
(
f
,
[
e
]
)
when
Fun
.
equal
f
f_lnot
->
is_negative
e
|
Logic
.
Fun
(
f
,
[
e
]
)
when
Fun
.
equal
f
f_lnot
->
is_negative
e
|
Logic
.
Fun
(
f
,
es
)
when
Fun
.
equal
f
f_land
->
List
.
exists
is_positive_or_null
es
|
Logic
.
Fun
(
f
,
es
)
when
Fun
.
equal
f
f_land
->
List
.
exists
is_positive_or_null
es
|
Logic
.
Fun
(
f
,
es
)
when
Fun
.
equal
f
f_lor
->
List
.
for_all
is_positive_or_null
es
|
Logic
.
Fun
(
f
,
es
)
when
Fun
.
equal
f
f_lor
->
List
.
for_all
is_positive_or_null
es
|
Logic
.
Fun
(
f
,
es
)
when
Fun
.
equal
f
f_lxor
->
(
match
xor_sign
es
with
|
Some
b
->
b
|
_
->
false
)
|
Logic
.
Fun
(
f
,
es
)
when
Fun
.
equal
f
f_lxor
->
(
match
mul_
xor_sign
es
with
|
Some
b
->
b
|
_
->
false
)
|
Logic
.
Fun
(
f
,
es
)
when
Fun
.
equal
f
f_lsr
||
Fun
.
equal
f
f_lsl
|
Logic
.
Fun
(
f
,
es
)
when
Fun
.
equal
f
f_lsr
||
Fun
.
equal
f
f_lsl
->
List
.
for_all
is_positive_or_null
es
->
List
.
for_all
is_positive_or_null
es
|
_
->
(* try some improvement first then ask to qed *)
|
_
->
(* try some improvement first then ask to qed *)
let
improved_is_positive_or_null
e
=
match
F
.
repr
e
with
let
improved_is_positive_or_null
e
=
match
F
.
repr
e
with
|
Logic
.
Add
es
->
List
.
for_all
is_positive_or_null
es
|
Logic
.
Add
es
->
List
.
for_all
is_positive_or_null
es
|
Logic
.
Mul
es
->
(
match
mul_xor_sign
es
with
|
Some
b
->
b
|
_
->
false
)
|
Logic
.
Mod
(
e1
,
e2
)
when
is_positive
e2
||
is_negative
e2
->
|
Logic
.
Mod
(
e1
,
e2
)
when
is_positive
e2
||
is_negative
e2
->
(* e2<>0 ==> ( 0<=(e1 % e2) <=> 0<=e1 ) *)
(* e2<>0 ==> ( 0<=(e1 % e2) <=> 0<=e1 ) *)
is_positive_or_null
e1
is_positive_or_null
e1
...
@@ -163,20 +164,21 @@ let rec is_positive_or_null e = match F.repr e with
...
@@ -163,20 +164,21 @@ let rec is_positive_or_null e = match F.repr e with
|
Logic
.
No
|
Logic
.
Maybe
->
false
|
Logic
.
No
|
Logic
.
Maybe
->
false
and
is_negative
e
=
match
F
.
repr
e
with
and
is_negative
e
=
match
F
.
repr
e
with
|
Logic
.
Fun
(
f
,
[
e
]
)
when
Fun
.
equal
f
f_lnot
->
is_positive_or_null
e
|
Logic
.
Fun
(
f
,
[
e
]
)
when
Fun
.
equal
f
f_lnot
->
is_positive_or_null
e
|
Logic
.
Fun
(
f
,
es
)
when
Fun
.
equal
f
f_lor
->
List
.
exists
is_negative
es
|
Logic
.
Fun
(
f
,
es
)
when
Fun
.
equal
f
f_lor
->
List
.
exists
is_negative
es
|
Logic
.
Fun
(
f
,
es
)
when
Fun
.
equal
f
f_land
->
List
.
for_all
is_negative
es
|
Logic
.
Fun
(
f
,
es
)
when
Fun
.
equal
f
f_land
->
List
.
for_all
is_negative
es
|
Logic
.
Fun
(
f
,
es
)
when
Fun
.
equal
f
f_lxor
->
(
match
xor_sign
es
with
|
Some
b
->
(
not
b
)
|
_
->
false
)
|
Logic
.
Fun
(
f
,
es
)
when
Fun
.
equal
f
f_lxor
->
(
match
mul_
xor_sign
es
with
|
Some
b
->
(
not
b
)
|
_
->
false
)
|
Logic
.
Fun
(
f
,
[
k
;
n
]
)
when
Fun
.
equal
f
f_lsr
||
Fun
.
equal
f
f_lsl
|
Logic
.
Fun
(
f
,
[
k
;
n
]
)
when
Fun
.
equal
f
f_lsr
||
Fun
.
equal
f
f_lsl
->
is_positive_or_null
n
&&
is_negative
k
->
is_positive_or_null
n
&&
is_negative
k
|
_
->
(* try some improvement first then ask to qed *)
|
_
->
(* try some improvement first then ask to qed *)
let
improved_is_negative
e
=
match
F
.
repr
e
with
let
improved_is_negative
e
=
match
F
.
repr
e
with
|
Logic
.
Add
es
->
List
.
for_all
is_negative
es
|
Logic
.
Add
es
->
List
.
for_all
is_negative
es
|
Logic
.
Mul
es
->
(
match
mul_xor_sign
es
with
|
Some
b
->
(
not
b
)
|
_
->
false
)
|
_
->
false
|
_
->
false
in
if
improved_is_negative
e
then
true
in
if
improved_is_negative
e
then
true
else
match
F
.
is_true
(
F
.
e_lt
e
e_zero
)
with
else
match
F
.
is_true
(
F
.
e_lt
e
e_zero
)
with
|
Logic
.
Yes
->
true
|
Logic
.
Yes
->
true
|
Logic
.
No
|
Logic
.
Maybe
->
false
|
Logic
.
No
|
Logic
.
Maybe
->
false
and
xor_sign
es
=
try
and
mul_
xor_sign
es
=
try
Some
(
List
.
fold_left
(
fun
acc
e
->
Some
(
List
.
fold_left
(
fun
acc
e
->
if
is_positive_or_null
e
then
acc
(* as previous *)
if
is_positive_or_null
e
then
acc
(* as previous *)
else
if
is_negative
e
then
(
not
acc
)
(* opposite sign *)
else
if
is_negative
e
then
(
not
acc
)
(* opposite sign *)
...
...
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