Use mapStmtExprChildrenM to simplify transformExpr#44
Draft
keyboardDrummer-bot wants to merge 1 commit intomainfrom
Draft
Use mapStmtExprChildrenM to simplify transformExpr#44keyboardDrummer-bot wants to merge 1 commit intomainfrom
keyboardDrummer-bot wants to merge 1 commit intomainfrom
Conversation
…xpressions Add mapStmtExprChildrenM and mapStmtExprPrePostM to MapStmtExpr.lean: - mapStmtExprChildrenM: maps a function over immediate children of a node (one level, no recursion), with optional right-to-left traversal - mapStmtExprPrePostM: full traversal with pre/post hooks Refactor transformExpr in LiftImperativeExpressions.lean: - Remove explicit PrimitiveOp arm - Replace catch-all with mapStmtExprChildrenM transformExpr call - The pass no longer needs to enumerate language features it doesn't relate to (like PrimitiveOp) — new constructors are handled automatically by the generic traversal - Mark transformExpr as partial since mapStmtExprChildrenM is opaque to the termination checker Closes #40
Collaborator
Author
|
I investigated the "Run internal benchmarks of Strata" CI failure. The benchmark job triggers an AWS CodeBuild build that runs internal tests. Finding: This failure is not caused by the code changes in this PR. The same benchmark job is also failing on other unrelated PRs:
The benchmark infrastructure appears to have a pre-existing issue (likely AWS credentials, CodeBuild configuration, or the benchmark environment itself). The failure happens quickly (~100 seconds), suggesting it fails during setup or early build rather than during actual test execution. Local verification:
|
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.
Addresses #40.
Summary
Adds
mapStmtExprChildrenMtoMapStmtExpr.lean— a utility that maps a function over the immediate children of aStmtExprMdnode (one level, no recursion), with an optionalreverseChildrenflag for right-to-left traversal.Uses it in
LiftImperativeExpressions.leanto replace the explicitPrimitiveOparm intransformExprwith a generic catch-all:This means the pass no longer needs to enumerate language features it doesn't relate to. If a new
StmtExprconstructor is added, it will be traversed automatically without updatingtransformExpr.Changes
MapStmtExpr.lean:
mapStmtExprChildrenM: one-level child mapping with optional right-to-left ordermapStmtExprPrePostM: full traversal with pre/post hooks (useful for other passes)LiftImperativeExpressions.lean:
PrimitiveOparm fromtransformExpr| _ => return exprwithmapStmtExprChildrenM transformExpr (reverseChildren := true) expr| .Assert _ | .Assume _ => return exprsince these are statement-like constructs lifted out of blocks and should not have substitutions appliedmutualblock (no longer needed sincetransformStmtdoesn't need mutual recursion withtransformExpr)transformExpraspartialsincemapStmtExprChildrenMis opaque to the termination checkerTrade-off
The use of
partialis a trade-off: we lose the termination proof fortransformExprin exchange for not needing to enumerate every constructor. The termination checker cannot see throughmapStmtExprChildrenMto verify thattransformExpris only called on structurally smaller values. The original code avoided this by listing every constructor with.attachproofs.Testing
All 591 test jobs pass.
"