Skip to content

Commit 3b5b92d

Browse files
docs(cleanup): residual pre-discovery framing in secondary docs (#186)
Follow-up to #184 + #185. Aligns 5 secondary entry surfaces (EXPLAINME, TOPOLOGY, docs/vision, ephapax-linear/README, .machine_readable/META.a2ml) with the post-counterexample doctrine. ROADMAP.adoc + .gitignore + .gitattributes + wiki deferred (not blocking proof work). See commit body for per-file detail. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 47bd7c1 commit 3b5b92d

5 files changed

Lines changed: 142 additions & 52 deletions

File tree

.machine_readable/6a2/META.a2ml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,14 @@ status = "accepted"
2222
date = "2026-04-11"
2323
context = "Formal verification of the type system is required for high-assurance use."
2424
decision = "Dual formalization in Coq (operational semantics) and Idris2 (type structure)."
25-
consequences = "Fully closed proofs (67 Qed) ensuring the correctness of the linear logic engine."
25+
consequences = "Mechanised Coq + Idris2 chain. NOTE: as of 2026-05-26 the legacy preservation theorem in formal/Semantics.v was shown to be provably false by formal/Counterexample.v (5 Qed). The single-layer mechanisation has been superseded by the four-layer redesign captured in adr-005 below — see formal/PRESERVATION-DESIGN.md and STATUS.adoc."
26+
27+
[project-meta.architecture-decisions.adr-005]
28+
status = "accepted"
29+
date = "2026-05-27"
30+
context = "On 2026-05-26 formal/Counterexample.v (5 Qed lemmas) demonstrated that preservation in the legacy single-layer judgment is provably false: region exit can invalidate sibling assumptions without the typing judgment tracking that dependency explicitly. The legacy judgment conflates four distinct concerns (structural discipline, region capabilities, dyadic interaction, echo residue)."
31+
decision = "Four-layer principled redesign with each layer's preservation theorem derived against its own explicit invariants. L1 = region capabilities (TypingL1.v + Semantics_L1.v, modality-indexed); L2 = structural modality Linear/Affine (Modality.v + m in has_type_l1); L3 = echo/residue (Echo.v, fiber-shaped, one type former, L2-mode dispatched at typing-rule boundary); L4 = dyadic interaction (designed only). Echo Types are orthogonal to structural discipline by construction — one Echo type former, Linear/Affine is a thin-poset of observation disciplines layered on top, not two separate echo types."
32+
consequences = "Preservation is re-derived per layer. Legacy formal/Semantics.v + formal/Typing.v are archaeology and must not be extended. Per-sublanguage proof debt tracked in PROOF-NEEDS.md. Past/present/future map in STATUS.adoc. Owner directive 2026-05-27 in CLAUDE.md is durable. Pre-2026-05-26 closure-plan PRs (#92, #102, #104, #106, #114, #116, #117, #121, #146) are archaeology, not instructions."
2633

2734
# ── Development Practices ──────────────────────────────────────────────────
2835
[project-meta.development-practices]

EXPLAINME.adoc

Lines changed: 55 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -151,64 +151,69 @@ Test `test_region_string_allocation` verifies in-region allocation.
151151

152152
=== Coq (`formal/`)
153153

154-
The Coq operational semantics is a small-step substitution-based
155-
calculus over the Tofte-Talpin region-linear type system.
156-
157-
[cols="3,1,2"]
154+
[IMPORTANT]
155+
.Post-counterexample 2026-05-26 — read this before any older proof claim
156+
====
157+
The legacy preservation theorem in `formal/Semantics.v` is **provably
158+
false**. `formal/Counterexample.v` (5 Qed lemmas) demonstrates a
159+
configuration that types under the legacy judgment, steps via the
160+
operational semantics, and lands at an untypable post-state. The
161+
`Admitted.` on `Theorem preservation` is correct — no proof closes it.
162+
163+
The post-discovery work is the **four-layer principled redesign**
164+
documented in `formal/PRESERVATION-DESIGN.md`, where preservation is
165+
*re-derived per layer* from explicit invariants. Any earlier-in-this-
166+
README counts of "910 → 22 → 12 open goals" are archaeology, not
167+
instructions. See `STATUS.adoc` for the past/present/future map.
168+
====
169+
170+
The Coq formalisation is now layered. Each layer has its own
171+
judgment, its own invariants, and its own per-layer preservation
172+
theorem.
173+
174+
[cols="3,1,3"]
158175
|===
159-
| Theorem | Status | Where
176+
| Component | Status | Where
177+
178+
| Counterexample regression (5 Qed)
179+
| ✅ Pinned
180+
| `formal/Counterexample.v` — `bad_input_untypable_l1` Qed under both modes
181+
182+
| L1 judgment (`has_type_l1`)
183+
| ✅ 100% (2 Qed, 0 admits)
184+
| `formal/TypingL1.v` — modality-indexed, R-threaded
160185

161-
| `no_leaks`
162-
| Qed
163-
| `formal/Semantics.v`
186+
| L1 semantics
187+
| 🟡 15 Qed, 9 admits (L2-integration debt)
188+
| `formal/Semantics_L1.v` — 9 admits are bullet-structure rewrites for new Affine-only constructors, *not* legacy patching
164189

165-
| `subst_preserves_typing`
166-
| ✅ Qed
167-
| `formal/Semantics.v` (line 2808)
190+
| L2 modality (`Modality.v`)
191+
| ✅ Core landed (1 Qed, 0 axioms)
192+
| `formal/Modality.v` + `m : Modality` in `has_type_l1`. PRs #176 + #177. `linear_to_affine` Qed with zero axioms.
168193

169-
| `typing_ctx_transfer`
170-
| ✅ Qed
171-
| `formal/Semantics.v`
194+
| L3 echo / residue calculus
195+
| ✅ 12 Qed, 0 admits (calculus); ⏳ integration pending
196+
| `formal/Echo.v` — one type former (fiber `Echo f y := Σ x. f x ≡ y`) + degrade map + no-section-collapse-to-residue proof. Not yet wired into `has_type_l1` or step rules.
172197

173-
| `region_env_perm_typing`, `region_add_typing`, `region_shrink_preserves_typing`
174-
| ✅ Qed
175-
| `formal/Semantics.v` (lines 2960, 3042, 3107)
198+
| L4 dyadic interaction
199+
| 🔲 Not started
200+
| Design in `formal/PRESERVATION-DESIGN.md §7`.
176201

177-
| **`preservation`**
178-
| 🟡 Admitted
179-
| `formal/Semantics.v` (Theorem at line 3207). **12 open goals** as of 2026-05-21 (was 910). See ROADMAP §"Preservation closure plan" + `formal/PRESERVATION-HANDOFF.md`.
202+
| Legacy `Theorem preservation` (`formal/Semantics.v`)
203+
| 🛑 Provably false (Admitted)
204+
| Pinned by `Counterexample.v`. **Do not attempt closure.** Archaeology.
180205
|===
181206

182-
The `preservation` reduction story is recent and load-bearing:
183-
184-
* **910 → 29 goals** via the standard preservation pattern
185-
(`remember (mu, R, e) as cfg eqn:Hcfg` + `inversion Hcfg; subst`
186-
inside each case). Lands as PR #102 (2026-05-20). 97% reduction.
187-
* **29 → 22 goals** via `revert mu R e mu' R' e' Hcfg Hcfg'` before
188-
`induction Hstep`, so each case's IH carries clean universal
189-
quantification over the inner step's config rather than the
190-
inconsistent outer-cfg equation. Lands as PR #106.
191-
* **22 → 12 goals** via per-case manual proofs using the new
192-
`step_R_eq_or_touches_region` region-invariance lemma (PR #114
193-
for the lemma, PR #116 for the 10 case closures: β-reduction,
194-
value-step, and atomic cases like `S_Let_Val`, `S_App_Fun`,
195-
`S_If_True/False`, `S_Fst`, `S_Snd`, `S_Case_Inl/Inr`, `S_Copy`).
196-
* **Phase 1 scaffold landed** (PR #121): `step_output_context_eq`
197-
(Lemma B) stated with induction-on-step skeleton. Per-case
198-
discharges are the next session's substantive work.
199-
* The remaining 12 are 11 congruence cases blocked on Lemma B
200-
(linearity-context drift between IH's output context and
201-
sibling's pre-context) + 1 `S_Region_Step + T_Region_Active`
202-
case blocked on the documented region-env weakening lemma for
203-
non-values.
204-
205-
The canonical closure path is **`ROADMAP.adoc` §"Preservation
206-
closure plan"** — 5 phases, ~3 sessions of focused work.
207-
208-
An earlier in-file comment (corrected by PR #92, 2026-05-20) claimed
209-
preservation was Qed-closed on 2026-04-27. That claim was
210-
unsubstantiated — `coqc` 8.18.0 rejected the proof script. The
211-
chain above is the honest closure work in progress.
207+
What's done = `Modality.linear_to_affine` (Linear ⇒ Affine weakening,
208+
zero axioms), the L1 judgment, L3 fiber + degrade calculus, and the
209+
counterexample regression witness. What's todo = close the 9
210+
Semantics_L1 admits (L2-integration debt), wire L3 into the typing
211+
judgment + step rules, then state per-layer preservation. What's
212+
banned = closing the legacy theorem, adding new `Axiom` declarations
213+
to discharge L1/L2 gaps, conflating `ephapax-affine` (this repo's
214+
sublanguage) with `AffineScript` (a separate language at
215+
`hyperpolymath/affinescript`). Full per-sublanguage breakdown in
216+
`PROOF-NEEDS.md`.
212217

213218
=== Idris2 (`idris2/src/Ephapax/` + `src/formal/`)
214219

TOPOLOGY.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,27 @@
11
<!-- SPDX-License-Identifier: PMPL-1.0-or-later -->
22
<!-- TOPOLOGY.md — Project architecture map and completion dashboard -->
3-
<!-- Last updated: 2026-03-22 -->
3+
<!-- Last updated: 2026-05-27 (post-counterexample doctrine landing) -->
4+
5+
> ## Post-counterexample doctrine — read before editing this file
6+
>
7+
> This TOPOLOGY map predates the 2026-05-26 counterexample landing in
8+
> parts of its system architecture diagram. The canonical *current*
9+
> architecture lives in:
10+
>
11+
> - [`STATUS.adoc`](STATUS.adoc) — past/present/future map
12+
> - [`formal/PRESERVATION-DESIGN.md`](formal/PRESERVATION-DESIGN.md) — four-layer architecture
13+
> - [`PROOF-NEEDS.md`](PROOF-NEEDS.md) — per-sublanguage proof debt
14+
> - [`CLAUDE.md`](CLAUDE.md) — agent guidance + owner directive 2026-05-27
15+
>
16+
> ### Layer mapping (formal/ contents post-2026-05-27)
17+
>
18+
> | Layer | Concern | File(s) | Status |
19+
> |---|---|---|---|
20+
> | **L1** | Region capabilities + capability environment threading | `formal/TypingL1.v` + `formal/Semantics_L1.v` | judgment 100%, semantics 15 Qed / 9 admits (L2-integration debt) |
21+
> | **L2** | Structural modality (Linear vs Affine) | `formal/Modality.v` + `m : Modality` in `has_type_l1` | core landed, `linear_to_affine` Qed with zero axioms |
22+
> | **L3** | Echo / residue (irreversibility evidence) | `formal/Echo.v` + upstream `hyperpolymath/echo-types` | calculus done (12 Qed), wiring into typing pending |
23+
> | **L4** | Dyadic interaction semantics | (none yet) | design in `PRESERVATION-DESIGN.md §7` |
24+
> | 🛑 | Legacy `formal/Semantics.v` + `formal/Typing.v` | archaeology | preservation provably false — see `formal/Counterexample.v` |
425
526
# ephapax (selur) — Project Topology
627

docs/vision/EPHAPAX-VISION.adoc

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,42 @@ Jonathan D.A. Jewell <j.d.a.jewell@open.ac.uk>
55
:toclevels: 3
66
:icons: font
77

8+
[IMPORTANT]
9+
.Post-counterexample reorientation 2026-05-27
10+
====
11+
This vision document is **the design rationale**. The architecture
12+
described here was reframed on 2026-05-26 when a verified Coq
13+
counterexample showed the original single-layer typing judgment was
14+
*provably false*. The current architecture is a *four orthogonal
15+
layers* design (region capabilities / structural modality / echo
16+
residue / dyadic mode) where preservation is re-derived per layer
17+
from explicit invariants.
18+
19+
The *intent* below — dyadic discipline, region-based memory, no
20+
tracing GC, WASM target — survives the redesign intact. The
21+
*mechanisation* is layered.
22+
23+
For implementation status (per-layer counts, what's done, what's
24+
todo, what's banned), read in this order:
25+
26+
. link:../../STATUS.adoc[`STATUS.adoc`] — past/present/future map.
27+
. link:../../formal/PRESERVATION-DESIGN.md[`formal/PRESERVATION-DESIGN.md`] — the four-layer architecture doctrine.
28+
. link:../../PROOF-NEEDS.md[`PROOF-NEEDS.md`] — per-sublanguage proof debt.
29+
====
30+
31+
[NOTE]
32+
.Disambiguation (ephapax ≠ AffineScript)
33+
====
34+
This is **`hyperpolymath/ephapax`** — a research language with
35+
mechanised Coq + Idris2 proofs. It is **not**
36+
`hyperpolymath/affinescript`, which is a separate JS/TS/ReScript
37+
successor with no mechanised proofs. The lexical overlap of "affine"
38+
in both names is a coincidence of substructural-logic terminology.
39+
Internal naming trap: `ephapax-affine` (the sublanguage *inside*
40+
this repo) is also **not** AffineScript. Canonical disambiguation:
41+
https://github.com/hyperpolymath/nextgen-languages/blob/main/docs/disambiguation/ephapax-vs-affinescript.md.
42+
====
43+
844
== What Ephapax Is
945

1046
Ephapax is a *programming language*. Not a proof assistant, not a type checker

ephapax-linear/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
# ephapax-linear
22

3+
> ## 🛑 First-read disambiguation
4+
>
5+
> This crate is part of **`hyperpolymath/ephapax`** — a research language for
6+
> compile-time WebAssembly memory safety, formally verified in Coq + Idris2.
7+
>
8+
> **`ephapax-linear` is *not* `hyperpolymath/affinescript`.** AffineScript is
9+
> a separate, unrelated language (JS/TS/ReScript successor, OCaml + ReScript
10+
> runtime). The two share only the compile target (`hyperpolymath/typed-wasm`).
11+
>
12+
> **Internal naming trap (important):** This crate implements *both*
13+
> sublanguages of Ephapax — `ephapax-linear` (strict core) AND `ephapax-affine`
14+
> (versatile prototyping companion). The name of the crate is `ephapax-linear`
15+
> for historical reasons, but **the affine grammar in this crate is NOT
16+
> `AffineScript`.** The lexical overlap of the word `affine` is a coincidence
17+
> of substructural-logic family terminology, not a project relationship. Do
18+
> not apply tactics, lessons, or framings from `hyperpolymath/affinescript`
19+
> here, and vice versa.
20+
>
21+
> Canonical disambiguation:
22+
> [`hyperpolymath/nextgen-languages/docs/disambiguation/ephapax-vs-affinescript.md`](https://github.com/hyperpolymath/nextgen-languages/blob/main/docs/disambiguation/ephapax-vs-affinescript.md).
23+
324
Standalone linear/affine discipline checker for the Ephapax language.
425

526
## Dual Grammars

0 commit comments

Comments
 (0)