Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

try out A ==> B to A ==> A && B conversion #466

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ tmp/
results.txt
*.bpl
*.bpl.*
z3.log
4 changes: 4 additions & 0 deletions src/main/scala/viper/carbon/boogie/Optimizer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ object Optimizer {
* - Constant folding for booleans, integers and reals.
* - Removal of dead branches.
* - Removal of assertions known to hold.
* - Experimental: all *remaining* A ==> B expressions / assertions become A ==> A && B
*
* Constant folding partly taken from Transformer.simplify from SIL, but added more optimizations.
*/
Expand All @@ -42,6 +43,9 @@ object Optimizer {
case BinExp(TrueLit(), Implies, FalseLit()) => FalseLit()
case BinExp(TrueLit(), Implies, consequent) => consequent

// experiment: make all A ==> B into A ==> A && B
case BinExp(left, Implies, right) => BinExp(left, Implies, BinExp(left, And, right))

case BinExp(BoolLit(left), EqCmp, BoolLit(right)) => BoolLit(left == right)
case BinExp(FalseLit(), EqCmp, right) => UnExp(Not, right)
case BinExp(left, EqCmp, FalseLit()) => UnExp(Not, left)
Expand Down
Loading