generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 129
Add support for loop-contract historic values #3951
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
thanhnguyen-aws
merged 31 commits into
model-checking:main
from
thanhnguyen-aws:loopmodify
Apr 11, 2025
Merged
Changes from 6 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
8a579da
add support or old in while loop inv
thanhnguyen-aws 3bc29ea
Merge branch 'model-checking:main' into loopmodify
thanhnguyen-aws 7520bc3
add expected
thanhnguyen-aws c393439
add expected
thanhnguyen-aws 8714931
add expected
thanhnguyen-aws bb7fdff
add more expected tests
thanhnguyen-aws 1c168bd
add clone to assignment, fix expected file name
thanhnguyen-aws b981fa2
fix expected files and add commnents in tests
thanhnguyen-aws c4c347d
Merge branch 'model-checking:main' into loopmodify
thanhnguyen-aws 5fc1da1
fix expected files
thanhnguyen-aws 6a30e72
added comments to expain the code
thanhnguyen-aws 6a9e97c
separate continue/break for the case where the loop break on the firs…
thanhnguyen-aws 4338359
fixed expected
thanhnguyen-aws 000c384
fixed expected
thanhnguyen-aws af11946
Merge branch 'main' into loopmodify
thanhnguyen-aws 7261284
Merge branch 'main' into loopmodify
thanhnguyen-aws 8f7f067
fix some typos
thanhnguyen-aws 35c93fa
Merge branch 'main' into loopmodify
thanhnguyen-aws 95ac221
Merge branch 'main' into loopmodify
thanhnguyen-aws 67d4a96
Merge branch 'main' into loopmodify
thanhnguyen-aws 8bb5b10
update prev semantic
thanhnguyen-aws 8ce1940
Merge branch 'loopmodify' of https://github.com/thanhnguyen-aws/kani …
thanhnguyen-aws 2b80c0a
Merge branch 'main' into loopmodify
thanhnguyen-aws 5737ac0
Merge branch 'main' into loopmodify
thanhnguyen-aws 91fc455
Merge branch 'main' into loopmodify
thanhnguyen-aws fcd878d
fix comment
thanhnguyen-aws 132723e
separate return statement in loop body
thanhnguyen-aws 609c388
fix format
thanhnguyen-aws 28c9d17
Merge branch 'main' into loopmodify
thanhnguyen-aws 747d2a3
fix typo
thanhnguyen-aws a7f833a
Merge branch 'loopmodify' of https://github.com/thanhnguyen-aws/kani …
thanhnguyen-aws 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
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 @@ | ||
| VERIFICATION:- SUCCESSFUL |
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,24 @@ | ||
| // Copyright Kani Contributors | ||
| // SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
|
||
| // kani-flags: -Z loop-contracts | ||
|
|
||
| //! Check if loop contracts is correctly applied. | ||
|
|
||
| #![feature(stmt_expr_attributes)] | ||
| #![feature(proc_macro_hygiene)] | ||
|
|
||
| #[kani::proof] | ||
| pub fn loop_with_old() { | ||
| let mut x: u8 = kani::any_where(|v| *v < 10); | ||
| let mut y: u8 = kani::any(); | ||
| let mut i = 0; | ||
| #[kani::loop_invariant( (i<=5) && (x <= old(x) + i) && (old(x) + i == old(i) + x))] | ||
| while i < 5 { | ||
| if i == 0 { | ||
| y = x | ||
| } | ||
| x += 1; | ||
| i += 1; | ||
| } | ||
| } |
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 @@ | ||
| VERIFICATION:- SUCCESSFUL |
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,22 @@ | ||
| // Copyright Kani Contributors | ||
| // SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
|
||
| // kani-flags: -Z loop-contracts | ||
|
|
||
| //! Check if loop contracts is correctly applied. | ||
|
|
||
| #![feature(stmt_expr_attributes)] | ||
| #![feature(proc_macro_hygiene)] | ||
|
|
||
| #[kani::proof] | ||
| pub fn loop_with_old_and_prev() { | ||
| let mut i = 100; | ||
| #[kani::loop_invariant((i >= 2) && (i <= 100) && (i % 2 == 0) && (old(i) == 100) && (prev(i) == i + 2))] | ||
| while i > 2 { | ||
| if i == 1 { | ||
| break; | ||
| } | ||
| i = i - 2; | ||
| } | ||
| assert!(i == 2); | ||
| } |
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,24 @@ | ||
| // Copyright Kani Contributors | ||
| // SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
|
||
| // kani-flags: -Z loop-contracts | ||
|
|
||
| //! Check if loop contracts is correctly applied. | ||
|
|
||
| #![feature(stmt_expr_attributes)] | ||
| #![feature(proc_macro_hygiene)] | ||
|
|
||
| #[kani::proof] | ||
| pub fn loop_with_prev() { | ||
| let mut i = 100; | ||
| let mut j = 100; | ||
| #[kani::loop_invariant((i >= 2) && (i <= 100) && (i % 2 == 0) && (j == 2*i-100) && (prev(i) == i + 2) && (prev(j) == j + 4) && (prev(i-j) == i-j-2) )] | ||
| while i > 2 { | ||
| if i == 1 { | ||
| break; | ||
| } | ||
| i = i - 2; | ||
| j = j - 4 | ||
| } | ||
| assert!(i == 2); | ||
| } |
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 @@ | ||
| VERIFICATION:- SUCCESSFUL | ||
tautschnig marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
Oops, something went wrong.
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.