Skip to content

Contract pass: assert postconditions in body for opaque procs - #48

Draft
keyboardDrummer-bot wants to merge 4 commits into
issue-924-contract-and-proof-passfrom
contract-pass-separate-pre-post
Draft

Contract pass: assert postconditions in body for opaque procs#48
keyboardDrummer-bot wants to merge 4 commits into
issue-924-contract-and-proof-passfrom
contract-pass-separate-pre-post

Conversation

@keyboardDrummer-bot

Copy link
Copy Markdown
Collaborator

Summary

Moves postcondition assertions into the procedure body for opaque procedures with implementation, matching the transparent case.

Previously, for .Opaque _ (some impl) _, postconditions were kept in the Opaque postconditions list and handled by the Core translator's translateChecks. Now they are asserted as inline statements after the implementation body, consistent with how transparent bodies work.

The separate $pre{i} and $post{i} helper procedures are generated per condition (one each), used at call sites via assert/assume. The procedure's own body asserts the raw conditions directly for better verifier interaction.

What was tested

  • All StrataTest modules pass (only pre-existing BvIntCast issue remains)
  • StrataBooleTest passes
  • StrataPythonTest passes

keyboardDrummer-bot and others added 3 commits June 5, 2026 13:42
Tests added to T2_ImpureExpressions.lean:
- Dangling if in expression position (needsCondVar == false)
- Assert/assume in expression position (lifted by the pass)
- Assignment to fresh variable in expression position

Removed commented-out code:
- Assert/Assume cases in onlyKeepSideEffectStmtsAndLast
- Old conditional guards in transformStmt for Assert/Assume
- LiftExpressionAssignments pass from Laurel pipeline
- EliminateMultipleOutputs/InlineLocalVariablesInExpressions from corePipeline
Add tests for lifting pass features and remove commented-out code
Move postcondition assertions into the procedure body for opaque
procedures with implementation, matching the transparent case. The
postconditions are now asserted as inline statements after the
implementation rather than being kept in the Opaque postconditions list
for the Core translator to handle.

This ensures consistent behavior: separate $pre and $post helper
procedures are generated per condition, used at call sites via
assert/assume, while the procedure's own body asserts the raw
conditions directly.
The original change cleared postconditions from the Opaque list and added
inline assertions. This broke pyAnalyze golden-file tests because the Core
translator uses the Opaque postconditions list to generate spec postconditions
(which produce the named obligation results in verification output).

Keep postconditions in the Opaque list for spec generation while preserving
the refactoring that hoists postAsserts computation and fixes the Abstract
pattern binding.
@keyboardDrummer
keyboardDrummer force-pushed the issue-924-contract-and-proof-pass branch from 743cc5a to 87d7214 Compare June 10, 2026 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants