Skip to content

Commit 9864b0a

Browse files
Add comprehensive Echo Types documentation suite
2 parents 1a84f7a + b1f10a6 commit 9864b0a

2 files changed

Lines changed: 45 additions & 2 deletions

File tree

proofs/agda/Echo.agda

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module Echo where
44

55
open import Level using (Level; _⊔_)
66
open import Function.Base using (_∘_; id)
7-
open import Data.Product.Base using (Σ; _,_)
7+
open import Data.Product.Base using (Σ; _,_; _×_)
88
open import Relation.Binary.PropositionalEquality using (_≡_; refl; trans; cong)
99

1010
-- Echo_f(y) := Σ (x : A) , (f x ≡ y)
@@ -63,3 +63,35 @@ map-square :
6363
(square : x f' (u x) ≡ v (f x)) {y : B}
6464
Echo f y Echo f' (v y)
6565
map-square f f' u v square (x , p) = u x , trans (square x) (cong v p)
66+
67+
-- Composition isomorphism: the echo of g ∘ f at y is canonically
68+
-- equivalent to a Σ over an intermediate b : B of (Echo f b × g b ≡ y).
69+
-- This is the accumulation law from docs/echo-types/composition.md §1:
70+
-- composition does not weaken the intensional core, it accumulates
71+
-- witness structure. Both round-trips are definitional once the
72+
-- refl pattern has pinned the intermediate b to f x.
73+
74+
Echo-comp-iso-to :
75+
{a b c} {A : Set a} {B : Set b} {C : Set c}
76+
(f : A B) (g : B C) {y : C}
77+
Echo (g ∘ f) y Σ B (λ b Echo f b × (g b ≡ y))
78+
Echo-comp-iso-to f g (x , p) = f x , (x , refl) , p
79+
80+
Echo-comp-iso-from :
81+
{a b c} {A : Set a} {B : Set b} {C : Set c}
82+
(f : A B) (g : B C) {y : C}
83+
Σ B (λ b Echo f b × (g b ≡ y)) Echo (g ∘ f) y
84+
Echo-comp-iso-from f g (b , (x , refl) , p) = x , p
85+
86+
Echo-comp-iso-from-to :
87+
{a b c} {A : Set a} {B : Set b} {C : Set c}
88+
(f : A B) (g : B C) {y : C} (e : Echo (g ∘ f) y)
89+
Echo-comp-iso-from f g (Echo-comp-iso-to f g e) ≡ e
90+
Echo-comp-iso-from-to f g (x , p) = refl
91+
92+
Echo-comp-iso-to-from :
93+
{a b c} {A : Set a} {B : Set b} {C : Set c}
94+
(f : A B) (g : B C) {y : C}
95+
(r : Σ B (λ b Echo f b × (g b ≡ y)))
96+
Echo-comp-iso-to f g (Echo-comp-iso-from f g r) ≡ r
97+
Echo-comp-iso-to-from f g (b , (x , refl) , p) = refl

proofs/agda/Smoke.agda

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,18 @@
66

77
module Smoke where
88

9-
open import Echo using (Echo; echo-intro; map-over; map-over-id; map-over-comp; map-square)
9+
open import Echo using
10+
( Echo
11+
; echo-intro
12+
; map-over
13+
; map-over-id
14+
; map-over-comp
15+
; map-square
16+
; Echo-comp-iso-to
17+
; Echo-comp-iso-from
18+
; Echo-comp-iso-from-to
19+
; Echo-comp-iso-to-from
20+
)
1021
open import EchoCharacteristic using (collapse; echo-true; echo-false; echo-true≢echo-false)
1122
open import EchoResidue using (EchoR; collapse-to-residue; strict-weakening-collapse; no-section-collapse-to-residue)
1223
open import EchoExamples using (square9; visible; quot; collapse-residue-identifies)

0 commit comments

Comments
 (0)