Skip to content

Conversation

thanhnguyen-aws
Copy link
Contributor

Add support for old and prev to refers to historic values in loop contracts where

  • old(expr) refers to the value of the expr before the loop.
  • prev(expr) refers to the value of the expr at the previous iteration.

Resolves #3697

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.

@thanhnguyen-aws thanhnguyen-aws requested a review from a team as a code owner March 20, 2025 00:18
@github-actions github-actions bot added the Z-EndToEndBenchCI Tag a PR to run benchmark CI label Mar 20, 2025
@thanhnguyen-aws thanhnguyen-aws changed the title Add support for loop old and prev Add support for loop-contract historic values Mar 20, 2025
@tautschnig
Copy link
Member

Looks like you want to run kani-fmt.sh to address the test failure.

@remi-delmas-3000
Copy link
Contributor

remi-delmas-3000 commented Mar 21, 2025

Could we use on_entry(...) instead of old(...) ? The doc itself says "old(...) denotes the value on loop entry".

Some documentation describing the transformation at a high level would help the review.

@qinheping
Copy link
Contributor

I am a bit confused about the semantics of prev. How do we check the loop invariant for the first case where there is no prev valuation?

Copy link
Contributor

@qinheping qinheping left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you!

@thanhnguyen-aws thanhnguyen-aws added this pull request to the merge queue Apr 11, 2025
Merged via the queue into model-checking:main with commit c87c7d0 Apr 11, 2025
26 checks passed
@thanhnguyen-aws thanhnguyen-aws deleted the loopmodify branch April 11, 2025 19:08
@thanhnguyen-aws thanhnguyen-aws restored the loopmodify branch April 11, 2025 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Z-EndToEndBenchCI Tag a PR to run benchmark CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

loop_old in loop contracts
5 participants