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
30345328
Commit
30345328
authored
3 years ago
by
Patrick Baudin
Browse files
Options
Downloads
Patches
Plain Diff
[WP] rewrites the part of eq_sequence relative to subsequence comparison
parent
b5553234
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/Vlist.ml
+27
-25
27 additions, 25 deletions
src/plugins/wp/Vlist.ml
with
27 additions
and
25 deletions
src/plugins/wp/Vlist.ml
+
27
−
25
View file @
30345328
...
@@ -332,24 +332,35 @@ let rewrite_is_nil ~nil a =
...
@@ -332,24 +332,35 @@ let rewrite_is_nil ~nil a =
F
.
p_or
(
F
.
p_leq
n
F
.
e_zero
)
(
p_is_nil
u
)
F
.
p_or
(
F
.
p_leq
n
F
.
e_zero
)
(
p_is_nil
u
)
|
_
->
raise
Not_found
|
_
->
raise
Not_found
let
elements
a
=
match
F
.
repr
a
with
|
L
.
Fun
(
nil
,
[]
)
when
nil
==
f_nil
->
[]
|
L
.
Fun
(
concat
,
es
)
when
concat
==
f_concat
->
es
|
_
->
[
a
]
(* [omit rs x ys]: if ys = u.x.v returns (rs+u,v) with r in reverse order *)
(* Ensures xs to be a sub-sequence of ys, otherwise raise Not_found
In such a case, (concat xs = concat ys) <==> (forall r in result, r = nil) *)
let
rec
subsequence
xs
ys
=
match
xs
,
ys
with
|
[]
,
ys
->
ys
|
x
::
rxs
,
y
::
rys
->
if
(
F
.
decide
(
e_eq
x
y
))
then
subsequence
rxs
rys
else
y
::
subsequence
xs
rys
|
_
->
raise
Not_found
let
rec
omit
rs
x
=
function
let
elements
a
=
|
[]
->
raise
Not_found
match
F
.
repr
a
with
|
y
::
ys
->
if
x
==
y
then
rs
,
ys
else
omit
(
y
::
rs
)
x
ys
|
L
.
Fun
(
concat
,
es
)
when
concat
==
f_concat
->
true
,
es
|
_
->
false
,
[
a
]
(* Ensures that [a] or [b] is a sub-sequence of the other, otherwise [raise Not_found]
In such a case, (concat xs = concat ys) <==> (forall r in result, r = nil) *)
let
subsequence
a
b
=
let
destruct_a
,
xs
=
elements
a
in
let
destruct_b
,
ys
=
elements
b
in
if
not
(
destruct_a
||
destruct_b
)
then
raise
Not_found
;
let
shortest
,
xs
,
ys
=
if
List
.
length
xs
<=
List
.
length
ys
then
a
,
xs
,
ys
else
b
,
ys
,
xs
in
let
es
=
subsequence
xs
ys
in
(* xs=ys <==> forall s in es ; s = nil *)
let
nil
=
v_nil
(
F
.
typeof
shortest
)
in
(* [s] are elements of [ys] (the longest sequence) and [nil] has the same type than the [shortest] sequence *)
let
p_is_nil
s
=
F
.
p_equal
nil
s
in
F
.
p_all
p_is_nil
es
let
rec
subsequence
xs
rs
ys
=
match
xs
with
|
[]
->
List
.
rev_append
rs
ys
|
x
::
xs
->
let
rs
,
ys
=
omit
rs
x
ys
in
subsequence
xs
rs
ys
let
rewrite_eq
a
b
=
let
rewrite_eq
a
b
=
debug
"Vlist.rewrite_eq: tries to rewrite %a@ = %a@.- left pattern: %a@.- right pattern: %a@."
debug
"Vlist.rewrite_eq: tries to rewrite %a@ = %a@.- left pattern: %a@.- right pattern: %a@."
...
@@ -362,16 +373,7 @@ let rewrite_eq a b =
...
@@ -362,16 +373,7 @@ let rewrite_eq a b =
|
_
->
|
_
->
try
leftmost_eq
a
b
with
Not_found
->
try
leftmost_eq
a
b
with
Not_found
->
try
rightmost_eq
a
b
with
Not_found
->
try
rightmost_eq
a
b
with
Not_found
->
let
xs
=
elements
a
in
subsequence
a
b
let
ys
=
elements
b
in
let
rs
=
if
List
.
length
xs
<
List
.
length
ys
then
subsequence
xs
[]
ys
else
subsequence
ys
[]
xs
in
let
pred
=
F
.
p_all
(
fun
s
->
F
.
p_equal
s
(
v_nil
(
F
.
typeof
s
)))
rs
in
if
F
.
decide
(
e_prop
pred
)
then
F
.
p_true
else
raise
Not_found
(* All Simplifications *)
(* All Simplifications *)
...
...
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