Skip to content

feat(transform): Add optional SSA transformation for Strata Core#1127

Draft
sagjoshi wants to merge 3 commits intomainfrom
sagjoshi
Draft

feat(transform): Add optional SSA transformation for Strata Core#1127
sagjoshi wants to merge 3 commits intomainfrom
sagjoshi

Conversation

@sagjoshi
Copy link
Copy Markdown

@sagjoshi sagjoshi commented May 5, 2026

Introduce a Static Single Assignment (SSA) transformation that converts
procedure bodies so every variable is assigned exactly once via init.
Mutations (set, havoc) become fresh init declarations. At if-then-else
join points, conditional init expressions merge divergent variable versions.

Uses the standard CoreTransformM monad with CoreGenState.gen for fresh
name generation (ssa_ prefix), aligning with transform API conventions.

Integration:

  • Available as `--pass ssa` in the transform CLI command
  • Available as `TransformPass.ssa` in the SimpleAPI
  • Not part of the default verification pipeline (opt-in)

Files:

  • `Strata/Transform/SSA.lean`: transformation implementation
  • `StrataTest/Transform/SSA.lean`: 16 tests
  • `Strata/SimpleAPI.lean`: TransformPass.ssa + applyPass wiring
  • `StrataMain.lean`: ssa added to valid transform passes

sagjoshi added 3 commits May 5, 2026 15:33
Introduce a Static Single Assignment (SSA) transformation that converts
procedure bodies so every variable is assigned exactly once via init.
Mutations (set, havoc) become fresh init declarations. At if-then-else
join points, conditional init expressions merge divergent variable
versions.

The transformation:
- Runs after callElim and loopElim (no calls or loops expected)
- Converts set to init with fresh variable names (x_0, x_1, ...)
- Converts havoc to nondet init
- Rewrites expressions to reference current SSA variable versions
- Emits conditional merge inits at if-then-else join points
- Uses modelPreserving validation (semantics-preserving)

Integration:
- Available as --pass ssa in the transform CLI command
- Available as TransformPass.ssa in the SimpleAPI
- Not part of the default verification pipeline (opt-in)

Files:
- Strata/Transform/SSA.lean: transformation implementation
- StrataTest/Transform/SSA.lean: 16 tests covering straight-line,
  if-then-else, havoc, nested branches, multiple variables, inout
  params, and pipeline chaining
- Strata/SimpleAPI.lean: TransformPass.ssa + applyPass integration
- StrataMain.lean: ssa added to valid transform passes
Refactor SSA transformation to use the standard CoreTransformM monad
instead of a custom SSAM monad. This aligns with the transform API
conventions used by other transforms (CallElim, LoopElim, etc.).

Changes:
- Use CoreGenState.gen for fresh name generation (ssa_ prefix)
- Use Transform.incrementStat for statistics
- Use Transform.createFvar for fvar construction
- Thread Env through function parameters instead of custom state
- Replace panic! with empty program fallback in test helper
Use #eval instead of #eval! as recommended. The #eval! was a leftover
from an earlier iteration that had sorry dependencies.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant