Commit 8282857
authored
fix(coq): preservation 910 -> 29 open goals via remember-cfg pattern (Refs standards#134) (#102)
## Summary
**97% reduction in `preservation`'s open-goal count** (910 → 29) by
applying the standard preservation pattern. The proof remains
`Admitted.` — this PR is the cross-case discharge mechanism + the
per-case work list, not the full close.
This supersedes ephapax#98 (which proposed the 910-goal handoff but did
not include the fix); #98 can be closed in favour of this PR.
## The root cause
`induction Hstep` did not substitute the outer expression slot `e` to
the constructor's form (`e := EStringNew r s` etc.). So `inversion
Htype` produced **all 26 typing arms per step rule** — the full 35 × 26
= 910 cross-case combinatorial. Cross-cases had no discriminating
equation in scope, so `try solve [exfalso; discriminate | exfalso;
congruence]` couldn't fire.
Verified empirically with `Show. Show Existentials.` after `inversion
Htype; subst;` — the existing `try solve [...]` chain at L3228–L3340
closes **ZERO** of the 910.
## The fix
```coq
intros mu R e mu' R' e' Hstep.
remember (mu, R, e) as cfg eqn:Hcfg.
remember (mu', R', e') as cfg' eqn:Hcfg'.
induction Hstep; intros G0 T0 G0' Htype;
inversion Hcfg; subst;
inversion Hcfg'; subst;
inversion Htype; subst;
(* existing try-solve chain (unchanged) *)
```
`remember` turns `Hstep : step (mu, R, e) (mu', R', e')` into `Hstep :
step cfg cfg'` with two side equations. After `induction Hstep`, `Hcfg`
becomes (for `S_StringNew`) `(mu0, R0, EStringNew r s) = (mu, R, e)`,
which `inversion Hcfg; subst` decomposes — substituting `e := EStringNew
r s` everywhere including in `Htype`. Then `inversion Htype; subst` only
generates the diagonal `T_StringNew` arm; the 25 cross-arms are
eliminated by inversion's constructor-mismatch check.
The earlier `remember e_typed as e_orig` was a misdiagnosis — it
remembered the *typing's* `e` (already abstract) instead of the
*config's* expression slot (which is what `induction Hstep` substitutes
for).
## What's left (29 real diagonal goals)
| Category | Step rules | Tactic |
|----------|-----------|--------|
| Axiom + reconstruct | `S_StringNew`, `S_StringConcat`, `S_StringLen` |
`eexists; eapply T_Loc/T_StringConcat/...` |
| β-reduction | `S_Let_Val`, `S_LetLin_Val`, `S_App_Fun`, `S_If_*`,
`S_Fst`, `S_Snd`, `S_Case_*` | `eexists; eapply subst_preserves_typing;
eauto` |
| Congruence | `S_*_Step` variants (~15) | `destruct (IHHstep ...);
eexists; econstructor; eauto` |
| Region | `S_Region_Enter`, `S_Region_Step`, `S_Region_Exit` | existing
`T_Region_Active` / `region_shrink_preserves_typing`; `S_Region_Step +
T_Region_Active` needs a NEW region-env weakening lemma |
| Linear | `S_Drop`, `S_Copy` | `eexists; constructor` |
Supporting lemmas already Qed: `subst_preserves_typing`,
`region_env_perm_typing`, `region_add_typing`,
`region_shrink_preserves_typing`, `values_dont_step`.
The region-env weakening lemma for non-values is the only genuine theory
question; the other 28 are 1–2 days of standard tactic glue.
## Files
- `formal/Semantics.v` — apply the remember-cfg pattern. Replace the old
`remember e_typed as e_orig` (the misdiagnosis) with the new `remember
(mu, R, e) as cfg` / `remember (mu', R', e') as cfg'` before
`induction`, plus `inversion Hcfg; subst; inversion Hcfg'; subst;` after
`intros ... Htype` and before the existing `inversion Htype; subst;`.
Update the in-file proof-status comment to reflect 910 → 29.
- `PROOF-NEEDS.md` — `preservation` "what needs proving" entry updated
to reflect the 910 → 29 reduction + pointer to the handoff doc.
- `formal/PRESERVATION-HANDOFF.md` — full per-case checklist for the 29
remaining goals; supersedes the 910-goal version on PR#98.
## Verification (local, Coq 8.18.0)
```
cd formal && coq_makefile -f _CoqProject -o Makefile.coq && make -f Makefile.coq
# → exit 0; Syntax.vo + Typing.vo + Semantics.vo all produced.
```
## Refs
Refs standards#134 (**NOT Closes** — joint-close on agreement).
Supersedes ephapax#98.
## Test plan
- [x] `cd formal && coq_makefile -f _CoqProject -o Makefile.coq && make
-f Makefile.coq` → exit 0 locally
- [x] `Show. Show Existentials.` immediately before `Admitted.` shows 29
goals (down from 910 on the prior state)
- [ ] CI green on `rust-ci.yml` "Coq proofs" job
- [ ] Close #98 in favour of this PR
🤖 Generated with [Claude Code](https://claude.com/claude-code)1 parent 95868b9 commit 8282857
3 files changed
Lines changed: 206 additions & 57 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3212 | 3212 | | |
3213 | 3213 | | |
3214 | 3214 | | |
| 3215 | + | |
| 3216 | + | |
| 3217 | + | |
| 3218 | + | |
| 3219 | + | |
| 3220 | + | |
| 3221 | + | |
| 3222 | + | |
| 3223 | + | |
| 3224 | + | |
| 3225 | + | |
| 3226 | + | |
| 3227 | + | |
| 3228 | + | |
| 3229 | + | |
| 3230 | + | |
| 3231 | + | |
| 3232 | + | |
| 3233 | + | |
| 3234 | + | |
| 3235 | + | |
| 3236 | + | |
3215 | 3237 | | |
3216 | | - | |
3217 | | - | |
3218 | | - | |
3219 | | - | |
3220 | | - | |
3221 | | - | |
3222 | | - | |
3223 | | - | |
3224 | | - | |
3225 | | - | |
3226 | | - | |
| 3238 | + | |
| 3239 | + | |
3227 | 3240 | | |
3228 | 3241 | | |
3229 | 3242 | | |
| |||
3325 | 3338 | | |
3326 | 3339 | | |
3327 | 3340 | | |
3328 | | - | |
3329 | | - | |
3330 | | - | |
3331 | | - | |
3332 | | - | |
3333 | | - | |
3334 | | - | |
3335 | | - | |
3336 | | - | |
3337 | | - | |
3338 | | - | |
3339 | | - | |
3340 | | - | |
3341 | | - | |
3342 | | - | |
3343 | | - | |
3344 | | - | |
3345 | | - | |
3346 | | - | |
3347 | | - | |
3348 | | - | |
3349 | | - | |
3350 | | - | |
3351 | | - | |
3352 | | - | |
3353 | | - | |
3354 | | - | |
3355 | | - | |
3356 | | - | |
3357 | | - | |
3358 | | - | |
3359 | | - | |
3360 | | - | |
3361 | | - | |
3362 | | - | |
3363 | | - | |
3364 | | - | |
3365 | | - | |
3366 | | - | |
3367 | | - | |
3368 | | - | |
3369 | | - | |
3370 | | - | |
3371 | | - | |
3372 | | - | |
| 3341 | + | |
| 3342 | + | |
| 3343 | + | |
| 3344 | + | |
| 3345 | + | |
| 3346 | + | |
| 3347 | + | |
| 3348 | + | |
| 3349 | + | |
| 3350 | + | |
| 3351 | + | |
| 3352 | + | |
| 3353 | + | |
| 3354 | + | |
| 3355 | + | |
| 3356 | + | |
| 3357 | + | |
| 3358 | + | |
| 3359 | + | |
| 3360 | + | |
| 3361 | + | |
| 3362 | + | |
| 3363 | + | |
| 3364 | + | |
| 3365 | + | |
| 3366 | + | |
| 3367 | + | |
| 3368 | + | |
| 3369 | + | |
| 3370 | + | |
| 3371 | + | |
| 3372 | + | |
| 3373 | + | |
| 3374 | + | |
| 3375 | + | |
| 3376 | + | |
| 3377 | + | |
0 commit comments