@@ -4,7 +4,7 @@ module Echo where
44
55open import Level using (Level; _⊔_)
66open import Function.Base using (_∘_; id)
7- open import Data.Product.Base using (Σ; _,_)
7+ open import Data.Product.Base using (Σ; _,_; _×_ )
88open 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)
6565map-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
0 commit comments