GOTO backend: Core-to-GOTO translation, CBMC pipeline tests, and CI#289
GOTO backend: Core-to-GOTO translation, CBMC pipeline tests, and CI#289tautschnig merged 24 commits intomainfrom
Conversation
b7a830b to
7b8e91f
Compare
|
One general comment on this: I have plans to add unstructured CFGs in Strata (started in #202), and it would probably make sense in the long run to have a a pipeline that does Strata Stmt -> Strata CFG -> GOTO instruction CFG. I'd paused work on #202 because it wasn't clear what we'd use it for right now, but I could finish it up and merge it if you think it'd be useful for this PR. |
There'll certainly be interactions between your PR and this one, but I'm happy for these to be worked on in either order: if #202 goes in first, this PR will be updated, else #202 should likely include changes to GOTO instruction support (which I'm then happy to contribute myself). |
There was a problem hiding this comment.
Pull request overview
This PR extends the transformation functionality from imperative commands to GOTO instructions by adding support for all statement types (.block, .ite, .loop, and .goto), not just the previously-supported .cmd statements.
Key Changes:
- Implemented mutual recursive functions
Stmt.toGotoInstructionsandBlock.toGotoInstructionsto handle all statement constructors - Added comprehensive test coverage with 10 test cases covering basic, nested, and edge-case scenarios
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
Strata/DL/Imperative/ToCProverGOTO.lean |
Adds mutual recursive transformation functions for statements and blocks, handling control flow constructs (blocks, conditionals, loops, gotos) with proper label generation and GOTO instruction patching |
StrataTest/Backends/CBMC/ToCProverGOTO.lean |
Adds 10 comprehensive test cases covering all new statement types including basic transformations, nested control flow, empty branches/bodies, and assertions/assumptions within control structures |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
I mostly just wanted to make sure we're both aware of each other's work. Since this PR seems just about ready to go, and #202 still needs some tests which I won't have a chance to add right away, let's go ahead and merge this one and update #202 later. |
Pull request was converted to draft
Pull request was converted to draft
f74b7a5 to
af9b21d
Compare
af9b21d to
32db60d
Compare
PR #496 added an optional prettyName field to LExpr.abs and LExpr.quant constructors. Update pattern matches in LambdaToCProverGOTO.lean and StrataMain.lean to include the new parameter.
PR #510 added safe truncating division/modulo operators with division-by-zero preconditions. Map them to the same GOTO operators as their non-safe counterparts (Int.DivT/Int.ModT), since the precondition check is handled separately by the Laurel-to-Core translation.
Dismissing as stale, we can revisit the .py.st concern if need be.
Resolve conflicts with module conversion (#523) and GOTO backend (#289): - Convert TypeConstructor.lean to module with public section - Fix namespace resolution for TypeConstructor across module boundaries - Add typeDecl case to ToCProverGOTO - Remove unused mkParamName, deduplicate typeConArgsToCST - Address PR review comments
Description of changes:
Core-to-GOTO translation
Translate Strata Core programs to CProver GOTO binary format for CBMC
verification. Covers all Imperative statement types, Core commands,
procedure contracts, calls, axioms, datatypes, and source locations.
ToCProverGOTO.lean:
LambdaToCProverGOTO.lean (new, in Strata/Backends/CBMC/GOTO/):
and regex operators to GOTO equivalents
to signedbv via typecast so CBMC interprets them correctly
Int.SafeMod): encode as compound expressions built from truncating
div/mod with correction terms
CoreToCProverGOTO.lean (new, in Strata/Backends/CBMC/GOTO/):
InstToJson.lean:
StrataMain.lean:
Code reorganization
Production GOTO translation code moved from StrataTest/ to
Strata/Backends/CBMC/GOTO/ (LambdaToCProverGOTO.lean,
CoreToCProverGOTO.lean). Test files in StrataTest/ now import from
the production modules and contain only test code.
Tests and CI
expected output matching (CBMC properties checked by line number)
regex, and bounds-check patches; runs all CBMC test suites
Documentation
operator semantics decisions, and remaining open gaps
Co-authored-by: Kiro kiro-agent@users.noreply.github.com
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.