Skip to content

Commit e6a15a6

Browse files
feat: EchoReversibilityBridge — discharge 007 L10 reversibility obligations (#249)
## What A new module `proofs/agda/EchoReversibilityBridge.agda` — the constructive discharge of the **007 language's** Layer-10 reversibility (echo-residue) *phase-2* proof obligations against echo-types as the library of record. 007 models reversibility with an echo residue (`reversible as <name>` arms a cell holding an `Echo f y`; `reverse <name>` consumes it to recover the input), specified in Idris2 (`EchoResidue.idr` / `EchoResidueLinear.idr`). Those obligations were *informal* requirements on 007's checker. This module re-states the interface they describe and proves echo-types' own `Echo` / `EchoTotalCompletion` / `EchoLinear` satisfy it — turning the informal claim into a checked theorem in the source of truth. ## The bridge | Headline | Discharges | Proof | |---|---|---| | `ReversibleCompletion f Residue` | the interface 007 needs: `hold` (arm) / `takeForReverse` (replay) / `reverse-recovers` (once-only correctness), residue carrier as a parameter | record | | `echo-reversible : ReversibleCompletion f (Echo f)` | `Echo f` *is* such a carrier | `hold = echo-intro`, `takeForReverse = proj₁` (= `reverseLinear`'s witness), recovery `refl` | | `reversibility-via-totality : Σ B (Echo f) ↔ A` | the slogan "irreversible f + residue = reversible representation" | symmetric partner of `EchoTotalCompletion.A↔ΣEcho` via `mk↔ₛ′` | | `capability-can-be-dropped : LEcho linear → LEcho affine` | phase-2 "affine capability" (the undo may be dropped) | `EchoLinear.weaken` | | `no-recovery-once-dropped` | phase-2 "linear consumption / Spent doesn't reverse" (no section of `weaken`) | `EchoLinear.no-section-weaken` | ## Discipline - `--safe --without-K`, **zero postulates**, no funext. - Wired into `All.agda` (next to `EchoCNOBridge`, the other cross-repo 007 bridge). - Five headlines pinned in `Smoke.agda` under their own `using` block with a header comment. - **Verified on the latest `main`:** `EchoReversibilityBridge.agda`, `Smoke.agda`, and `All.agda` all `agda --safe --without-K` exit 0 (captured locally; absolute-zero fetched at the CI-pinned ref `3ff5cee`). ## Notes - The Agda here is the source of truth; 007's Rust checker and Idris2 spec mirror this model. The `takeForReverse` field is the *total* `Just`-branch of 007's `takeForReverse : … → Maybe a` (the `Maybe` is runtime `Holding`/`Spent` bookkeeping, not part of the type-level correspondence). - A 007-side doc pointer to this module is a trivial follow-up, best landed after 007#55 merges. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_018CaSgNjNURC7ocsyjYh9We --- _Generated by [Claude Code](https://claude.ai/code/session_018CaSgNjNURC7ocsyjYh9We)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 62e9d61 commit e6a15a6

5 files changed

Lines changed: 145 additions & 1 deletion

File tree

docs/echo-types/MAP.adoc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,27 @@ discharged by `coqc` on the ephapax side; no Lane 4 CI dependency.
466466
`formal/PRESERVATION-DESIGN.md` + `docs/echo-types/paper.adoc`
467467
§"Threats to validity").
468468

