Extend LiftImperativeExpression pass to handle assert/assume#46
Draft
keyboardDrummer-bot wants to merge 1 commit into
Draft
Extend LiftImperativeExpression pass to handle assert/assume#46keyboardDrummer-bot wants to merge 1 commit into
keyboardDrummer-bot wants to merge 1 commit into
Conversation
- Add Assert/Assume cases to transformExpr so assignments within assert/assume conditions in expression context are lifted correctly - Update transformStmt for Assert/Assume to always transform their conditions (lifting assignments and imperative calls) - Add Assert/Assume to containsAssignmentOrImperativeCall for recursive detection - Use fresh substitution context when processing assert/assume in expression position to avoid applying outer substitutions - Follow the prepend ordering pattern: child prepends come before the lifted node itself Fixes #43
Collaborator
Author
|
The "Run internal benchmarks of Strata" failure is not caused by the code changes in this PR. It's a systemic issue affecting all PRs on this fork — the CI workflow's benchmark job is hardcoded to pull source from Locally, the build and all 591 test jobs pass successfully with no errors. |
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.
Extends the
LiftImperativeExpressionpass to handleassertandassumenodes, as described in #43.Changes
Strata/Languages/Laurel/LiftImperativeExpressions.lean:.Assertand.Assumecases totransformExpr— when these appear in expression context (e.g. inside block expressions), their conditions are transformed with a fresh substitution context (to lift any assignments within), and the assert/assume itself is lifted to prepends using the correct ordering pattern.transformStmtfor.Assertand.Assumeto always transform their conditions, lifting assignments and imperative calls (previously only handled nondet holes)..Assertand.AssumetocontainsAssignmentOrImperativeCallfor recursive detection of impure expressions within assert/assume conditions.StrataTest/Languages/Laurel/LiftExpressionAssignmentsTest.lean:var y := { assert x > 0; 3 }andassert (x := 2) == 2assume (x := 2) == 2StrataTest/Languages/Laurel/Examples/Fundamentals/T2_ImpureExpressionsError.lean:assertwith assignments/imperative calls in procedure bodies, since these are now handled by the lift pass (errors remain for contracts/functions which are pure contexts).Prepend ordering
For lifted nodes, the prepend ordering follows the pattern from the issue:
ensuring child prepends come before the lifted node itself, and outer prepends come after.
Fixes #43"