Fix PAST decrease checks - #127
Merged
Merged
Conversation
This terminating countdown was rejected by the generated decrease check:
proc main(init_x: UInt) -> (x: UInt) {
x = init_x
@past(x + 1, 0.5, 1)
while 0 < x { x = x - 1 }
}
The precondition checked [0 < x] before x = init_x, so it could use x = 0 while init_x = 1.
Use [0 < init_x] in that precondition so the guard agrees with the state in which the loop iteration starts.
The countdown now verifies for every initial value; cover both this deterministic case and a probabilistic countdown.
Extract the exit bound, continuation bound, and expected decrease into separate helpers. Keep argument validation and orchestration in transform, with state initialization local to the decrease obligation. Name the generated procedures after their premises so verification output identifies which condition failed.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The decrease check accepted
@past(1, 0.5, 1) while true { tick 1 }despite its infinite runtime.It used
proc, proving the inequality in the wrong direction; usecoprocto check that the invariant decreases by at least epsilon.The valid countdown
@past(x + 1, 0.5, 1) while 0 < x { x = x - 1 }was rejected because the generated precondition checked[0 < x]beforex = init_x.Use
[0 < init_x]so the guard and invariant refer to the same initial state.Fixes #122
Implementation assisted by Codex.