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
eeff119a
Commit
eeff119a
authored
2 years ago
by
Loïc Correnson
Browse files
Options
Downloads
Patches
Plain Diff
[wp] matching in sequent
parent
f6b8f4ca
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/plugins/wp/Pattern.ml
+93
-1
93 additions, 1 deletion
src/plugins/wp/Pattern.ml
src/plugins/wp/Pattern.mli
+15
-8
15 additions, 8 deletions
src/plugins/wp/Pattern.mli
with
108 additions
and
9 deletions
src/plugins/wp/Pattern.ml
+
93
−
1
View file @
eeff119a
...
@@ -222,8 +222,10 @@ let pp_pattern = pp
...
@@ -222,8 +222,10 @@ let pp_pattern = pp
(* -------------------------------------------------------------------------- *)
(* -------------------------------------------------------------------------- *)
type
sigma
=
Tactical
.
selection
Vmap
.
t
type
sigma
=
Tactical
.
selection
Vmap
.
t
type
env
=
{
type
env
=
{
mutable
sigma
:
sigma
;
mutable
sigma
:
sigma
;
mutable
marked
:
Lang
.
F
.
Tset
.
t
;
select
:
Lang
.
F
.
term
->
Tactical
.
selection
;
select
:
Lang
.
F
.
term
->
Tactical
.
selection
;
}
}
...
@@ -348,7 +350,21 @@ and pargs env ps es =
...
@@ -348,7 +350,21 @@ and pargs env ps es =
|
p
::
ps
,
e
::
es
->
pmatch
env
p
e
;
pargs
env
ps
es
|
p
::
ps
,
e
::
es
->
pmatch
env
p
e
;
pargs
env
ps
es
|
_
->
raise
Not_found
|
_
->
raise
Not_found
let
()
=
ignore
pmatch
(* Deep matching with marking *)
let
rec
pchildren
env
p
e
=
match
Lang
.
F
.
repr
e
with
|
Bind
_
->
false
|
_
->
let
rs
=
ref
[]
in
Lang
.
F
.
lc_iter
(
fun
e
->
rs
:=
e
::
!
rs
)
e
;
List
.
exists
(
pchild
env
p
)
(
List
.
rev
!
rs
)
and
pchild
env
p
e
=
not
(
Lang
.
F
.
Tset
.
mem
e
env
.
marked
)
&&
begin
env
.
marked
<-
Lang
.
F
.
Tset
.
add
e
env
.
marked
;
ptry
env
p
e
||
pchildren
env
p
e
end
(* -------------------------------------------------------------------------- *)
(* -------------------------------------------------------------------------- *)
(* --- Pattern Lookup --- *)
(* --- Pattern Lookup --- *)
...
@@ -361,6 +377,82 @@ type lookup = {
...
@@ -361,6 +377,82 @@ type lookup = {
pattern
:
pattern
;
pattern
:
pattern
;
}
}
let
pterm
{
head
;
pattern
}
clause
sigma
term
=
let
select
t
=
if
t
==
term
then
Tactical
.
Clause
clause
else
Tactical
.
Inside
(
clause
,
t
)
in
let
env
=
{
sigma
;
select
;
marked
=
Lang
.
F
.
Tset
.
empty
}
in
if
ptry
env
pattern
term
||
(
not
head
&&
pchildren
env
pattern
term
)
then
Some
env
.
sigma
else
None
(* --- Step Ordering --- *)
let
queue
=
Queue
.
create
()
let
order
(
s
:
Conditions
.
step
)
:
int
=
match
s
.
condition
with
|
Have
_
->
0
|
When
_
->
1
|
Branch
_
->
2
|
Core
_
->
3
|
Init
_
->
4
|
Type
_
->
5
|
Either
_
->
6
|
State
_
->
7
let
priority
sa
sb
=
order
sa
-
order
sb
let
push
(
step
:
Conditions
.
step
)
=
match
step
.
condition
with
|
Have
_
|
When
_
|
Core
_
|
Init
_
|
Type
_
|
State
_
->
()
|
Branch
(
_
,
sa
,
sb
)
->
Queue
.
push
sa
queue
;
Queue
.
push
sb
queue
|
Either
cs
->
List
.
iter
(
fun
s
->
Queue
.
push
s
queue
)
cs
(* --- Step Matching --- *)
let
pstep
ctxt
sigma
(
step
:
Conditions
.
step
)
=
let
term
=
Lang
.
F
.
e_prop
@@
Conditions
.
head
step
in
let
clause
=
Tactical
.
Step
step
in
pterm
ctxt
clause
sigma
term
(* --- Sequence Matching --- *)
let
rec
plist
f
=
function
[]
->
None
|
x
::
xs
->
match
f
x
with
|
Some
_
as
result
->
result
|
None
->
plist
f
xs
let
rec
psequence
ctxt
sigma
(
seq
:
Conditions
.
sequence
)
=
let
steps
=
List
.
sort
priority
(
Conditions
.
list
seq
)
in
match
plist
(
pstep
ctxt
sigma
)
steps
with
|
Some
_
as
result
->
Queue
.
clear
queue
;
result
|
None
->
List
.
iter
push
steps
;
if
Queue
.
is_empty
queue
then
None
else
psequence
ctxt
sigma
(
Queue
.
pop
queue
)
(* --- Hypotheses Matching --- *)
let
phyps
ctxt
sigma
(
seq
:
Conditions
.
sequent
)
=
if
not
ctxt
.
hyps
then
None
else
psequence
ctxt
sigma
(
fst
seq
)
let
pgoal
ctxt
sigma
(
seq
:
Conditions
.
sequent
)
=
if
not
ctxt
.
goal
then
None
else
let
goal
=
snd
seq
in
let
term
=
Lang
.
F
.
e_prop
goal
in
let
clause
=
Tactical
.
Goal
goal
in
pterm
ctxt
clause
sigma
term
let
empty
=
Vmap
.
empty
let
psequent
ctxt
sigma
(
seq
:
Conditions
.
sequent
)
=
match
pgoal
ctxt
sigma
seq
with
|
Some
_
as
result
->
result
|
None
->
phyps
ctxt
sigma
seq
(* -------------------------------------------------------------------------- *)
(* -------------------------------------------------------------------------- *)
(* --- Composing Values --- *)
(* --- Composing Values --- *)
(* -------------------------------------------------------------------------- *)
(* -------------------------------------------------------------------------- *)
...
...
This diff is collapsed.
Click to expand it.
src/plugins/wp/Pattern.mli
+
15
−
8
View file @
eeff119a
...
@@ -31,13 +31,6 @@ type context
...
@@ -31,13 +31,6 @@ type context
type
pattern
type
pattern
type
value
type
value
type
lookup
=
{
head
:
bool
;
goal
:
bool
;
hyps
:
bool
;
pattern
:
pattern
;
}
(** Creates an empty environment *)
(** Creates an empty environment *)
val
context
:
typing_context
->
context
val
context
:
typing_context
->
context
...
@@ -53,10 +46,24 @@ val pp_pattern : Format.formatter -> pattern -> unit
...
@@ -53,10 +46,24 @@ val pp_pattern : Format.formatter -> pattern -> unit
(** Value printer *)
(** Value printer *)
val
pp_value
:
Format
.
formatter
->
value
->
unit
val
pp_value
:
Format
.
formatter
->
value
->
unit
(** Matching lookup *)
type
lookup
=
{
head
:
bool
;
goal
:
bool
;
hyps
:
bool
;
pattern
:
pattern
;
}
(** Matching result *)
(** Matching result *)
type
sigma
type
sigma
(** Composing values *)
(** Empty results *)
val
empty
:
sigma
(** Matching sequent *)
val
psequent
:
lookup
->
sigma
->
Conditions
.
sequent
->
sigma
option
(** Composing values from matching results *)
val
select
:
sigma
->
value
->
Tactical
.
selection
val
select
:
sigma
->
value
->
Tactical
.
selection
(* -------------------------------------------------------------------------- *)
(* -------------------------------------------------------------------------- *)
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