Remove functions#1408
Conversation
…trata into transparency-pass-only
This reverts commit d3e7594.
The function→procedure changes renumber assertion/assume IDs in the generated Core programs. Update all expected_interpret/*.expected files that had hardcoded assertion numbers to use [0-9]+ patterns instead, matching the approach already used by test_missing_models.expected.
|
I investigated the For example, Fix pushed (b46ab22): I updated all 16 affected Potential remaining issues I couldn't verify (no Lean toolchain available locally):
If CI still shows failures after this push, running |
|
@keyboardDrummer-bot please investigate the CMBC failures that occur when doing |
|
I investigated the CBMC pipeline failures on this branch. Here's what I found: Root CauseThe GOTO backend ( Affected Tests (9 tests)All tests calling procedures with contracts failed at
FixI opened PR #1430 (targeting Additional Note14 tests currently marked |
|
@keyboardDrummer-bot please cherry-pick 8a3bbe4 into this PR |
The GOTO backend's toGotoExprCtx and toGotoExpr functions only handled up to ternary (3-argument) function applications. With the removal of Laurel functions in favor of procedures, the contract pass now generates pre/postcondition checks with 4+ arguments (e.g., procedure params + return value + exception variable). Add explicit pattern matching for quaternary (4), quinary (5), and senary (6) argument applications in both LExprT.toGotoExpr and LExpr.toGotoExprCtx. This fixes pyAnalyzeLaurelToGoto failures for tests that call procedures with contracts (e.g., test_helper.procedure).
|
@keyboardDrummer-bot please debug the failures in this CI run: https://github.com/strata-org/Strata/actions/runs/28402459992/job/84162551771?pr=1408 |
symtab2gb requires the 'guard' key on every instruction, but the serializer was omitting it for non-GOTO instructions with a true guard. This caused 'instruction_from_json: key guard not found' errors for all 6 failing Python CBMC pipeline tests.
Port of GitHub PR strata-org/Strata#1408 ("Remove functions"), the StrataPythonFrontEnd half. - Convert the Laurel runtime prelude (PythonRuntimeLaurelPart) from `function` declarations to `procedure`s. - Thread `alwaysCallCoreFunctions` through PySpecPipeline / Cli. - Emit a valueless `.Return` (not a direct `$body` exit) for Python `return`, so postcondition assertions appended after the body stay reachable; pass the new `postTest` argument to `While`. Goldens: regenerated all expected_laurel/*.expected via run_py_analyze.sh --update (with label-ID normalization) and updated the test_missing_models interpret pattern. AnalyzeGoldenTest and the full FE test suite pass against the ported Strata.
…on twins Ports the TransparencyPass.lean changes from #1408: - Add redirectCallsToFunctional / redirectCallsInProc helpers - Split toUpdate into procedures needing a procedural twin vs transparent-only (via blockContainsAssumeOrAssert) - Redirect single-output twinned procedure calls to $asFunction when options.alwaysCallCoreFunctions is set - Thread LaurelTranslateOptions through createFunctionsForTransparentBodies
…ion classification Ports the coupled call-site rewrite from #1408 so that $post/$asFunction helper calls in pure contexts are no longer rejected: - Add TranslateState.procedureNames + containsProcedure, and switch the three call-site checks in translateExpr/translateStmt from the id-based model.isFunction to the name-based containsProcedure. TransparencyPass redirects foo -> foo$asFunction while preserving uniqueId, so an id-based check still resolves to the base procedure and wrongly rejects the call. - TransparencyPass: this tree still carries the isFunctional field (unlike #1408, which removes it), and the SCC/formatter/SemanticModel classification all key off it. So restore isFunctional := true on the $asFunction copies and isFunctional := false on the procedural twins, and only give a procedural twin to non-functional procedures. Without this, genuine functions (e.g. 'function assertP(x) requires P(x)') got a procedural twin, landed in procedureNames, and their calls in pure bodies were rejected. - Tests: mark 'safe' as a procedure in the Postconditions well-formedness test; update 'assertion could not be proved' -> 'assertion does not hold' in TransparentBody; regenerate the ContractPassConditionModeTest golden for the new procedure-shaped $post helpers. Full brazil-build (512 jobs) passes.
Port of GitHub PR #1408 ("Remove functions"). - Remove the Laurel `function` keyword and the `isFunctional` distinction; everything is now a `procedure`. - Support let expressions in transparent bodies (the contract pass can produce them when calling procedures with preconditions). - Fix several bugs in the lifting pass now that more constructs are procedures. - Improve printing of if-then-else (indent then/else branches). - Fix the contract pass so it eliminates all pre and postconditions. Tests: replaced `function` with `procedure` in Laurel tests (dropping duplicated function/procedure cases), updated printed-output goldens for the new if-then-else formatting and procedure encoding, and updated diagnostics that changed wording. Full StrataTest suite builds and passes.
Changes
#guard_msgs (drop info) into several tests to prevent gettinginfooutput when runninglake test. These guards previously already existed but they were accidentally removed in a test refactoring.Tests
functionin tests withprocedure. Tests that had duplicated cases for functions and procedures had the function test-cases removed.