You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Small-step Imperative semantics: loop/ite exit handling and invariant checking (#1052)
- Small-step `.exit` semantics: According to the previous small-step
statement, `{ loop .. { exit ; } print "a"; } print "b" }` was exiting
the outerblock as well and made this print "b", not "ab". This patch
makes exit without destination block only escape the loop. For if { exit
} else { exit }, this is consistently applied.
- Loop invariants are now checked by `step_loop_{,nondet_}{enter,exit}`:
each invariant must evaluate to `tt`/`ff`, and any `ff` result ORs a
fresh `hasInvFailure` flag into the env's cumulative `hasFailure`,
mirroring how `step_cmd` threads assert failures. (refer to:
Strata/DL/Imperative/StmtSemantics.lean)
- `Stmt.loop` invariants are now labeled pairs `List (String × P.Expr)`
(distinct labels per invariant, like assert labels). Downstream
frontends, backends, and passive-encoding transforms are updated to
carry the labels through. (refer to: Strata/DL/Imperative/Stmt.lean,
Strata/DL/Imperative/StmtSemantics.lean)
- The Core syntax is extended to allow a label to invariants.
```
while (i < n)
invariant [test]: 0 <= i
{
i := (i + 1);
}
```
*Issue #, if available:*
*Description of changes:*
By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0 commit comments