469+
=== 007 L10 reversibility — echo-residue bridge `[REAL]`
470+
Cross-repo navigability marker for the `hyperpolymath/007` language
471+
project, whose Layer-10 reversibility model (`reversible as`/`reverse`,
472+
specified in Idris2 `proofs/idris2/EchoResidue.idr` +
473+
`EchoResidueLinear.idr`) is discharged against echo-types as the library
474+
of record. The module re-states the interface 007's model needs and shows
475+
echo-types' own structures satisfy it, under `--safe --without-K`, zero
476+
postulates.
477+
478+
* Proofs: `proofs/agda/EchoReversibilityBridge.agda` —
479+
`ReversibleCompletion` (the arm / take-for-reverse / replay-recovers
480+
interface), `echo-reversible` (`Echo f` satisfies it; `takeForReverse`
481+
↔ `reverseLinear`'s witness), `reversibility-via-totality :
482+
Σ B (Echo f) ↔ A` (symmetric partner of
483+
`EchoTotalCompletion.A↔ΣEcho`), and `capability-can-be-dropped` /
484+
`no-recovery-once-dropped` (007 phase-2 "affine capability, linear
485+
consumption" via `EchoLinear.weaken` / `no-section-weaken`).
486+
* Scope: the type-level totality + recovery + linear→affine no-section
487+
content. 007's linear `(1 e : Echo f y)` quantity is NOT re-proved in
488+
Agda (the full quantity-semantics port is the documented next slice).
489+
469490
=== Tropical / Dyadic `[REAL*]`
470491
Bridge domains enumerated in `docs/EchoBridges.md` (JanusKey / CNO /
471492
Tropical / Dyadic). Dyadic is mechanised; Tropical is named/early.

docs/echo-types/echo-kernel-note.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ kernel** — the boundary is real and lives outside this core.
8282
`EchoEpistemicResidue`, `EchoExamples`, `EchoGraded`,
8383
`EchoLinear`, `EchoPullback`, `EchoRelModel`, `EchoScope`,
8484
`EchoStabilityTests`, `EchoThermodynamics`, `EchoCNOBridge`,
85-
`EchoEphapaxBridge`,
85+
`EchoEphapaxBridge`, `EchoReversibilityBridge`,
8686
`EchoThermodynamicsFinite`, `EchoIntegration`, `EchoAccess`,
8787
`EchoCost`, `EchoCostInstance`, `EchoSearch`, `EchoSearchInstance`,
8888
`EchoExampleAbsInt`, `EchoExampleParser`, `EchoExampleProvenance`,

proofs/agda/All.agda

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ open import AntiEchoTropical
3636
open import AntiEchoTropicalGeneric
3737
open import EchoIntegration
3838
open import EchoCNOBridge
39+
open import EchoReversibilityBridge
3940

4041
open import EchoApprox
4142
open import EchoApproxInstance
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
-- SPDX-License-Identifier: MPL-2.0
2+
-- SPDX-FileCopyrightText: 2025-2026 Jonathan D.A. Jewell <j.d.a.jewell@open.ac.uk>
3+
--
4+
-- EchoReversibilityBridge: the constructive discharge of the 007 language's
5+
-- Layer-10 reversibility (echo-residue) "phase-2" proof obligations against
6+
-- this library of record.
7+
--
8+
-- 007 (https://github.com/hyperpolymath/007) models reversibility with an
9+
-- echo residue: `reversible as <name>` arms a residue cell holding an
10+
-- `Echo f y`, and `reverse <name>` consumes it to recover the input. Its
11+
-- Idris2 spec (`proofs/idris2/EchoResidue.idr`,
12+
-- `proofs/idris2/EchoResidueLinear.idr`) pins three obligations:
13+
--
14+
-- 1. encode / decode round-trips — an irreversible `f` together with its
15+
-- residue is a total, reversible representation;
16+
-- 2. `reverseLinear : (1 e : Echo f y) → (x ** f x ≡ y)` — replaying a held
17+
-- residue recovers the input (the `Holding`/`takeForReverse = Just`
18+
-- branch of `ResidueCell`);
19+
-- 3. the linear discipline "affine capability, linear consumption" — the
20+
-- undo capability may be dropped (weakened) but, once dropped, the
21+
-- linear residue cannot be recovered (`Spent` does not reverse).
22+
--
23+
-- This module re-states the *interface* those obligations describe and shows
24+
-- echo-types' own `Echo` / `EchoTotalCompletion` / `EchoLinear` satisfy it,
25+
-- under `--safe --without-K` with zero postulates. The Agda here is the
26+
-- source of truth; 007's Rust checker and Idris2 spec mirror this model.
27+
28+
{-# OPTIONS --safe --without-K #-}
29+
30+
module EchoReversibilityBridge where
31+
32+
open import Level using (Level; _⊔_)
33+
open import Data.Product.Base using (Σ; _,_; proj₁)
34+
open import Function.Bundles using (_↔_; mk↔ₛ′)
35+
open import Relation.Binary.PropositionalEquality using (_≡_; refl)
36+
open import Relation.Nullary using (¬_)
37+
38+
open import Echo using (Echo; echo-intro)
39+
open import EchoTotalCompletion using (encode; decode; decode-encode; encode-decode)
40+
open import EchoLinear using (linear; affine; LEcho; weaken; no-section-weaken)
41+
42+
private variable
43+
a b : Level
44+
A : Set a
45+
B : Set b
46+
47+
------------------------------------------------------------------------
48+
-- Obligations 1 + 2: the reversible-completion interface, met by Echo.
49+
------------------------------------------------------------------------
50+
51+
-- The minimal data 007's reversibility model needs from a residue carrier:
52+
-- arm a residue from an input (`hold`), take-it-for-reverse to recover an
53+
-- input (`takeForReverse`), and the once-only correctness that replaying a
54+
-- freshly-armed residue returns the original input (`reverse-recovers`).
55+
--
56+
-- `takeForReverse` here is the *total* `Just`-branch of 007's
57+
-- `takeForReverse : … → Maybe a`, i.e. `reverseLinear`'s witness extraction
58+
-- on a `Holding` cell; the `Maybe` wrapper is the runtime `Holding`/`Spent`
59+
-- bookkeeping, not part of the type-level correspondence.
60+
--
61+
-- The residue carrier `Residue` is a parameter: an instance witnesses that a
62+
-- *particular* carrier (here `Echo f`) supports armed reversal.
63+
record ReversibleCompletion {a b} {A : Set a} {B : Set b}
64+
(f : A B) (Residue : B Set (a ⊔ b)) : Set (a ⊔ b) where
65+
field
66+
hold : (x : A) Residue (f x)
67+
takeForReverse : {y : B} Residue y A
68+
reverse-recovers : (x : A) takeForReverse (hold x) ≡ x
69+
70+
-- echo-types' `Echo f` is such a carrier. `hold` is `echo-intro` (= 007's
71+
-- `encode` / the `Holding` cell); `takeForReverse` is the witness projection
72+
-- (= `reverseLinear`'s `fst`); recovery is `refl`, because
73+
-- `proj₁ (echo-intro f x) = proj₁ (x , refl) = x` definitionally.
74+
echo-reversible : (f : A B) ReversibleCompletion f (Echo f)
75+
echo-reversible f = record
76+
{ hold = echo-intro f
77+
; takeForReverse = proj₁
78+
; reverse-recovers = λ _ refl
79+
}
80+
81+
-- 007's narrative slogan — "an irreversible computation together with its
82+
-- echo residue is a reversible representation" — is exactly echo-types'
83+
-- totality iso read in the residue→input direction: the total echo space
84+
-- `Σ B (Echo f)` recovers the domain `A`. (The A→Σ direction is
85+
-- `EchoTotalCompletion.A↔ΣEcho`; this is its symmetric partner.)
86+
reversibility-via-totality : (f : A B) Σ B (Echo f) ↔ A
87+
reversibility-via-totality f =
88+
mk↔ₛ′ (decode f) (encode f) (decode-encode f) (encode-decode f)
89+
90+
------------------------------------------------------------------------
91+
-- Obligation 3: the phase-2 linear discipline.
92+
------------------------------------------------------------------------
93+
94+
-- "Affine capability": a live (linear) undo residue may always be weakened
95+
-- to an affine one — the capability dropped. Never an error in 007.
96+
capability-can-be-dropped : LEcho linear LEcho affine
97+
capability-can-be-dropped = weaken
98+
99+
-- "Linear consumption / Spent-does-not-reverse": there is NO section of
100+
-- `weaken` — once the residue is degraded (the undo dropped, the cell
101+
-- `Spent`) the linear residue cannot be recovered. This is echo-types'
102+
-- `no-section-weaken`, the library-of-record discharge of the irreversibility
103+
-- of dropping the capability.
104+
no-recovery-once-dropped :
105+
¬ (Σ (LEcho affine LEcho linear)
106+
(λ raise e raise (weaken e) ≡ e))
107+
no-recovery-once-dropped = no-section-weaken

proofs/agda/Smoke.agda

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,21 @@ open import EchoTotalCompletion using
9292
; encode-is-section-of-proj₁
9393
)
9494

95+
-- EchoReversibilityBridge — constructive discharge of the 007 language's
96+
-- Layer-10 reversibility (echo-residue) phase-2 obligations against this
97+
-- library of record. `ReversibleCompletion` is the interface 007's model
98+
-- needs (arm / take-for-reverse / replay-recovers); `echo-reversible` shows
99+
-- `Echo f` satisfies it; `reversibility-via-totality` is the slogan iso
100+
-- `Σ B (Echo f) ↔ A`; `capability-can-be-dropped` / `no-recovery-once-dropped`
101+
-- pin the phase-2 "affine capability, linear consumption" discipline.
102+
open import EchoReversibilityBridge using
103+
( ReversibleCompletion
104+
; echo-reversible
105+
; reversibility-via-totality
106+
; capability-can-be-dropped
107+
; no-recovery-once-dropped
108+
)
109+
95110
-- EchoNoSectionGeneric — raises the example-level
96111
-- `no-section-collapse-to-residue` to a uniform structural theorem.
97112
-- Generic headline `no-section-of-collapsing-map`: any collapsing

0 commit comments

Comments
 (0)