Keep "X is in the collection" inside a FOR EACH pass, not on the way out
The way out of a FOR EACH loop includes the case of no pass at all, but the checker added "X is in the collection" to the loop's head state and then used that same state as the way out. After a loop over an empty list the fact is FALSE, so the checker held a contradiction and proved anything after the loop, ASSERT 1 == 2 included (tests/prover/foreach-empty.pseudo). The fact is now assumed only for the body of a pass. The soundness test gains a canary: after every program that runs to its end without input, ASSERT 1 == 2 is appended and must not be proved, since a proof there means a contradiction on a path every run takes. A one-off scan with the canary after every top-level statement of every program (476 points) found nothing else. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FgvbRdoEheAHqsRmr2WuKZ
This commit is contained in:
3 files changed
+48
-3
No files matched your search
@@ -0,0 +1,13 @@
|
||||
// The way out of a FOR EACH loop includes the case of no pass at all. A
|
||||
// checker that kept "X is in Xs" on the way out held FALSE after looping over
|
||||
// an empty list, and proved anything, even 1 == 2.
|
||||
// MUST-NOT-PROVE: assert@12
|
||||
DECLARE Xs : LIST OF INTEGER
|
||||
DECLARE S : INTEGER
|
||||
Xs <- []
|
||||
S <- 0
|
||||
FOR EACH X IN Xs
|
||||
S <- S + X
|
||||
NEXT X
|
||||
ASSERT 1 == 2
|
||||
OUTPUT S
|
||||
Reference in new issue
Block a user