Merged
Conversation
Add tests covering the pattern where a function-level `asserts` covers per-iteration abort conditions in an implementation loop. The loop invariant uses `ensures` to carry the partial information needed for both the Check direction (discharge body assertion under asserts) and the Assume direction (force loop to be unable to exit normally when asserts is negated). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Cover variations of the asserts-in-loop pattern: * requires + asserts mix * multiple per-iteration asserts in the body * sequential pair of loops in one function * loop with early break (no asserts needed) * accumulator overflow with closed-form invariant * asserts pinning down a return-value postcondition * mutating state via &mut Plus two failure cases exposing prover limitations: * nested loops with two independent asserts (Assume direction does not propagate inner-loop contradiction outward) * mutating quantified state where the asserts and the natural invariant collapse to the same predicate at iteration zero Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The mutating quantified case is solvable — apply the same `j < i` guard trick used for immutable inputs, but to the cloned `old_v` snapshot. The invariant `forall j < i, safe(old_v[j])` is vacuous at iteration 0, accumulates per-iteration, and at loop exit covers the full range — contradicting the negated asserts. Keep the broken un-guarded version as a fail test showing what does not work and why. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Express the function-level asserts as `forall k, outer_safe(k, n, m)` and accumulate `forall k, k >= i || outer_safe(k, n, m)` in the outer loop invariant — same vacuous-at-zero / collapses-at-exit pattern that works for `positive_check` and `increment_all`. The earlier nested.fail variant used a bounded asserts which doesn't let the prover connect a single conjunctive assertion to the per-iteration abort behaviour spread across two loops. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0634313 to
437e4c7
Compare
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.
No description provided.