Commit cb54027
Phase 1 core: the Substitution Lemma (type-safety.md Lemma 3.4) (#111)
Continues Tier 1 of the verification roadmap with the foundational piece
of Phase 1.
## `subst_preserves_typing` — the Substitution Lemma
Mechanizes type-safety.md **Lemma 3.4** on the existing hole-free
`WokeLang.lean`:
> If `e` is well typed under `Γ` extended with `x : tx`, and `v` is a
value of type `tx` under `Γ`, then `subst x v e` is well typed under `Γ`
at the same type.
- Adds `subst : String → Value → Expr → Expr` — capture-free (values are
closed; `Expr` has no binders).
- Proof by induction on the **typing derivation** with the context
generalized — all ~30 typing rules; the `tArray` case uses the
per-element IH + `List.mem_map`, and the `tVar` case does the `x :
tx`/`y : t'` lookup split.
- Axioms: `propext`, `Quot.sound`. No holes. `WokeLang.lean` still
compiles hole-free (CI-gated).
This is the prerequisite the type-theory survey called **"the single
biggest gap"** — it unblocks `[T-Call]`'s preservation case and
Algorithm W soundness (roadmap Phase 3a).
## Roadmap finding (refined accordingly)
While building this I confirmed `[T-Call]` is **not** the assumed simple
body-substitution: `Expr.call` is **by name** and `TopItem.functionDef`
bodies are **statement lists**, so call reduction entangles with
statement *execution* and belongs with **Phase 1b** (statement
dynamics), not this step. There's also no `index` AST constructor (so
`[T-Index]` needs an AST extension). The substitution lemma is the
clean, self-contained piece deliverable now; the rest of Phase 1
sequences after statement dynamics. `VERIFICATION-ROADMAP.md` progress
updated.
🤖 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 712b58a commit cb54027
2 files changed
Lines changed: 92 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
130 | | - | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
131 | 140 | | |
132 | 141 | | |
133 | 142 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1391 | 1391 | | |
1392 | 1392 | | |
1393 | 1393 | | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
| 1419 | + | |
| 1420 | + | |
| 1421 | + | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
| 1425 | + | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
| 1464 | + | |
| 1465 | + | |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
| 1474 | + | |
| 1475 | + | |
1394 | 1476 | | |
1395 | 1477 | | |
1396 | 1478 | | |
| |||
0 commit comments