You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Phase 1b: store-typed preservation (generalize preservation to an arbitrary context) (#114)
## What
Adds **`store_step_preservation`** — the expression preservation theorem
generalized from the empty type context to an arbitrary `Γ` under a
store typing:
```lean
StoreWellTyped Γ ρ → HasType Γ e t → Step e ρ e' ρ' → HasType Γ e' t
```
This is the form **statement execution** needs: expressions appearing
inside a
statement are typed in the *running* context, not in the empty one.
## How
The proof mirrors the existing `preservation` (induction on the `Step`
derivation, inversion on the typing). The **only** case that differs is
`sVar`:
- **Before** (`preservation`, empty context): `.var x` is untypable, so
the case
is a contradiction (`emptyTypeEnv x = none`).
- **Now**: `store_wellTyped_lookup` gives the value `ρ` binds to `x`
together with
`HasType emptyTypeEnv (.lit v) t`, and `hasType_lit_any` lifts that to
the
running context `Γ`. Both lemmas landed in the two prior PRs (#112,
#113).
Every other case is context-polymorphic and textually identical to
`preservation`.
A **`preservation_via_store`** corollary confirms the generalization
subsumes the
closed theorem: the empty context is *vacuously* store-typed against any
store
(`emptyTypeEnv x = none` is never `some t`), so the old theorem is the
`Γ := emptyTypeEnv` instance.
## Why this shape (and not a refactor)
The cleaner design — make the general theorem primary and reduce
`preservation`
to a one-liner — would require moving `StoreWellTyped` /
`hasType_lit_any` *above*
`preservation` in the file, an invasive reorder of merged, CI-gated
proofs. This
PR is instead **purely additive (217 insertions, 0 deletions)**: the
merged
`preservation` and `type_safety` are left exactly as they are.
## Verification
- `lean docs/proofs/verification/WokeLang.lean` exits 0 (Lean 4.30.0,
Mathlib-free, single-file).
- Hole-free: `store_step_preservation` and `preservation_via_store`
depend only on
the classical kernel base (`propext`, `Classical.choice`, `Quot.sound`).
No
`sorryAx`, no project-specific assumptions.
## Scope
`docs/proofs/verification/WokeLang.lean` (the theorem + corollary) and a
Progress
entry in `docs/proofs/VERIFICATION-ROADMAP.md`. No changes to existing
proofs or to
the shipping implementation.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_015oyMquf4daB6hMhmqB1wAL
---
_Generated by [Claude
Code](https://claude.ai/code/session_015oyMquf4daB6hMhmqB1wAL)_
Co-authored-by: Claude <noreply@anthropic.com>
0 commit comments