Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
why3
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
81
Issues
81
List
Boards
Labels
Milestones
Merge Requests
8
Merge Requests
8
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Why3
why3
Commits
1c896e89
Commit
1c896e89
authored
Oct 09, 2015
by
MARCHE Claude
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add local rewrite rules for compute
parent
ffd0d006
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
4 deletions
+22
-4
src/transform/compute.ml
src/transform/compute.ml
+3
-1
src/transform/reduction_engine.ml
src/transform/reduction_engine.ml
+4
-3
tests/test_rewrite.mlw
tests/test_rewrite.mlw
+15
-0
No files found.
src/transform/compute.ml
View file @
1c896e89
...
...
@@ -35,12 +35,14 @@ let meta_begin_compute_context =
transformation@ 'compute_in_context'."
*)
let
rule_label
=
Ident
.
create_label
"rewrite"
let
collect_rule_decl
prs
e
d
=
match
d
.
Decl
.
d_node
with
|
Decl
.
Dtype
_
|
Decl
.
Ddata
_
|
Decl
.
Dparam
_
|
Decl
.
Dind
_
|
Decl
.
Dlogic
_
->
e
|
Decl
.
Dprop
(
_
,
pr
,
t
)
->
if
Decl
.
Spr
.
mem
pr
prs
then
if
Decl
.
Spr
.
mem
pr
prs
||
Ident
.
Slab
.
mem
rule_label
t
.
t_label
then
try
add_rule
t
e
with
NotARewriteRule
msg
->
Warning
.
emit
"proposition %a cannot be turned into a rewrite rule: %s"
...
...
src/transform/reduction_engine.ml
View file @
1c896e89
...
...
@@ -519,6 +519,7 @@ and reduce_match st u ~orig tbl sigma cont =
and
reduce_eval
st
t
~
orig
sigma
rem
=
let
orig
=
t_label_copy
orig
t
in
match
t
.
t_node
with
|
Tvar
v
->
begin
...
...
@@ -533,13 +534,13 @@ and reduce_eval st t ~orig sigma rem =
Format.eprintf "Tvar not found: %a@." Pretty.print_vs v;
assert false
*)
{
value_stack
=
Term
(
t_label_copy
orig
t
)
::
st
;
{
value_stack
=
Term
orig
::
st
;
cont_stack
=
rem
;
}
end
|
Tif
(
t1
,
t2
,
t3
)
->
{
value_stack
=
st
;
cont_stack
=
(
Keval
(
t1
,
sigma
)
,
t1
)
::
(
Kif
(
t2
,
t3
,
sigma
)
,
t
)
::
rem
;
cont_stack
=
(
Keval
(
t1
,
sigma
)
,
t1
)
::
(
Kif
(
t2
,
t3
,
sigma
)
,
orig
)
::
rem
;
}
|
Tlet
(
t1
,
tb
)
->
let
v
,
t2
=
t_open_bound
tb
in
...
...
@@ -574,7 +575,7 @@ and reduce_eval st t ~orig sigma rem =
cont_stack
=
List
.
rev_append
args
((
Kapp
(
ls
,
t
.
t_ty
)
,
orig
)
::
rem
);
}
|
Ttrue
|
Tfalse
|
Tconst
_
->
{
value_stack
=
Term
(
t_label_copy
orig
t
)
::
st
;
{
value_stack
=
Term
orig
::
st
;
cont_stack
=
rem
;
}
...
...
tests/test_rewrite.mlw
0 → 100644
View file @
1c896e89
module M
predicate (-->) (x y:'a) = "rewrite" x = y
use import int.Int
goal g0 :
forall x:int. ("rewrite" x = 42) -> x+1 = 42+1
goal g :
forall x:int. x --> 42 -> x+1 = 42
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment