-
Notifications
You must be signed in to change notification settings - Fork 52
[Termination Plugin] Extend Expr Support #618
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
31a1804
adds support for forall quantifiers and wildcard permission amounts t…
ArquintL f6b1db6
adds support for sets and multisets to expression transformer
ArquintL c073e44
further extends the expr transformer's support to existentials
ArquintL 361caea
Merge branch 'master' into extend-expr-support-in-termination-plugin
ArquintL 5daeb7b
adds missing expressions to the expression transformer
ArquintL eec7cb1
moves the non-problematic simplifications from the termination plugin…
ArquintL 1121e53
fixes unit tests for carbon
ArquintL File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/test/resources/termination/functions/expressions/exists.vpr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| // Any copyright is dedicated to the Public Domain. | ||
| // http://creativecommons.org/publicdomain/zero/1.0/ | ||
|
|
||
| import <decreases/declaration.vpr> | ||
|
|
||
| field f: Int | ||
|
|
||
| function test(x: Ref): Bool | ||
| decreases | ||
| { | ||
| //:: ExpectedOutput(termination.failed:termination.condition.false) | ||
| exists x2: Ref :: x == x2 && nonTerminating(x2) | ||
| } | ||
|
|
||
| function test2(): Bool | ||
| decreases | ||
| { | ||
| // in general `partiallyTerminating` is non-terminating | ||
| //:: ExpectedOutput(termination.failed:termination.condition.false) | ||
| exists x2: Int :: partiallyTerminating(x2) | ||
| } | ||
|
|
||
| function test3(x: Int): Bool | ||
| decreases | ||
| requires x == 42 | ||
| { | ||
| // `partiallyTerminating` terminates for input `42` so this is fine | ||
| exists x2: Int :: x == x2 && partiallyTerminating(x2) | ||
| } | ||
|
|
||
| function test4(x: Int): Bool | ||
| decreases | ||
| { | ||
| // in general `partiallyTerminating` is non-terminating | ||
| //:: ExpectedOutput(termination.failed:termination.condition.false) | ||
| (exists x2: Int :: x == x2) && partiallyTerminating(x) | ||
| } | ||
|
|
||
| function test5(x: Int): Bool | ||
| decreases | ||
| { | ||
| // this is fine due to short-circuiting | ||
| (exists x2: Int :: x == x2 && x != x2) && partiallyTerminating(x) | ||
| } | ||
|
|
||
| function nonTerminating(x: Ref): Bool | ||
| decreases * | ||
|
|
||
| function partiallyTerminating(x: Int): Bool | ||
| decreases if x == 42 | ||
| decreases * |
25 changes: 25 additions & 0 deletions
25
src/test/resources/termination/functions/expressions/forall.vpr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| // Any copyright is dedicated to the Public Domain. | ||
| // http://creativecommons.org/publicdomain/zero/1.0/ | ||
|
|
||
| import <decreases/declaration.vpr> | ||
|
|
||
| field f: Int | ||
|
|
||
| function test(x: Ref): Bool | ||
| decreases | ||
| //:: ExpectedOutput(termination.failed:termination.condition.false) | ||
| requires forall x2: Ref :: x == x2 ==> acc(x2.f) && nonTerminating(x2) | ||
| { | ||
| true | ||
| } | ||
|
|
||
| function test2(x: Ref): Bool | ||
| decreases | ||
| // this is fine because `nonTerminating(x2)` is not reachable | ||
| requires forall x2: Ref :: x == x2 ==> false && nonTerminating(x2) | ||
| { | ||
| true | ||
| } | ||
|
|
||
| function nonTerminating(x: Ref): Bool | ||
| decreases * |
13 changes: 13 additions & 0 deletions
13
src/test/resources/termination/functions/expressions/wildcard.vpr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| // Any copyright is dedicated to the Public Domain. | ||
| // http://creativecommons.org/publicdomain/zero/1.0/ | ||
|
|
||
| import <decreases/declaration.vpr> | ||
|
|
||
| field f: Int | ||
|
|
||
| function test(x: Ref): Bool | ||
| decreases | ||
| requires acc(x.f, wildcard) | ||
| { | ||
| true | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.