Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
032e8ea
docs(audit): reconcile standards#134 sub-tasks against 2026-05-26 gro…
hyperpolymath May 26, 2026
83e1e31
docs(handoff): correct case counts after 2026-05-24 cluster closures
hyperpolymath May 26, 2026
36ff88e
docs(audit): Lemma B Phase 2 Option 2 hits a real obstacle, pivot to …
hyperpolymath May 26, 2026
5318a37
docs: session note + STATE.a2ml refresh for the Lemma B pivot
hyperpolymath May 26, 2026
715a6b7
docs: ROADMAP + PROOF-NEEDS reflect 2026-05-26 Path-1 pivot
hyperpolymath May 26, 2026
c55651f
proof: Qed step_preserves_type + step_output_context_eq via at-pre he…
hyperpolymath May 26, 2026
f7aa76a
proof: close 27 of 35 cases in step_preserves_type_at_pre via copied …
hyperpolymath May 26, 2026
1fa0f1c
proof: copy step_output_context_eq's tactic blocks into _at_pre helper
hyperpolymath May 26, 2026
1069a35
docs(proof-needs): Path 3 (at-pre helper) closes the shared 4885/5963…
hyperpolymath May 26, 2026
67114b5
proof: swarm A+B integration — 3 more cases closed in at-pre helpers …
hyperpolymath May 26, 2026
9cb24b4
proof: scaffold S_Let_Step LEFT splice with idtac RIGHT fallthrough
hyperpolymath May 26, 2026
d6ebf68
proof: Swarm A+B+C closures land — at-pre helpers Qed, 10 preservatio…
hyperpolymath May 26, 2026
97d39e2
docs: ROADMAP + PRESERVATION-HANDOFF reflect at-pre helpers Qed (post…
hyperpolymath May 26, 2026
04975fc
proof: narrow MIDDLE branches in preservation S_*_Step blocks (10 adm…
hyperpolymath May 26, 2026
894011a
proof: typing_free_of_absent_region (Qed) — Brief C kernel (#151)
hyperpolymath May 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 39 additions & 16 deletions .machine_readable/6a2/STATE.a2ml
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,51 @@

@state(version="2.0"):
phase: "implementation"
next_action: "Close residual ~29 open goals in formal/Semantics.v preservation theorem (see formal/PRESERVATION-HANDOFF.md for per-case checklist)"
last_action: "Rust/SPARK ABI seam landed (PR#95); preservation proof now Admitted with honest open-goal count after 910 -> 29 reduction (PR#102)"
updated: 2026-05-20T19:00:00Z
next_action: "Discharge ~8 per-goal cases in step_preserves_type_at_pre + ~11 in step_output_context_eq_at_pre (port from upstream's per-goal sections, ~2-3h each). Then re-attack preservation's 12 cascading goals using step_preserves_type + step_output_context_eq as oracles (~4-8h, may need region-env weakening for non-values)."
last_action: "Path 3 (at-pre helper) landed 2026-05-26 eve. step_preserves_type AND step_output_context_eq both now Qed (was Admitted with 1 shared admit each at S_Region_Step r=r1 cross-case). Two new helper lemmas introduced (Admitted with most cases auto-closed by verbatim block copy). 4 proof commits + 1 doc commit pushed to lemma-b-phase2 (ephapax#146)."
updated: 2026-05-26T19:00:00Z

@blockers:
# Formal proofs NOT fully closed (earlier "FULLY CLOSED (67 Qed, 0 Admitted)"
# claim was wrong — `coqc` 8.18.0 rejects `Qed.` on preservation).
# - formal/Semantics.v `preservation`: Admitted (down from 910 to ~29 open
# goals via remember-cfg pattern, PR#102). The prior in-file `Qed.` was
# rejected with "Attempt to save an incomplete proof"; the build-oracle
# is now source of truth. PR#92 marked it Admitted and reverted PR#87's
# propagated "Qed, closed 2026-04-27" claim from ROADMAP+PROOF-NEEDS.
# - src/formal/Ephapax/Formal/RegionLinear.idr `regionSafetyExtract` /
# `noGCExtract`: vacuous wrappers (body is the input unchanged); ROADMAP
# citing them as "regionSafetyTheorem"/"noGCTheorem" complete is
# overstated. Honest E3/E4 obligations stated in src/abi/Ephapax/ABI/
# Invariants.idr (PR#95-MERGED).
# Formal proofs NOT fully closed; current shape (verified by coqc 8.18 on
# 2026-05-26 eve):
# - formal/Semantics.v `step_preserves_type` (line 4355): Qed ✓
# - formal/Semantics.v `step_output_context_eq` aka Lemma B: Qed ✓
# - formal/Semantics.v `step_preserves_type_at_pre` (NEW, line ~3625):
# Admitted with `all: admit.` catch-all. 27 of 35 cases closed via
# verbatim copy of step_preserves_type's tactic blocks (Cluster A+B).
# 8 per-goal cases remaining: S_StringConcat_Step2, S_Let_Step,
# S_LetLin_Step, S_App_Step2, S_If_Step, S_Pair_Step1, S_Pair_Step2,
# S_Case_Step.
# - formal/Semantics.v `step_output_context_eq_at_pre` (NEW, line ~5698):
# Admitted with `all: admit.` catch-all. ~24-27 of 35 cases closed via
# verbatim copy. S_Region_Step block deliberately excluded (would
# self-reference). ~11 cases remaining.
# - formal/Semantics.v `preservation`: 12 cascading goals — SEPARATE
# structural problem (region-env weakening for non-values), NOT the
# shared admit closed by Path 3.
#
# Path 3 (at-pre helper) lands. Path 1 (mutual induction) and Path 2
# (structural recursion via expr_free_of_region) both AVOIDED — Path 2
# was blocked by counterexample, Path 1 would have been heavier refactor.
# Path 3 wins by sidestepping the cross-case via shared-env framing.
#
# Other proof-debt items (out of standards#134 scope):
# - src/abi/Ephapax/ABI/Invariants.idr E1-E6: E1 (preservation) OWED;
# E2 (linear consumption) PARTIAL (head form discharged via
# splitLinearCoverage PR#85); E3 (region no-escape) PARTIAL (narrow
# form discharged via noEscapeTheorem); E4 (no-runtime-GC) OWED;
# E5 (WASM compilation) OWED; E6 (IR lowering) OWED.
# Estate proof-debt arm: standards#134 (OPEN).
# - 30 unsafe Rust blocks (was 49); concentrated in
# src/ephapax-runtime/src/{lib,list}.rs and src/ephapax-interp/src/lib.rs.
# Per-block contract audit out of scope for standards#134.
# Estate proof-debt arm: standards#134 (OPEN; 4/5 sub-tasks DONE pre-2026-05-26).
@end

@artifacts:
# Doc-only commits parked on `lemma-b-phase2` (PR ephapax#146):
# 032e8ea - audit reconciliation (docs/reports/audit/audit-2026-05-26-standards-134-reconciliation.md)
# 83e1e31 - handoff case-count correction (formal/PRESERVATION-HANDOFF.md)
# 36ff88e - Option 2 obstacle + Path 1 pivot (docs/reports/audit/audit-2026-05-26-lemma-b-option-2-obstacle.md)
# Plus this STATE update + session note (docs/sessions/SESSION-2026-05-26-lemma-b-pivot.adoc).
@end
@end
32 changes: 20 additions & 12 deletions PROOF-NEEDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,35 @@

## Current state
- `formal/Syntax.v` — Coq formalization of Ephapax syntax (clean)
- `formal/Semantics.v` — Coq operational semantics; `preservation` **Admitted** (earlier in-file comment claiming "Qed, closed 2026-04-27" was unsubstantiated — `coqc` 8.18.0 rejects the proof script with remaining open goals)
- `formal/Semantics.v` — Coq operational semantics
- `step_preserves_type` — **Qed** (closed 2026-05-26 via [Path 3 at-pre helper](#path-3-at-pre-helper))
- `step_output_context_eq` (Lemma B) — **Qed** (closed 2026-05-26 via Path 3)
- `step_preserves_type_at_pre` — **Admitted** (NEW helper; 8 of 35 cases remain admitted, falls through to `all: admit.` catch-all)
- `step_output_context_eq_at_pre` — **Admitted** (NEW helper; analogous shape)
- `preservation` — **Admitted** (12 cascading goals — separate problem, region-env weakening for non-values)
- `formal/Typing.v` — Coq typing rules (clean)
- `src/formal/Ephapax/Formal/RegionLinear.idr` — Idris2 region-based linearity proof (explicitly states "REAL proof — not believe_me, not assert_total")
- 17 Idris2 files across formal verification layer
- No `believe_me`, `sorry`, or `assert_total` in Idris2 source code
- Coq admitted proofs remaining in `formal/Semantics.v`: 1 (`preservation` — 12 open goals, plan below)

## What needs proving
- **`preservation`**: Close the remaining **12 open goals** in `formal/Semantics.v` so the `Qed` lands. Down from 910 at session start (98.7% reduction). Reduction story: 910 → 29 via remember-cfg (PR #102) → 22 via universal-IH revert (PR #106) → 12 via per-case manual closures (PR #116). The remaining 12 are 11 congruence cases (`S_*_Step` variants) + 1 region case (`S_Region_Step + T_Region_Active`).
## Path 3 at-pre helper

The 2026-05-26 Path-1 (mutual induction) plan was superseded by a simpler approach: introduce two NEW helper lemmas whose typings are at the SAME pre-step env R (not R/R'). The key insight: in the S_Region_Step cross-case `Hte = T_Region_Active` × `Hte' = T_Region` with `R0' = remove_first r R0` and `r = r1`, the body's typing under `r :: R0'` is membership-equivalent to `R0` (via `remove_first_then_cons_membership_eq`). After perm transport, both bodies are typed at R0 — the at-pre helper concludes type/output-context equality.

The at-pre helpers' S_Region_Step case is structurally simpler than the original because `In r R0` (from S_Region_Step's premise) FORCES `T_Region_Active` on both sides — the problematic cross-case vanishes by contradiction.

**Canonical closure path: `ROADMAP.adoc` § Preservation closure plan** — 5 phases:
Most of the helpers' OTHER cases were closed by copying step_preserves_type's and step_output_context_eq's tactic blocks verbatim (patterns use `?R`/`?R'` polymorphically and match at-pre framing trivially). What remains in each helper is the per-goal cases (~8 of 35), pending case-by-case closure.

## What needs proving
- **`step_preserves_type_at_pre`**: Close the remaining ~8 admitted cases (the per-goal cases of step_preserves_type's structure that need explicit blocks: S_StringConcat_Step2, S_Let_Step, S_LetLin_Step, S_App_Step2, S_If_Step, S_Pair_Step1, S_Pair_Step2, S_Case_Step). Each ~30 LOC, ported from step_preserves_type's "Per-goal" section (lines 5033-5562). Estimated 2-3h.
- **`step_output_context_eq_at_pre`**: Close ~11 remaining admitted cases (the per-goal cases + S_Region_Step). Patterns parallel step_output_context_eq's body. Estimated 2-3h.
- **`preservation`**: Close the remaining **12 open goals** — the RIGHT branch (R' = remove_first r R) sub-cases of each congruence step rule. These need a **region-env weakening for non-values** lemma that doesn't follow trivially from current infrastructure. Per the handoff doc, this is a deeper problem: when a binder steps to exit region r, the sibling expression might still mention r and not be typeable at the post-step R'. Closing requires either (a) a strengthened type invariant preventing such configurations, (b) a weakened preservation statement, or (c) a region-env weakening helper that case-analyses on the sibling's syntactic shape. Estimated 4-8h.

1. **Lemma B (linearity-context invariance for siblings)** — closes the IH-vs-sibling context mismatch blocking the 11 congruence cases. ~3–4 hours.
2. **Apply Lemma B → close 11 congruence cases** — per-case manual proof scripts (PR #116 pattern). ~2 hours, parallelizable.
3. **Region-env weakening lemma for non-values** — defines `safe_for_region_weakening` predicate + proves the weakening lemma. 1–2 days, genuine metatheoretic work.
4. **Apply Phase 3 lemma → close S_Region_Step** — ~1 hour.
5. **`Admitted.` → `Qed.` + docs sweep** — mechanical, ~1 hour.
Reduction story (910 → 12): 910 via remember-cfg (PR #102) → 22 via universal-IH revert (PR #106) → 12 via per-case manual closures (PR #116). The 2026-05-26 Path-3 work closed the SAME structural admit shared across step_preserves_type:4885 and step_output_context_eq:5963 (the `S_Region_Step` `r = r1` "exited from inside" case) by introducing two at-pre helpers and using `region_env_perm_typing` to bridge. The 12 cascading goals in `preservation` remain — they're a SEPARATE structural problem (region-env weakening), not the same shared admit.

Total: 3 sessions / ~10 hours wall-clock with fan-out. See ROADMAP for full effort estimates and risk-adjusted forecast.
Total focused wall-clock to full Qed: **~6-12h** (depending on the depth of the preservation region-env weakening fix).

Supporting lemmas already Qed: `subst_preserves_typing`, `region_env_perm_typing`, `region_add_typing`, `region_shrink_preserves_typing`, `values_dont_step`, and **`step_R_eq_or_touches_region`** (PR #114, the region-invariance lemma used by the per-case closures and required by Phase 2).
Supporting lemmas already Qed: `subst_preserves_typing`, `region_env_perm_typing`, `region_add_typing`, `region_shrink_preserves_typing`, `values_dont_step`, **`step_R_eq_or_touches_region`** (PR #114), and now **`step_preserves_type`** + **`step_output_context_eq`** (closed 2026-05-26 via at-pre helpers).
- **Linear type consumption**: Prove resources with linear types are consumed exactly once across all execution paths (region boundaries, exception handlers)
- **Effect system soundness**: Prove the effect type system correctly tracks side effects and that effect-free terms are truly pure
- **Region safety**: Prove that region-based memory management prevents use-after-free and dangling references across region boundaries
Expand Down
34 changes: 24 additions & 10 deletions ROADMAP.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ substitution semantics:

| **`preservation`**
| 🟡 Admitted
| **12 open goals** after the reduction chain (PRs #92 / #102 / #104 / #106 / #114 / #116 / #117 / #121). Started at 910; 98.7% reduced. Phase 1 scaffold (Lemma B `step_output_context_eq`) landed; per-case discharges next. Remaining 12 = 11 congruence cases (blocked on Lemma B per-case closure) + 1 region case (`S_Region_Step + T_Region_Active`, blocked on region-env weakening). Canonical closure path: ROADMAP §"Preservation closure plan" below.
| **11 open goals** after the reduction chain (PRs #92 / #102 / #104 / #106 / #114 / #116 / #117 / #121 / #146). Started at 910; 98.8% reduced. Lemma B (`step_output_context_eq`) + its `step_preserves_type_at_pre` / `step_output_context_eq_at_pre` plug-ins are all `Qed` (commit `d6ebf68`, 2026-05-26). Remaining 11 = 10 RIGHT-only congruence sub-cases (`HTR : touches_region` in scope, blocked on region-env weakening for non-values — see Phase 3 below) + 1 region case (`S_Region_Step + T_Region_Active`, same blocker). Canonical closure path: ROADMAP §"Preservation closure plan" below.
|===

**Historical note**: an earlier in-file comment claimed `preservation`
Expand Down Expand Up @@ -196,10 +196,19 @@ up the proof should follow.
| Phase 1 empirical baseline (2026-05-24)
| 12 (preservation) / **31 of 35** (Lemma B itself)
| `cfg`-remember pattern + atomic-axiom tactic on Lemma B closes 4 of its 35 step-rule cases (`S_StringNew`, `S_StringConcat`, `S_Drop`, `S_Borrow_Step`); the remaining 31 cluster across β-reduction / congruence / region-and-compound-value branches. Per-case map in `formal/PRESERVATION-HANDOFF.md`.

| Phase 1 cluster closures (2026-05-24 night)
| 12 (preservation) / **1 of 35** (Lemma B itself)
| Cluster A (β-reduction, 7) FULLY CLOSED via `subst_preserves_typing_strong` + `output_ctx_det`. Cluster C (region/compound-value, 6) FULLY CLOSED via inversion + `value_context_unchanged`. Cluster B (congruence) 9 of 18 closed via R-shape dispatch + 2 more via sibling type_determinacy trick. **1 admit remains** in Lemma B and step_preserves_type — the same S_Region_Step `r=r1` "inner step exits outer region from inside" sub-case mirrored.

| 2026-05-26 re-verification
| **1 + 1 + 12** (step_preserves_type + Lemma B + preservation)
| Empirical coqc 8.18 re-grep. The 14 total = 1 independent (shared S_Region_Step admit) + 12 cascading (close on Lemma B Qed). **PRESERVATION-HANDOFF's recommended Option 2 (structural recursion on `Hstep`) is BLOCKED** by the counterexample `ELet (ERegion r v_inner) e2` with e2 referencing r (T_Let has no sibling-freedom premise). Pivot to Path 1 (mutual induction over `step_preserves_type` + `step_output_context_eq` + `preservation`). See `docs/reports/audit/audit-2026-05-26-lemma-b-option-2-obstacle.md` + `docs/sessions/SESSION-2026-05-26-lemma-b-pivot.adoc`.
|===

98.7% reduction across one day. Remaining 12 = 11 congruence cases
(`S_*_Step` variants) + 1 region case (`S_Region_Step + T_Region_Active`).
98.7% reduction across one day; further refined 2026-05-24 and 2026-05-26.
Final shape: 1 independent admit (S_Region_Step `r=r1` sub-case) + 12
cascading preservation goals that close on Lemma B `Qed.`.

=== Phase 1 — Lemma B: linearity-context invariance for siblings

Expand All @@ -226,13 +235,18 @@ via `G' = G_out`.
**Approach**: induction on `step` with `type_determinacy` per case.
Same pattern as `step_R_eq_or_touches_region`.

**Effort**: ~~3–4 hours focused session~~ → **8–15 focused hours**
(revised 2026-05-24). Empirical baseline from `coqc 8.18.0`: the
`cfg`-remember + atomic-axiom tactic closes 4 of 35 step rules
(`S_StringNew`, `S_StringConcat`, `S_Drop`, `S_Borrow_Step`); the
remaining 31 split across 3 clusters needing distinct recipes. Full
per-case map in `formal/PRESERVATION-HANDOFF.md` §"Lemma B per-case
status".
**Effort**: ~~3–4 hours focused session~~ → ~~8–15 focused hours
(revised 2026-05-24)~~ → **8–12 focused hours via Path 1**
(re-revised 2026-05-26). The 2026-05-24 baseline assumed 31 cases
to close independently; the 2026-05-24-night session closed Clusters
A + C entirely + most of B, leaving 1 admit. PRESERVATION-HANDOFF's
"Option 2 (structural recursion, ~150 LOC, orthogonal)" was found
BLOCKED on 2026-05-26 by a sibling-typing counterexample (`ELet
(ERegion r v_inner) e2` with `e2` referencing `r` — `T_Let` has no
sibling-freedom premise). The actual route is **Path 1: simultaneous
mutual induction over `step_preserves_type` + `step_output_context_eq`
+ `preservation`**. See
`docs/reports/audit/audit-2026-05-26-lemma-b-option-2-obstacle.md`.

**Risk**:

Expand Down
Loading
Loading