Skip to content

Fix PAST decrease checks - #127

Merged
Philipp15b merged 4 commits into
mainfrom
codex/fix-past-decrease
Sep 25, 2026
Merged

Philipp15b merged 4 commits into
mainfrom
codex/fix-past-decrease

Conversation

@Philipp15b

@Philipp15b Philipp15b commented Sep 25, 2026 •

Copy link
Copy Markdown
Collaborator

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; use coproc to 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] before x = init_x.
Use [0 < init_x] so the guard and invariant refer to the same initial state.

Fixes #122

Implementation assisted by Codex.

The decrease obligation used proc, reversing the required upper bound and allowing @past(1, 0.5, 1) while true { tick 1 } to verify despite infinite runtime.
Generate a coproc to check the expected decrease, correct the documented encoding, and add regressions with and without tick.

Fixes #122
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.
@Philipp15b
Philipp15b merged commit 18efe99 into main Sep 25, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@past verifies nonterminating loops due to reversed decrease check

1 participant