Skip to content

Commit facd2e7

Browse files
agda(Echo): equivalence-record packaging for cancel-iso (closes composition.md §4) (#25)
## Summary - Adds two equivalence-record packagers in \`Echo.agda\` using stdlib's \`Function.Bundles._↔_\` and \`mk↔ₛ′\`: - \`Echo-comp-iso\` — unconditional accumulation iso \`Echo (g ∘ f) y ↔ Σ B (λ b → Echo f b × g b ≡ y)\`, built from the existing \`Echo-comp-iso-{to,from,from-to,to-from}\` quartet. - \`cancel-iso\` — per-fiber cancellation equivalence \`Echo (g ∘ f) y ↔ Echo f (s y)\`, parameterised by \`s-left\`, \`s-right\`, and both triangle-identity coherences (\`triangle₁\`, \`triangle₂\`); built from the existing \`cancel-iso-{to,from,from-to,to-from}\` quartet. - Closes \`docs/echo-types/composition.md\` §4 ("Full cancel-iso with round-trips") cleanly. Each triangle is needed for the corresponding round-trip — one implies the other in HoTT but the adjustment is non-trivial path algebra, so both stay explicit. - Pinned in \`Smoke.agda\`. ## Why The four cancel-iso pieces had been load-bearing as separate lemmas, requiring downstream consumers to apply them in tandem to recover the equivalence shape. Packaging them into a single \`↔\` record gives one structured object (with strict-inverse laws available via \`mk↔ₛ′\`'s field projections) and matches stdlib's idiom for bi-invertible maps. ## Compile-verification \`\`\` agda -i proofs/agda proofs/agda/All.agda agda -i proofs/agda proofs/agda/Smoke.agda \`\`\` Both exit 0 under \`--safe --without-K\`. No postulates introduced. ## Test plan - [ ] \`agda -i proofs/agda proofs/agda/All.agda\` exits 0 - [ ] \`agda -i proofs/agda proofs/agda/Smoke.agda\` exits 0 - [ ] \`grep -n postulate proofs/agda/Echo.agda\` returns nothing - [ ] \`Echo-comp-iso\` and \`cancel-iso\` headlines pinned in \`Smoke.agda\` 🤖 Generated with [Claude Code](https://claude.com/claude-code)
2 parents 7b1c6fe + 5c94057 commit facd2e7

3 files changed

Lines changed: 70 additions & 4 deletions

File tree

docs/echo-types/composition.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,13 @@ Ranked by unblock-value. (1) and (2) landed; (3) onwards is open.
267267
3. ~~**Pentagon coherence.**~~ Landed: projection-level
268268
(`-pent-B`, `-pent-echo` as `refl`) plus the full Σ-shape iso
269269
(`Echo-comp-pent-Σ-assoc-{to, from, from-to, to-from}`).
270-
4. **Full cancel-iso with round-trips.** Needs an equivalence
271-
record that packages `s-left`, `s-right`, and the triangle
272-
identity as three fields, or direct use of stdlib's
273-
`Function.Bundles.Inverse`. Then the round-trip refls go through.
270+
4. ~~**Full cancel-iso with round-trips.**~~ Landed: `Echo.cancel-iso`
271+
packages the four pieces (`cancel-iso-{to, from, from-to, to-from}`)
272+
plus both triangle-identity coherences as a single
273+
`Function.Bundles._↔_` record. Companion `Echo.Echo-comp-iso`
274+
does the same for the unconditional accumulation iso (no
275+
triangles needed). Built via stdlib's `mk↔ₛ′`; both round-trips
276+
close on the existing pointwise lemmas.
274277
5. ~~**Approximate-echo skeleton.**~~ Landed in
275278
`EchoApprox.agda` with `EchoR ε f y`, `echo-approx-intro`,
276279
`echo-approx-relax`, and `echo-approx-compose` (additive under

proofs/agda/Echo.agda

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,3 +308,64 @@ Echo-comp-pent-Σ-assoc-to-from :
308308
Echo-comp-pent-Σ-assoc-to f g h
309309
(Echo-comp-pent-Σ-assoc-from f g h r) ≡ r
310310
Echo-comp-pent-Σ-assoc-to-from f g h (b , ef , p) = refl
311+
312+
----------------------------------------------------------------------
313+
-- Equivalence-record packaging
314+
--
315+
-- The `cancel-iso-{to,from,from-to,to-from}` and
316+
-- `Echo-comp-iso-{to,from,from-to,to-from}` quartets above each
317+
-- pair into a stdlib `Function.Bundles._↔_` (bijection /
318+
-- bi-invertible map). The `cancel-iso` packager takes the two
319+
-- triangle-identity coherences as hypotheses (one per round-trip),
320+
-- as the round-trip lemmas themselves require; the
321+
-- `Echo-comp-iso` packager is unconditional (the round-trips
322+
-- there are pure pattern-matching).
323+
--
324+
-- The `↔` record from `Function.Bundles` is the standard
325+
-- categorical-equivalence object in stdlib v2: `to`, `from`,
326+
-- congruences (trivial under `_≡_`), and the two strict-inverse
327+
-- laws. Building this here gives downstream consumers a single
328+
-- structured object instead of a quintuple of named lemmas, and
329+
-- means the cancel-iso closes `composition.md` §4 ("Full
330+
-- cancel-iso with round-trips") cleanly.
331+
332+
open import Function.Bundles using (_↔_; mk↔ₛ′)
333+
334+
-- Per-fiber Echo-comp iso, packaged as a ↔. The accumulation
335+
-- iso is unconditional, so no extra hypotheses are needed.
336+
337+
Echo-comp-iso :
338+
{a b c} {A : Set a} {B : Set b} {C : Set c}
339+
(f : A B) (g : B C) (y : C)
340+
Echo (g ∘ f) y ↔ Σ B (λ b Echo f b × (g b ≡ y))
341+
Echo-comp-iso f g y =
342+
mk↔ₛ′
343+
(λ e Echo-comp-iso-to f g {y = y} e)
344+
(λ r Echo-comp-iso-from f g {y = y} r)
345+
(λ r Echo-comp-iso-to-from f g r)
346+
(λ e Echo-comp-iso-from-to f g e)
347+
348+
-- Per-fiber cancel iso, packaged as a ↔. Requires both triangle
349+
-- identities; one triangle implies the other in HoTT but the
350+
-- adjustment is non-trivial path algebra, so both are taken as
351+
-- explicit hypotheses (matching `cancel-iso-from-to` and
352+
-- `cancel-iso-to-from`).
353+
--
354+
-- Closes `docs/echo-types/composition.md` §4 ("Full cancel-iso
355+
-- with round-trips") via the stdlib equivalence record.
356+
357+
cancel-iso :
358+
{a b c} {A : Set a} {B : Set b} {C : Set c}
359+
(f : A B) (g : B C) (s : C B)
360+
(s-left : b s (g b) ≡ b)
361+
(s-right : y g (s y) ≡ y)
362+
(triangle₁ : b cong g (s-left b) ≡ s-right (g b))
363+
(triangle₂ : y cong s (s-right y) ≡ s-left (s y))
364+
(y : C)
365+
Echo (g ∘ f) y ↔ Echo f (s y)
366+
cancel-iso f g s s-left s-right triangle₁ triangle₂ y =
367+
mk↔ₛ′
368+
(λ e cancel-iso-to f g s s-left {y = y} e)
369+
(λ e cancel-iso-from f g s s-right {y = y} e)
370+
(λ e cancel-iso-to-from f g s s-left s-right triangle₂ e)
371+
(λ e cancel-iso-from-to f g s s-left s-right triangle₁ e)

proofs/agda/Smoke.agda

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ open import Echo using
2828
; Echo-comp-pent-Σ-assoc-from
2929
; Echo-comp-pent-Σ-assoc-from-to
3030
; Echo-comp-pent-Σ-assoc-to-from
31+
; Echo-comp-iso
32+
; cancel-iso
3133
)
3234
open import EchoCharacteristic using (collapse; echo-true; echo-false; echo-true≢echo-false)
3335
open import EchoResidue using (EchoR; collapse-to-residue; strict-weakening-collapse; no-section-collapse-to-residue)

0 commit comments

Comments
 (0)