Rewrite StrataCoreToGoto for multi-procedure programs with contracts#657
Draft
tautschnig wants to merge 4 commits intomainfrom
Draft
Rewrite StrataCoreToGoto for multi-procedure programs with contracts#657tautschnig wants to merge 4 commits intomainfrom
tautschnig wants to merge 4 commits intomainfrom
Conversation
- Iterate over all procedures and functions in the Core program - Apply call elimination to inline contracts (configurable via --no-call-elim) - Re-type-check after call elimination for new variable discovery - Seed type environment with global variable types - Apply GOTO pipeline passes: function inlining, recursive inlining, datatype partial evaluation, datatype axiom/recursive function axiom generation, datatype expression rewriting - Deduplicate symbol table, add default symbols Tests: - test_multi_proc.core.st: multi-procedure Core program with contracts - test_strata_core_to_goto.sh: verifies translation, symbol table, contract annotations, and GOTO assertions Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Updates StrataCoreToGoto to support translating multi-procedure Strata Core programs (including procedure contracts) into aggregated CBMC GOTO JSON outputs, and adds a regression test exercising the new behavior.
Changes:
- Reworks
StrataCoreToGototo iterate over all procedures/functions, optionally run call elimination, re-type-check, run GOTO pipeline passes, and emit combined symtab/goto JSON. - Adds a
--no-call-elimflag to optionally skip call elimination. - Adds a multi-procedure Core test input plus a bash test that validates translation output, symbol table content, contract annotations, and presence of ASSERT instructions.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 9 comments.
| File | Description |
|---|---|
StrataCoreToGoto.lean |
New multi-procedure translation + pipeline passes, symbol table aggregation/dedup, default symbol injection, new CLI flag. |
StrataTest/Backends/CBMC/GOTO/test_strata_core_to_goto.sh |
New end-to-end-ish test script validating multi-proc translation artifacts. |
StrataTest/Backends/CBMC/GOTO/test_multi_proc.core.st |
New Core input program with two procedures, contracts, a global var, and an assert. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
github-merge-queue bot
pushed a commit
that referenced
this pull request
Mar 26, 2026
FUNCTION_CALL callees (e.g., print) had Empty type in the symbol table because coreStmtsToGoto created the callee expression with .Empty type. CBMC instrument_preconditions crashed trying to_code_type on Empty. Fix: add Ty.Identifier.code and Ty.mkCode, use it for the callee expression in coreStmtsToGoto. The code type flows through collectSymbolRefs into the symbol table naturally. Fixes 16 Python CBMC tests that use class-related function calls. See PRs like #657 for current failures on that. By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice. --------- Co-authored-by: Kiro <kiro-agent@users.noreply.github.com> Co-authored-by: Josh Cohen <36058610+joscoh@users.noreply.github.com>
- Sanitize programName to prevent path traversal in output filenames - Remove unused Ctx variable - Use Array instead of List for symtabPairs to avoid quadratic append - Track translation errors and return non-zero exit code on failure - Use HashMap for symbol table dedup with last-wins semantics so that collectExtraSymbols globals/datatypes override per-procedure entries - Strengthen test to verify global variable has isStaticLifetime attribute - Use set -euo pipefail in test script for consistency Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
Follow the pattern of PR #691 (StrataVerify → strata verify) and migrate the standalone StrataCoreToGoto executable into a coreToGoto subcommand of the strata CLI. - Delete StrataCoreToGoto.lean, move logic into StrataMain.lean - Use the shared Command/ParsedFlags infrastructure and exit code scheme - Add .core.st to deriveBaseName suffix list - Remove StrataCoreToGoto from lakefile.toml and defaultTargets - Update test script, mkGotoBin.sh, README, and steering doc Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
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.
Tests:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.