Commit d71dfe9
Phase 1b: statement-execution relation + preservation (simple-statement fragment) (#115)
## What
A big-step **statement-execution semantics** and its **store-typing
preservation**,
for the simple (non-control-flow) statements.
```lean
mutual
StmtExec : Stmt → Env → Env → Prop -- single statement
StmtsExec : List Stmt → Env → Env → Prop -- block, threaded left-to-right
end
```
Covered forms: `complain`, `expr`, `varDecl`, `assign`, `return_`. Each
evaluates
its expression to a value via the closed-store `MultiStep` (expression
evaluation
is store-invariant) and then applies its store effect.
## Metatheorem — store-typing preservation
```lean
stmt_exec_preservation : StoreWellTyped Γ ρ → StmtWellTyped Γ s Γ'
→ StmtExec s ρ ρ' → StoreWellTyped Γ' ρ'
stmts_exec_preservation : the same, threaded over a block
```
A well-typed statement (or block) run in a well-typed store yields a
store
well-typed against the statement's output context. The pieces compose
exactly as
the prior PRs set up:
| Statement | Preserved by |
|---|---|
| `varDecl` | `store_wellTyped_extend` (grows the context) |
| `assign` | `store_wellTyped_update` (overwrites an already-declared
variable at its type — **new** here) |
| `complain` / `expr` / `return_` | store and context unchanged |
and the value's type comes from `store_multiStep_preservation`
(multi-step
store-typed preservation, **new** here) + `hasType_lit_any`.
Two **executable smoke tests**: `let x = 0`, and the block `let x = 0;
x` staying
well-typed against the context it produces.
## Deferred (next increment) — and why
The control-flow forms `if` / `loop` / `attempt` / `consent` are **not**
included.
They introduce **block scoping**, which the flat `Env` (`String → Option
Value`)
model doesn't yet handle: a block-local `varDecl` shadowing an outer
variable at a
*different* type would leave the store ill-typed against the outer
context after
the block, unless the store is **restored on block exit**. That
store-restoration
design is a real modelling decision (it determines how faithfully the
model tracks
the Rust implementation's lexical scoping), so I've scoped it out of
this PR rather
than rush it. `return_`'s value-propagation / block short-circuit
(relevant once
function calls are modelled) is likewise deferred. Both are flagged in
the roadmap.
## Verification
- `lean docs/proofs/verification/WokeLang.lean` exits 0 (Lean 4.30.0,
Mathlib-free, single-file).
- Hole-free: new lemmas/theorems depend only on the classical kernel
base
(`propext`, `Classical.choice`, `Quot.sound`); `store_wellTyped_update`
needs
**no** axioms. No `sorryAx`.
- **Purely additive (123 insertions, 0 deletions).** No existing proof
touched.
## Scope
`docs/proofs/verification/WokeLang.lean` (relations + lemmas + theorems
+ 2 smoke
tests) and a Progress entry in `docs/proofs/VERIFICATION-ROADMAP.md`. No
changes 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>1 parent 01f7329 commit d71dfe9
2 files changed
Lines changed: 141 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
163 | 163 | | |
164 | 164 | | |
165 | 165 | | |
166 | | - | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
167 | 184 | | |
168 | 185 | | |
169 | 186 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1778 | 1778 | | |
1779 | 1779 | | |
1780 | 1780 | | |
| 1781 | + | |
| 1782 | + | |
| 1783 | + | |
| 1784 | + | |
| 1785 | + | |
| 1786 | + | |
| 1787 | + | |
| 1788 | + | |
| 1789 | + | |
| 1790 | + | |
| 1791 | + | |
| 1792 | + | |
| 1793 | + | |
| 1794 | + | |
| 1795 | + | |
| 1796 | + | |
| 1797 | + | |
| 1798 | + | |
| 1799 | + | |
| 1800 | + | |
| 1801 | + | |
| 1802 | + | |
| 1803 | + | |
| 1804 | + | |
| 1805 | + | |
| 1806 | + | |
| 1807 | + | |
| 1808 | + | |
| 1809 | + | |
| 1810 | + | |
| 1811 | + | |
| 1812 | + | |
| 1813 | + | |
| 1814 | + | |
| 1815 | + | |
| 1816 | + | |
| 1817 | + | |
| 1818 | + | |
| 1819 | + | |
| 1820 | + | |
| 1821 | + | |
| 1822 | + | |
| 1823 | + | |
| 1824 | + | |
| 1825 | + | |
| 1826 | + | |
| 1827 | + | |
| 1828 | + | |
| 1829 | + | |
| 1830 | + | |
| 1831 | + | |
| 1832 | + | |
| 1833 | + | |
| 1834 | + | |
| 1835 | + | |
| 1836 | + | |
| 1837 | + | |
| 1838 | + | |
| 1839 | + | |
| 1840 | + | |
| 1841 | + | |
| 1842 | + | |
| 1843 | + | |
| 1844 | + | |
| 1845 | + | |
| 1846 | + | |
| 1847 | + | |
| 1848 | + | |
| 1849 | + | |
| 1850 | + | |
| 1851 | + | |
| 1852 | + | |
| 1853 | + | |
| 1854 | + | |
| 1855 | + | |
| 1856 | + | |
| 1857 | + | |
| 1858 | + | |
| 1859 | + | |
| 1860 | + | |
| 1861 | + | |
| 1862 | + | |
| 1863 | + | |
| 1864 | + | |
| 1865 | + | |
| 1866 | + | |
| 1867 | + | |
| 1868 | + | |
| 1869 | + | |
| 1870 | + | |
| 1871 | + | |
| 1872 | + | |
| 1873 | + | |
| 1874 | + | |
| 1875 | + | |
| 1876 | + | |
| 1877 | + | |
| 1878 | + | |
| 1879 | + | |
| 1880 | + | |
| 1881 | + | |
| 1882 | + | |
| 1883 | + | |
| 1884 | + | |
| 1885 | + | |
| 1886 | + | |
| 1887 | + | |
| 1888 | + | |
| 1889 | + | |
| 1890 | + | |
| 1891 | + | |
| 1892 | + | |
| 1893 | + | |
| 1894 | + | |
| 1895 | + | |
| 1896 | + | |
| 1897 | + | |
| 1898 | + | |
| 1899 | + | |
| 1900 | + | |
| 1901 | + | |
| 1902 | + | |
| 1903 | + | |
1781 | 1904 | | |
1782 | 1905 | | |
1783 | 1906 | | |
| |||
0 commit comments