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

loop_old in loop contracts #3697

Open
qinheping opened this issue Nov 8, 2024 · 1 comment
Open

loop_old in loop contracts #3697

qinheping opened this issue Nov 8, 2024 · 1 comment
Assignees
Labels
[C] Feature / Enhancement A new feature request or enhancement to an existing feature.

Comments

@qinheping
Copy link
Contributor

Requested feature: loop_old similar to old that can refers to historic values in loop contracts
Use case:

#[kani::loop_invariants(loop_old(x) == y)]

where loop_old(x) refers to the value of x upon the entrance of the loop.
Link to relevant documentation (Rust reference, Nomicon, RFC): #3167

Test case:

let mut x: u8 = kani::any_where(|v| *v < 10);
let mut y: u8 = kani::any();
let mut i = 0;
#[kani::loop_invariants(i == 0 || loop_old(x) == y)]
while i < 5{
  if i == 0{
    y = x
  }
  x += 1;
  i += 1;
}
@qinheping qinheping added the [C] Feature / Enhancement A new feature request or enhancement to an existing feature. label Nov 8, 2024
@qinheping qinheping self-assigned this Nov 8, 2024
@qinheping
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C] Feature / Enhancement A new feature request or enhancement to an existing feature.
Projects
None yet
Development

No branches or pull requests

1 participant