Skip to content

Commit c7a6e77

Browse files
committed
Lemma B: step_preserves_type proof completion (#126)
1 parent 651a6d8 commit c7a6e77

3 files changed

Lines changed: 493 additions & 232 deletions

File tree

Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

formal/PRESERVATION-HANDOFF.md

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -226,14 +226,52 @@ New supporting lemmas added (all `Qed.`):
226226
`(r :: remove_first r R)` and `R` have the same membership when
227227
`In r R`. NO `NoDup R` required.
228228

229-
The single remaining admit is genuinely the hardest sub-case: the
230-
inner step exits the outer ERegion's own region, producing a typing
231-
that under `r :: remove_first r R` re-introduces `r` as fresh. To
232-
close it, we need `expr_free_of_region r e'` for the post-step inner
233-
expression. This follows from the underlying `S_Region_Exit`'s
234-
`expr_free_of_region r v` premise, but extracting it requires
235-
further inversion on `Hstep` to reach that base step. Small
236-
follow-up — `step_exit_implies_free_of_exited_region` would settle it.
229+
The single remaining admit is the cross-case where `Hte` uses
230+
`T_Region_Active` and `Hte'` uses `T_Region` — meaning the inner
231+
step exits the outer `ERegion`'s own region `r`, and `r` was unique
232+
in `R0` (so post-step `~In r remove_first r R0`).
233+
234+
**The genuine obstacle:** `e'` may syntactically reference `r` even
235+
though `r` was unique pre-step. Concrete witness: if
236+
`e = ELet (ERegion r v_inner) (ELoc l r)`, then after the inner
237+
`S_Region_Exit` we get `e' = ELet v_inner (ELoc l r)`. The post-step
238+
sibling `ELoc l r` still references `r`, so `expr_free_of_region r e'`
239+
is false. Yet `e'` is well-typed under `r :: remove_first r R0`
240+
because `T_Region` re-introduces `r` at the head, making
241+
`ELoc l r` typeable via the freshly-bound `r`. This is the
242+
semantic-freshness issue inherent to concrete-name region encodings:
243+
with alpha-renaming the post-step `r` would be a distinct region
244+
name; with concrete names the syntactic occurrence persists.
245+
246+
Consequences for closure paths:
247+
- Adding `NoDup R` as an invariant does **not** close it. The
248+
`T_Region`-vs-`T_Region_Active` choice in `Hte'` already encodes
249+
uniqueness in scope (`H3 : ~In r remove_first r R0` plus
250+
`H : In r R0` implies `r` unique). NoDup gives no extra info.
251+
- A `typing_implies_free_of_absent_region` lemma doesn't apply
252+
because `e'` is typed at `r :: remove_first r R0` where `r` IS
253+
present (at the head), so `~In r R` doesn't hold for the typing
254+
in scope.
255+
- A `step_exit_implies_free_of_exited_region` lemma would be **false**
256+
for congruence cases that preserve siblings — the sibling's
257+
surviving `r`-references break the freedom claim.
258+
259+
The genuinely-closing options are:
260+
1. **Mutual recursion with `preservation`**: prove `preservation`
261+
and `step_preserves_type` simultaneously. `preservation`'s direct
262+
construction of a typing for `e'` at the post-step `R'` provides
263+
exactly what this admit needs. Standard textbook approach for
264+
region calculi, but a significant restructuring touching both proofs.
265+
2. **Inversion on `Hstep` with structural recursion**: directly case-split
266+
on the step rule path that produced `R' = remove_first r R0`,
267+
handling the `S_Region_Exit`-at-top sub-case via region_shrink
268+
(works because `e' = v`, free of `r` by `S_Region_Exit`'s premise),
269+
and handling the congruence-bubbling sub-cases by recursive structural
270+
argument on the wrapping. ~150 LOC, orthogonal to the current case split.
271+
272+
Both are substantial follow-ups. The current single admit is bounded
273+
and well-documented; closing it should be deferred to whoever takes
274+
on (1) or (2) as a focused effort.
237275

238276
## Lemma B per-case status (2026-05-24)
239277

0 commit comments

Comments
 (0)