Skip to content

Commit de02dd9

Browse files
Resolve the monad/comonad/adjunction variance of loss in --safe Agda (#243)
## What & why The sharpened understanding of an echo-type — *a tropically-graded modality of structured information loss over the min-plus semiring (ℕ∪{∞}, min, +), recoverable **exact on a homotopy fibre rather than complement-storing*** — left a precise **live question**: > the combining direction of loss is monadic (accumulation is `μ : D_r (D_s A) → D_{r+s} A`), so whether the right word is "graded comonad", "graded monad", or "graded adjunction (with the section as unit/counit)" is unsettled and is being **resolved in `--safe` Agda rather than asserted**. `R-2026-05-18` already retracted the unqualified "graded comonad" claim (a *reindexing modality*, **no nested `D_r D_s`**); this PR builds the nested maps the question is actually about and lets the type-checker decide. ## The verdict (each clause a pinned theorem in `EchoVariance.agda`) | Clause | Theorem | Reuses | |---|---|---| | **(1) Accumulation is monadic** — `μ` total + canonical (definable from layered data alone) | `accumulate` | `Echo-comp-iso-from` | | **(2) Exact on the fibre** — fixed-factoring round-trips are `refl` | `accumulate-split-id`, `split-accumulate-id` | `Echo-comp-iso-{to,from}` | | **(2′) Grade-0 section/retraction adjunction** | `recoverable-fibre` | `A↔ΣEcho` | | **(3) Comonad direction fails for genuine loss** — no recovery from a *bare* residue | `no-bare-recovery`, `fibre-retains-lost-bit` | `no-section-of-collapsing-map` | | **(4) "Graded comonad" = lossless complement-storing writer** — F1's `δ` is `coe` along a *type equality*, inverted by `μ-writer` | `μ-writer`, `writer-μ-section`, `writer-δ-section` | `EchoGradedComonadF1.{δ,D-+,coe}` | **One-line resolution.** Echo (fibre-based loss) is a **graded monad** of accumulation (the `+` axis) with a fibre-exact section/retraction **adjunction**; it is **not** a graded comonad. The `min` axis (order / `degrade`) carries the reindexing modality; the `+` axis (accumulation) carries the monad. The graded-comonad reading is available only on the **complement-storing writer**, which is lossless — the resource neighbour echo-types is *not*. This sharpens `R-2026-05-18` from "graded comonad withdrawn" to "decided against". ## Informs the redesign `docs/echo-types/variance-resolution.adoc` records the verdict and four consequences: keep the modality(`min`)/measure(`+`) split (it *is* the variance answer); name the accumulation monad on the measure axis; read `EchoGradedComonad`/F1/F3 as the complement-storing neighbour on the record; state recoverability as the grade-0 adjunction, never an all-grade comonadic `extract`/`duplicate`. ## Files - **`proofs/agda/EchoVariance.agda`** (new) — `--safe --without-K`, **zero postulates**, reuses only existing kernel theorems. - `All.agda` import; `Smoke.agda` pin block (10 headlines). - `docs/echo-types/variance-resolution.adoc` (new) — the verdict + redesign consequences + honest-scope `NotProved-*`. - `echo-kernel-note.adoc` + `MAP.adoc` — `EchoVariance` classified `[REAL]`. - `paper.adoc` Reframing note — follow-up `F-2026-06-19`. ## Verification - `agda proofs/agda/All.agda` → exit 0 - `agda proofs/agda/Smoke.agda` → exit 0 - `scripts/kernel-guard.sh` → **PASS** (Check A funext-free cone; Check B classification in sync) - zero postulates; `--safe --without-K` throughout 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01Rw1RpYXU5Q7rzy2bVofVeB --- _Generated by [Claude Code](https://claude.ai/code/session_01Rw1RpYXU5Q7rzy2bVofVeB)_ Co-authored-by: Claude <noreply@anthropic.com>
1 parent ce75866 commit de02dd9

7 files changed

Lines changed: 555 additions & 1 deletion

File tree

docs/echo-types/MAP.adoc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,24 @@ honest-bound matched-negative block.
275275
is the fold's homomorphism law, NOT full SQL GROUP-BY operational
276276
semantics; `avg` is deliberately absent (not a monoid — express as
277277
`sum / count`). `proofs/agda/EchoAggregation.agda`. `[REAL]`
278+
* *Variance verdict (monad / comonad / adjunction)* — resolves, in
279+
`--safe` Agda rather than asserting it, the precise variance of the
280+
loss-graded modality. Accumulation is the graded-MONAD multiplication
281+
`accumulate : D_r (D_s A) → D_{r+s} A` (total + canonical, definable
282+
from the layered data alone; `= Echo-comp-iso-from`); recoverability is
283+
exact on the grade-0 fibre (`recoverable-fibre = A↔ΣEcho`, the
284+
section/retraction adjunction); the graded-COMONAD direction fails for
285+
genuine loss (`no-bare-recovery`, the canonical collapse has no section
286+
via `no-section-of-collapsing-map`); and the "graded comonad" reading is
287+
the LOSSLESS complement-storing writer of `EchoGradedComonadF1`, whose
288+
`δ` is `coe` along a type equality and is therefore inverted by
289+
`μ-writer`. Sharpens R-2026-05-18: echo-types is "exact on a homotopy
290+
fibre rather than complement-storing". Honest-bound: the verdict is
291+
about the SHAPE of the canonical structure maps and the LOCUS of
292+
recoverability, not a universal categorical impossibility theorem
293+
(matched `NotProved-*` block). See
294+
`docs/echo-types/variance-resolution.adoc`.
295+
`proofs/agda/EchoVariance.agda`. `[REAL]`
278296

279297
*Curated suite — single-file entry point.* The narrative
280298
deliverable that pulls the Tier-1 / Tier-2 / Tier-3 named theorems

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ kernel** — the boundary is real and lives outside this core.
125125
*Application/extension modules* (also added via the same sweep):
126126
`EchoEntropy`, `EchoLLEncoding`, `EchoProvenance`, `EchoSecurity`,
127127
`EchoProbabilisticSupport`, `EchoDifferential`, `EchoDeniability`,
128-
`EchoAggregation`
128+
`EchoAggregation`, `EchoVariance`
129129
are derived domain applications mapped under their own headings in
130130
MAP.adoc. `EchoDeniability` formalises residue deniability: the
131131
perfect (constant / no-section) case and the partial (injective /
@@ -140,6 +140,17 @@ kernel** — the boundary is real and lives outside this core.
140140
`Example-PairSum` instance the oikos/betlang alib note cites
141141
(`pairSum` IS the `sumMonoid` fold). Imports `Echo` +
142142
`EchoNoSectionGeneric`.
143+
`EchoVariance` resolves, in `--safe` Agda rather than asserting it,
144+
the monad / comonad / adjunction status of loss accumulation
145+
(`docs/echo-types/variance-resolution.adoc`): accumulation is the
146+
graded-MONAD multiplication `accumulate : D_r (D_s A) → D_{r+s} A`
147+
(total + canonical, `= Echo-comp-iso-from`); recoverability is exact on
148+
the grade-0 fibre (`recoverable-fibre = A↔ΣEcho`, the section/retraction
149+
adjunction); the graded-COMONAD direction fails for genuine loss
150+
(`no-bare-recovery`, via `no-section-of-collapsing-map`); and the
151+
"graded comonad" reading is the LOSSLESS complement-storing writer
152+
(`μ-writer` inverts F1's `δ`). Imports `Echo`, `EchoCharacteristic`,
153+
`EchoNoSectionGeneric`, `EchoTotalCompletion`, `EchoGradedComonadF1`.
143154

144155
| *Earn-back gate modules* +
145156
(derived / scoped; not kernel)

docs/echo-types/paper.adoc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,6 +1270,28 @@ via a genuine non-graph `StepND` model (§6 NOTE,
12701270
`EchoStepNDModelF2.agda`). The graded-comonad, modality-level
12711271
model-independence, and conservativity rows remain fully retracted.
12721272

1273+
*Variance resolved (follow-up F-2026-06-19, 2026-06-19).* The
1274+
graded-comonad row is now *positively resolved*, not merely retracted.
1275+
The sharpened understanding of an echo-type — a tropically-graded
1276+
modality of structured loss over the min-plus semiring, recoverable
1277+
*exact on a homotopy fibre rather than complement-storing* — left a
1278+
precise live question: the combining direction of loss is monadic
1279+
(accumulation is `μ : D_r (D_s A) → D_{r+s} A`), so is the right word
1280+
graded comonad, graded monad, or graded adjunction? `EchoVariance.agda`
1281+
settles it in `--safe` Agda (`docs/echo-types/variance-resolution.adoc`):
1282+
(i) accumulation is the graded-MONAD multiplication, total and canonical
1283+
(`accumulate = Echo-comp-iso-from`); (ii) recoverability is exact on the
1284+
grade-0 fibre, the section/retraction *adjunction*
1285+
(`recoverable-fibre = A↔ΣEcho`); (iii) the graded-COMONAD direction fails
1286+
for genuine loss — bare-residue recovery is the no-section obstruction
1287+
(`no-bare-recovery`); and (iv) the "graded comonad" reading is the
1288+
LOSSLESS complement-storing writer (`EchoGradedComonadF1`'s `δ` is `coe`
1289+
along a type equality, inverted by `μ-writer`), i.e. the resource
1290+
neighbour, not the loss modality. Net: echo is a graded *monad* of
1291+
accumulation with a fibre-exact section/retraction *adjunction*; it is
1292+
*not* a graded comonad. This sharpens the retracted row from "withdrawn"
1293+
to "decided against", and does not resurrect any retracted prose.
1294+
12731295
== Post-establishment structural extensions (2026-05-27)
12741296

12751297
A substantial layer of structural mechanisation landed after the
Lines changed: 235 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,235 @@
1+
// SPDX-License-Identifier: CC-BY-SA-4.0
2+
// SPDX-FileCopyrightText: 2025-2026 Jonathan D.A. Jewell <j.d.a.jewell@open.ac.uk>
3+
= Echo Types — Variance Resolution (monad / comonad / adjunction)
4+
:date: 2026-06-19
5+
:toc: macro
6+
:toclevels: 3
7+
:sectnums:
8+
:sectnumlevels: 3
9+
10+
[.lead]
11+
This note resolves, *in `--safe` Agda rather than by assertion*, the
12+
precise variance of the loss-graded echo modality: is it a graded
13+
comonad, a graded monad, or a graded adjunction? The resolution is
14+
mechanised in `proofs/agda/EchoVariance.agda` and its headlines are
15+
pinned in `Smoke.agda`. It is written to *inform the redesign* of the
16+
repository's modality/measure architecture.
17+
18+
toc::[]
19+
20+
== The live question
21+
22+
The current, sharpened understanding of an echo-type:
23+
24+
[quote]
25+
____
26+
An echo-type is a tropically-graded modality of structured information
27+
loss — an instance of graded-(co)monad machinery over the min-plus
28+
semiring (ℕ ∪ {∞}, min, +), with a section/retraction pair whose
29+
round-trip is *exact on a homotopy fibre* rather than over-approximating
30+
or complement-storing — whose monad/comonad/adjunction status is being
31+
pinned down formally.
32+
____
33+
34+
The variance was genuinely unsettled, and for a concrete reason. The
35+
*combining* direction of loss is monadic: accumulation has the shape
36+
`μ : D_r (D_s A) → D_{r+s} A`. So the right word — "graded comonad",
37+
"graded monad", or "graded adjunction (with the section as
38+
unit/counit)" — was a live question to be *resolved in Agda, not
39+
asserted*.
40+
41+
Two pre-existing facts framed the question:
42+
43+
* *R-2026-05-18* (`docs/retractions.adoc`) already RETRACTED the
44+
unqualified "graded comonad" claim on `EchoGradedComonad`, reframing
45+
it as a loss-graded *reindexing* modality with **no nested
46+
`D_r D_s`**. So the structure the question is actually about — the
47+
nested comultiplication/multiplication — had not been built where the
48+
retraction left things.
49+
* *Gate F1* (`EchoGradedComonadF1`) DID build a genuine nested graded
50+
comonad with `δ : D (m+n) ⇒ D m (D n)`. But — see §4 — its model
51+
stores its residue, which turns out to be the crux.
52+
53+
== How the tropical semiring already splits across two axes
54+
55+
The repository architecture (the `Echo.Modality.*` / `Echo.Measure.*`
56+
foundation surface) already decomposes the min-plus semiring along
57+
exactly the two axes the variance question lives on:
58+
59+
[cols="1,3,3a",options="header"]
60+
|===
61+
| Tropical op | Role | Where it lives
62+
63+
| `min` (⊕, the order / lattice)
64+
| The thin echo *index*. `degrade` reindexes along it. This is the
65+
proof-relevant modality *core* — deliberately semiring-free
66+
(the *measure-independence invariant*).
67+
| `Echo.Index.ThinPoset`, `Echo.Modality.{Interface,Core}`
68+
69+
| `+` (⊗, accumulation)
70+
| The residue *measure*: a lossy, monotone *observation*
71+
(`measure x ≤ measure (degrade p x)`). The accumulation
72+
`μ : D_r D_s → D_{r+s}` the live question names lives on *this* axis.
73+
| `Echo.Measure.{Interface,Examples}` (incl. `tropical-cost-measure`)
74+
|===
75+
76+
So "is loss a comonad or a monad?" is really two questions on two axes:
77+
what is the variance of the `min`-graded reindexing (the modality core),
78+
and what is the variance of the `+`-graded accumulation (the measure /
79+
nesting)?
80+
81+
== The verdict
82+
83+
Each clause below is a *pinned theorem* in `EchoVariance.agda`, not a
84+
slogan. `--safe --without-K`, zero postulates; every artefact reuses an
85+
existing kernel theorem.
86+
87+
=== (1) Accumulation is monadic
88+
89+
`accumulate : Σ B (λ b → Echo f b × (g b ≡ y)) → Echo (g ∘ f) y`
90+
(`= Echo-comp-iso-from`) is the combining map: a nested loss (an
91+
`f`-echo sitting under a `g`-step) collapses to a single
92+
`(g ∘ f)`-echo. It is *total* and *canonical*: it is definable from the
93+
layered data alone — the factoring `(f, g)` is exactly its input, so no
94+
choice is made. This is the graded-MONAD multiplication shape
95+
`μ : D_r (D_s A) → D_{r+s} A`; the loss magnitudes add.
96+
97+
=== (2) Recoverability is exact on the fibre
98+
99+
For a *fixed factoring*, `accumulate` and `split-with-factoring`
100+
(`= Echo-comp-iso-to`) are mutually inverse — both round-trips are
101+
`refl` (`accumulate-split-id`, `split-accumulate-id`). The fibre stores
102+
the loss *precisely*: no over-approximation, no stored complement.
103+
104+
At grade 0 this is the totality isomorphism
105+
`recoverable-fibre : A ↔ Σ B (Echo f)` (`= A↔ΣEcho`). Its `encode`
106+
(unit) and `decode` (counit) ARE the section/retraction pair — the
107+
unit/counit of the *adjunction* reading. So the "graded adjunction"
108+
candidate is correct, and it is *exact on a homotopy fibre*, precisely as
109+
the sharpened understanding requires.
110+
111+
=== (3) The comonad direction fails for genuine loss
112+
113+
A graded *comonad* would supply a *natural* `δ` on the BARE residual
114+
functor: recover the intermediate/layered data from a residue *without
115+
being handed a factoring*. For genuine loss that is exactly the
116+
irreversibility obstruction. The canonical collapse
117+
`collapse : Bool → ⊤` has *no section*: `no-bare-recovery` (via
118+
`no-section-of-collapsing-map`) refutes any `raise : ⊤ → Bool` with
119+
`raise ∘ collapse ≡ id`.
120+
121+
The forgotten bit is retained on the *fibre*
122+
(`fibre-retains-lost-bit : echo-true ≢ echo-false`, two distinct echoes
123+
over the same residue `tt`) but is *not* a recoverable complement of the
124+
residue — which is exactly why `no-bare-recovery` holds while
125+
`accumulate-split-id` is `refl`.
126+
127+
=== (4) The "graded comonad" reading is the complement-storing neighbour
128+
129+
`EchoGradedComonadF1` is a genuine nested graded comonad — but its model
130+
`D r A = A × Boolʳ` (`R X = X × Bool`) *retains* its residue layers. Its
131+
comultiplication is `δ = coe (D-+ m n A)` along the *type equality*
132+
`D (m+n) A ≡ D m (D n A)`, hence INVERTIBLE. `EchoVariance` exhibits the
133+
inverse `μ-writer = coe (sym (D-+ m n A))` and proves both round-trips
134+
(`writer-μ-section`, `writer-δ-section`): the writer is *simultaneously*
135+
a graded comonad and a graded monad.
136+
137+
That bi-directionality is the signature of a COMPLEMENT-STORING
138+
(resource / coeffect) modality — the loss is not actually lost, it is
139+
filed in the `Bool` layer. This is precisely what the sharpened
140+
understanding says echo-types is *not*: "exact on a homotopy fibre rather
141+
than ... complement-storing". So the graded-comonad reading does not
142+
contradict the verdict; it silently *changes the modality* to the
143+
lossless resource neighbour.
144+
145+
=== One-line resolution
146+
147+
[.lead]
148+
Echo-types (fibre-based loss) is a *graded monad* of accumulation (the
149+
`+` axis) together with a section/retraction *adjunction* that is exact on
150+
the grade-0 fibre; it is *not* a graded comonad. The `min` axis (order /
151+
`degrade`) carries the reindexing modality; the `+` axis (accumulation)
152+
carries the monad. The graded-comonad reading is available only on the
153+
complement-storing writer, which is lossless and hence a different
154+
(resource-flavoured) modality.
155+
156+
This sits the echo modality exactly where the landscape places it: at the
157+
intersection of the grading axis (Katsumata; Fujii–Katsumata–Melliès;
158+
Orchard–Petricek coeffects) and the modal axis, with the modality's
159+
content being *information loss* rather than resource usage, distinguished
160+
from its neighbours by the tropical (worst-case, non-probabilistic) grade
161+
and by carrying recoverability as *fibre-level* rather than
162+
*complement-level* structure.
163+
164+
== Consequences for the redesign
165+
166+
. *Keep the modality/measure split; it IS the variance answer.* The
167+
`min` axis (`Echo.Modality.*`, thin-poset `degrade`) and the `+` axis
168+
(`Echo.Measure.*`, accumulation) should remain separate surfaces. The
169+
variance question dissolves once they are not conflated: reindexing
170+
(order) and accumulation (measure) have different variances.
171+
172+
. *Name the accumulation monad on the measure axis.* The `+`-graded
173+
accumulation `μ : D_r D_s → D_{r+s}` is the graded-monad multiplication.
174+
A future `Echo.Measure.Accumulation` (or similar) can package
175+
`accumulate` + the grade-0 unit as the graded monad of loss, with the
176+
tropical `+` (and `∞` as the absorbing "fully unrecoverable" grade) as
177+
the grade monoid. `EchoVariance.accumulate` is the kernel-level witness
178+
it would build on.
179+
180+
. *Read `EchoGradedComonad` / F1 / F3 as the complement-storing
181+
neighbour, on the record.* They are correct Agda and a useful
182+
contrast object (the resource sibling), but they are *not* the echo
183+
modality of genuine loss. Any downstream prose that calls echo "a
184+
graded comonad of loss" without the complement-storing caveat is
185+
re-introducing the R-2026-05-18 overclaim. `EchoVariance` is the pin
186+
that fails CI if that slide recurs.
187+
188+
. *The adjunction is the honest headline for recoverability.* "Exact on
189+
a homotopy fibre" = the grade-0 `A ↔ Σ B (Echo f)` section/retraction.
190+
Recoverability should be stated as this adjunction unit/counit, never as
191+
an all-grade comonadic `extract`/`duplicate` (which would falsely imply
192+
recovery off the fibre).
193+
194+
== Honest scope
195+
196+
The verdict is about the *shape* of the canonical structure maps and the
197+
*locus* of recoverability — not a universal categorical impossibility
198+
theorem. Matched-negatives are pinned in `EchoVariance` as `NotProved-*`
199+
⊤-aliases:
200+
201+
* *Not claimed:* that no graded comonad of any kind touches Echo — F1 is
202+
one, on the complement-storing writer. The claim is that *genuine*
203+
(fibre-based, non-complement-storing) loss is not a graded comonad.
204+
* *Not claimed:* a numeric realisation of the full min-plus grade semiring
205+
(with `∞`) carrying the entire graded-monad law triangle. The measure
206+
seam (`tropical-cost-measure`) supplies the tropical carrier; this work
207+
pins only the variance *shape*. Completing the law triangle over
208+
`ℕ ∪ {∞}` is the natural next rung (consequence 2 above).
209+
* *Not claimed:* that `split-with-factoring` is non-canonical. Given the
210+
factoring it is the unique inverse (clause 2). The obstruction (clause
211+
3) is strictly about recovery from a *bare* residue with no factoring
212+
supplied.
213+
214+
== Provenance
215+
216+
* Mechanisation: `proofs/agda/EchoVariance.agda` (`--safe --without-K`,
217+
zero postulates); pinned in `proofs/agda/Smoke.agda`; wired into
218+
`proofs/agda/All.agda`; classified in
219+
`docs/echo-types/echo-kernel-note.adoc` and `docs/echo-types/MAP.adoc`.
220+
* Reused kernel theorems: `Echo.Echo-comp-iso-{to,from,to-from,from-to}`,
221+
`EchoNoSectionGeneric.no-section-of-collapsing-map`,
222+
`EchoTotalCompletion.A↔ΣEcho`, and `EchoGradedComonadF1.{δ,D-+,coe}`.
223+
* Relationship to the ledger: this *resolves* the variance left open by
224+
R-2026-05-18; it does not resurrect any retracted prose.
225+
226+
== Revision history
227+
228+
[cols="1,3",options="header"]
229+
|===
230+
| Date | Change
231+
232+
| 2026-06-19
233+
| Initial resolution. `EchoVariance.agda` lands the five-clause verdict;
234+
this note records it and the redesign consequences.
235+
|===

proofs/agda/All.agda

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ open import EchoGradedComonadF1 -- Gate F1 PASSED (graded comonad on iterated-re
102102
open import EchoGradedComonadInterface -- Gate F3 abstract record
103103
open import EchoGradedComonadInstance1 -- Gate F3 instance 1 (F1 at (ℕ, +, 0))
104104
open import EchoGradedComonadInstance2 -- Gate F3 PASSED — instance 2 at (List Tag, ++, [])
105+
open import EchoVariance -- variance verdict: monad (accumulation) + fibre adjunction, NOT comonad
105106

106107
-- Foundation P1: external-fibre triangulation. Echo agrees with the
107108
-- standard library's OWN independently-authored notions

0 commit comments

Comments
 (0)