Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Lustrec - public version
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LustreC
Lustrec - public version
Commits
7659bbb1
Commit
7659bbb1
authored
5 years ago
by
Pierre Loic Garoche
Browse files
Options
Downloads
Patches
Plain Diff
Corelang function: push_negations that propagate negations in leafs of the expression
parent
7aaacbc9
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/corelang.ml
+56
-3
56 additions, 3 deletions
src/corelang.ml
src/corelang.mli
+1
-0
1 addition, 0 deletions
src/corelang.mli
with
57 additions
and
3 deletions
src/corelang.ml
+
56
−
3
View file @
7659bbb1
...
...
@@ -1331,6 +1331,59 @@ let get_node name prog =
Utils
.
desome
node_opt
with
Utils
.
DeSome
->
raise
Not_found
(* Local Variables: *)
(* compile-command:"make -C .." *)
(* End: *)
(* Pushing negations in expression. Subtitute operators whenever possible *)
let
rec
push_negations
?
(
neg
=
false
)
e
=
let
res
=
let
pn
=
push_negations
in
let
map
desc
=
{
e
with
expr_desc
=
desc
}
in
match
e
.
expr_desc
with
|
Expr_ite
(
g
,
t
,
e
)
->
if
neg
then
map
(
Expr_ite
(
pn
g
,
pn
e
,
pn
t
))
else
map
(
Expr_ite
(
pn
g
,
pn
t
,
pn
e
))
|
Expr_tuple
t
->
map
(
Expr_tuple
(
List
.
map
(
pn
~
neg
)
t
))
|
Expr_arrow
(
e1
,
e2
)
->
map
(
Expr_arrow
(
pn
~
neg
e1
,
pn
~
neg
e2
))
|
Expr_fby
(
e1
,
e2
)
->
map
(
Expr_fby
(
pn
~
neg
e1
,
pn
~
neg
e2
))
|
Expr_pre
e
->
map
(
Expr_pre
(
pn
~
neg
e
))
|
Expr_appl
(
op
,
e'
,
None
)
when
op
=
"not"
->
if
neg
then
push_negations
~
neg
:
false
e'
else
push_negations
~
neg
:
true
e'
|
Expr_appl
(
op
,
e'
,
None
)
when
List
.
mem
op
(
Basic_library
.
bool_funs
@
Basic_library
.
rel_funs
)
->
(
match
op
with
|
"&&"
->
map
(
Expr_appl
((
if
neg
then
"||"
else
op
)
,
pn
~
neg
e'
,
None
))
|
"||"
->
map
(
Expr_appl
((
if
neg
then
"&&"
else
op
)
,
pn
~
neg
e'
,
None
))
(* TODO xor/equi/impl *)
|
"<"
->
map
(
Expr_appl
((
if
neg
then
">="
else
op
)
,
pn
e'
,
None
))
|
">"
->
map
(
Expr_appl
((
if
neg
then
"<="
else
op
)
,
pn
e'
,
None
))
|
"<="
->
map
(
Expr_appl
((
if
neg
then
">"
else
op
)
,
pn
e'
,
None
))
|
">="
->
map
(
Expr_appl
((
if
neg
then
"<"
else
op
)
,
pn
e'
,
None
))
|
"!="
->
map
(
Expr_appl
((
if
neg
then
"="
else
op
)
,
pn
e'
,
None
))
|
"="
->
map
(
Expr_appl
((
if
neg
then
"!="
else
op
)
,
pn
e'
,
None
))
|
_
->
assert
false
)
|
Expr_const
_
|
Expr_ident
_
->
if
neg
then
mkpredef_call
e
.
expr_loc
"not"
[
e
]
else
e
|
Expr_appl
(
op
,_,_
)
->
if
neg
then
mkpredef_call
e
.
expr_loc
"not"
[
e
]
else
e
|
_
->
assert
false
(* no array, array access, power or merge/when *)
in
res
(* Local Variables: *)
(* compile-command:"make -C .." *)
(* End: *)
This diff is collapsed.
Click to expand it.
src/corelang.mli
+
1
−
0
View file @
7659bbb1
...
...
@@ -197,6 +197,7 @@ val get_expr_calls: top_decl list -> expr -> Utils.ISet.t
val
eq_has_arrows
:
eq
->
bool
val
push_negations
:
?
neg
:
bool
->
expr
->
expr
(* Local Variables: *)
(* compile-command:"make -C .." *)
(* End: *)
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