Skip to content

docs: Add exit-semantics design documentation#1080

Open
seebees wants to merge 1 commit intostrata-org:mainfrom
seebees:issue-993-exit-semantics
Open

docs: Add exit-semantics design documentation#1080
seebees wants to merge 1 commit intostrata-org:mainfrom
seebees:issue-993-exit-semantics

Conversation

@seebees
Copy link
Copy Markdown

@seebees seebees commented Apr 30, 2026

Adds a spec and decisions document for the small-step semantics of exit and labeled blocks in Strata/DL/Imperative/StmtSemantics.lean.

The spec uses RFC 2119 normative language only where an obligation maps to a specific Lean construct:

  • Preservation of well-formedness by every step, discharged by step_preserves_exitsCoveredByBlocks.
  • No-escape (exit does not leave a well-formed procedure body), discharged by exitsCoveredByBlocks_noEscape and its statement-list companion.

Per-transition behavior is documented descriptively, since each transition is directly realized by a constructor of StepStmt and does not carry a separate normative obligation.

The decisions document records six design choices and a future-work section, incorporating feedback from #993 and #869.

Tracks: #993

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Adds a spec and decisions document for the small-step semantics of
`exit` and labeled blocks in `Strata/DL/Imperative/StmtSemantics.lean`,
plus two thin Lean files giving each spec requirement a descriptive
public name.

## Documentation (`docs/design/exit-semantics/`)

The spec uses RFC 2119 normative language only where an obligation
maps to a specific Lean construct:
- Preservation of well-formedness by every step, discharged by
  `step_preserves_exitsCoveredByBlocks`.
- No-escape (exit does not leave a well-formed procedure body),
  discharged by `exitsCoveredByBlocks_noEscape` and its statement-list
  companion.

Per-transition behavior is documented descriptively, since each
transition is directly realized by a constructor of `StepStmt` and
does not carry a separate normative obligation.

The decisions document records six design choices and a future-work
section, incorporating feedback from strata-org#993 and strata-org#869.

## Lean

- `ExitProperties.lean` — seven per-transition lemmas
  (`exit_preserves_env`, `exit_skips_remaining`, `matching_block_consumes`,
  `nonmatching_exit_propagates`, `normal_block_completion`,
  `unlabeled_exit_consumed`, `block_body_steps`) plus two multi-step
  companions (`exit_eval`, `matching_block_eval`).
- `ExitWellFormedness.lean` — `exit_target_in_labels` and
  `exit_none_has_enclosing` over `Stmt.exitsCoveredByBlocks`.

Each lemma is a single-line proof over an existing `StepStmt` constructor
or `Stmt.exitsCoveredByBlocks` definitional equation. No new mathematical
content. Zero sorries.

Also promotes `step_preserves_exitsCoveredByBlocks` from private to
public so the spec's §4.3 requirement cites a public symbol.

Tracks: strata-org#993
@seebees seebees force-pushed the issue-993-exit-semantics branch from 867c5d2 to b28fd4d Compare April 30, 2026 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant