@@ -5,7 +5,10 @@ module Echo where
55open import Level using (Level; _⊔_)
66open import Function.Base using (_∘_; id)
77open import Data.Product.Base using (Σ; _,_; _×_; proj₁; proj₂)
8- open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; trans; cong)
8+ open import Relation.Binary.PropositionalEquality
9+ using (_≡_; refl; sym; trans; cong; module ≡-Reasoning )
10+ open import Relation.Binary.PropositionalEquality.Properties
11+ using (trans-assoc; trans-reflʳ; trans-symˡ; sym-cong; trans-cong; cong-∘)
912
1013-- Echo_f(y) := Σ (x : A) , (f x ≡ y)
1114Echo : ∀ {a b} {A : Set a} {B : Set b} (f : A → B) → B → Set (a ⊔ b)
@@ -34,12 +37,6 @@ map-over-id :
3437 map-over (id , (λ x → refl)) e ≡ e
3538map-over-id (x , p) = refl
3639
37- trans-assoc :
38- ∀ {a} {A : Set a} {x y z w : A}
39- (p : x ≡ y) (q : y ≡ z) (r : z ≡ w) →
40- trans (trans p q) r ≡ trans p (trans q r)
41- trans-assoc refl q r = refl
42-
4340-- Composition law (pointwise on each fiber element).
4441map-over-comp :
4542 ∀ {a a' a'' b}
@@ -53,7 +50,7 @@ map-over-comp :
5350 ≡ map-over {f = f'} {f' = f''} (u2 , c2)
5451 (map-over {f = f} {f' = f'} (u1 , c1) e)
5552map-over-comp u1 c1 u2 c2 (x , p)
56- rewrite trans-assoc (c2 (u1 x)) ( c1 x) p = refl
53+ rewrite trans-assoc (c2 (u1 x)) {q = c1 x} {r = p} = refl
5754
5855-- Action along a commuting square: f' ∘ u = v ∘ f.
5956map-square :
@@ -121,16 +118,109 @@ cancel-iso-from f g s s-right {y = y} (x , q) =
121118 x , trans (cong g q) (s-right y)
122119
123120-- The two maps above witness that `Echo (g ∘ f) y` and `Echo f (s y)`
124- -- are *related* via g's section/retraction structure. To conclude
125- -- they are *isomorphic* one must also prove two round-trips equal to
126- -- the identity. Under `--without-K`, that requires a triangle-identity
127- -- coherence between `s-left` and `s-right` (roughly:
128- -- `cong g (s-left b) ≡ s-right (g b)`), which is not a consequence of
129- -- the two pointwise laws alone — a bare "both-way inverse" is weaker
130- -- than an equivalence / bijection in HoTT terms. The round-trip
131- -- formalisation is deferred until we commit to either (a) an
132- -- equivalence record that packages the triangle identity as a field,
133- -- or (b) stdlib's `Function.Bundles.Inverse`.
121+ -- are *related* via g's section/retraction structure. The round-trips
122+ -- below upgrade that to a full isomorphism. Under `--safe --without-K`,
123+ -- the two pointwise laws `s-left` and `s-right` are not enough on their
124+ -- own — a bare "both-way inverse" is weaker than an equivalence /
125+ -- bijection in HoTT terms. We therefore parameterise each round-trip
126+ -- by the relevant triangle-identity coherence:
127+ --
128+ -- * `cancel-iso-from-to` (round-trip on `Echo (g ∘ f) y`) requires
129+ -- `triangle₁ : ∀ b → cong g (s-left b) ≡ s-right (g b)`.
130+ -- * `cancel-iso-to-from` (round-trip on `Echo f (s y)`) requires
131+ -- `triangle₂ : ∀ y → cong s (s-right y) ≡ s-left (s y)`.
132+ --
133+ -- One triangle implies the other in HoTT (any quasi-inverse can be
134+ -- adjusted to a half-adjoint equivalence), but the adjustment needs
135+ -- non-trivial path algebra; we take both as explicit hypotheses to
136+ -- keep the proofs first-order. Callers who already have an
137+ -- `Inverse` record from `Function.Bundles` can derive the triangles
138+ -- from that record's coherence fields.
139+
140+ -- Naturality of a homotopy `h : f ∼ id` along `p : x ≡ y`. The
141+ -- single load-bearing path-algebra lemma for the cancel-iso round-trips.
142+ hom-natural-id :
143+ ∀ {a} {A : Set a} (f : A → A) (h : ∀ z → f z ≡ z)
144+ {x y : A} (p : x ≡ y) →
145+ trans (cong f p) (h y) ≡ trans (h x) p
146+ hom-natural-id f h refl = sym (trans-reflʳ (h _))
147+
148+ -- Round-trip on `Echo (g ∘ f) y`: `cancel-iso-from ∘ cancel-iso-to ≡ id`.
149+ cancel-iso-from-to :
150+ ∀ {a b c} {A : Set a} {B : Set b} {C : Set c}
151+ (f : A → B) (g : B → C) (s : C → B)
152+ (s-left : ∀ b → s (g b) ≡ b)
153+ (s-right : ∀ y → g (s y) ≡ y)
154+ (triangle₁ : ∀ b → cong g (s-left b) ≡ s-right (g b))
155+ {y : C} (e : Echo (g ∘ f) y) →
156+ cancel-iso-from f g s s-right (cancel-iso-to f g s s-left e) ≡ e
157+ cancel-iso-from-to f g s s-left s-right triangle₁ {y = y} (x , p) =
158+ cong (λ q → x , q) lemma
159+ where
160+ open ≡-Reasoning
161+ lemma : trans (cong g (trans (sym (s-left (f x))) (cong s p))) (s-right y) ≡ p
162+ lemma = begin
163+ trans (cong g (trans (sym (s-left (f x))) (cong s p))) (s-right y)
164+ ≡⟨ cong (λ z → trans z (s-right y))
165+ (sym (trans-cong (sym (s-left (f x))))) ⟩
166+ trans (trans (cong g (sym (s-left (f x)))) (cong g (cong s p))) (s-right y)
167+ ≡⟨ cong (λ z → trans (trans z (cong g (cong s p))) (s-right y))
168+ (sym (sym-cong (s-left (f x)))) ⟩
169+ trans (trans (sym (cong g (s-left (f x)))) (cong g (cong s p))) (s-right y)
170+ ≡⟨ cong (λ z → trans (trans (sym z) (cong g (cong s p))) (s-right y))
171+ (triangle₁ (f x)) ⟩
172+ trans (trans (sym (s-right (g (f x)))) (cong g (cong s p))) (s-right y)
173+ ≡⟨ cong (λ z → trans (trans (sym (s-right (g (f x)))) z) (s-right y))
174+ (sym (cong-∘ p)) ⟩
175+ trans (trans (sym (s-right (g (f x)))) (cong (g ∘ s) p)) (s-right y)
176+ ≡⟨ trans-assoc (sym (s-right (g (f x)))) ⟩
177+ trans (sym (s-right (g (f x)))) (trans (cong (g ∘ s) p) (s-right y))
178+ ≡⟨ cong (trans (sym (s-right (g (f x)))))
179+ (hom-natural-id (g ∘ s) s-right p) ⟩
180+ trans (sym (s-right (g (f x)))) (trans (s-right (g (f x))) p)
181+ ≡⟨ sym (trans-assoc (sym (s-right (g (f x))))) ⟩
182+ trans (trans (sym (s-right (g (f x)))) (s-right (g (f x)))) p
183+ ≡⟨ cong (λ z → trans z p) (trans-symˡ (s-right (g (f x)))) ⟩
184+ trans refl p
185+ ≡⟨⟩
186+ p
187+ ∎
188+
189+ -- Round-trip on `Echo f (s y)`: `cancel-iso-to ∘ cancel-iso-from ≡ id`.
190+ cancel-iso-to-from :
191+ ∀ {a b c} {A : Set a} {B : Set b} {C : Set c}
192+ (f : A → B) (g : B → C) (s : C → B)
193+ (s-left : ∀ b → s (g b) ≡ b)
194+ (s-right : ∀ y → g (s y) ≡ y)
195+ (triangle₂ : ∀ y → cong s (s-right y) ≡ s-left (s y))
196+ {y : C} (e : Echo f (s y)) →
197+ cancel-iso-to f g s s-left (cancel-iso-from f g s s-right e) ≡ e
198+ cancel-iso-to-from f g s s-left s-right triangle₂ {y = y} (x , q) =
199+ cong (λ r → x , r) lemma
200+ where
201+ open ≡-Reasoning
202+ lemma : trans (sym (s-left (f x))) (cong s (trans (cong g q) (s-right y))) ≡ q
203+ lemma = begin
204+ trans (sym (s-left (f x))) (cong s (trans (cong g q) (s-right y)))
205+ ≡⟨ cong (trans (sym (s-left (f x))))
206+ (sym (trans-cong (cong g q))) ⟩
207+ trans (sym (s-left (f x))) (trans (cong s (cong g q)) (cong s (s-right y)))
208+ ≡⟨ cong (λ z → trans (sym (s-left (f x))) (trans (cong s (cong g q)) z))
209+ (triangle₂ y) ⟩
210+ trans (sym (s-left (f x))) (trans (cong s (cong g q)) (s-left (s y)))
211+ ≡⟨ cong (λ z → trans (sym (s-left (f x))) (trans z (s-left (s y))))
212+ (sym (cong-∘ q)) ⟩
213+ trans (sym (s-left (f x))) (trans (cong (s ∘ g) q) (s-left (s y)))
214+ ≡⟨ cong (trans (sym (s-left (f x))))
215+ (hom-natural-id (s ∘ g) s-left q) ⟩
216+ trans (sym (s-left (f x))) (trans (s-left (f x)) q)
217+ ≡⟨ sym (trans-assoc (sym (s-left (f x)))) ⟩
218+ trans (trans (sym (s-left (f x))) (s-left (f x))) q
219+ ≡⟨ cong (λ z → trans z q) (trans-symˡ (s-left (f x))) ⟩
220+ trans refl q
221+ ≡⟨⟩
222+ q
223+ ∎
134224
135225-- Pentagon coherence for three-fold composition. Given
136226-- f : A → B, g : B → C, h : C → D, the echo of (h ∘ g ∘ f)
@@ -169,3 +259,52 @@ Echo-comp-iso-pent-echo :
169259 (proj₁ (proj₂ (Echo-comp-iso-to (g ∘ f) h e)))))
170260 ≡ proj₁ (proj₂ (Echo-comp-iso-to f (h ∘ g) e))
171261Echo-comp-iso-pent-echo f g h (x , p) = refl
262+
263+ -- Pentagon Σ-associativity isomorphism. The two natural factorings of
264+ -- `Echo (h ∘ g ∘ f) y` from the projection-pentagon lemmas above differ
265+ -- only by Σ-associativity / unification of the intermediate base point:
266+ --
267+ -- outer : Σ C (λ c → Σ B (λ b → Echo f b × (g b ≡ c)) × (h c ≡ y))
268+ -- — the "outer-first then inner" factoring, two nested splits
269+ -- inner : Σ B (λ b → Echo f b × (h (g b) ≡ y))
270+ -- — the "inner-first" factoring, a single split with (h ∘ g)
271+ --
272+ -- The forward map collapses `c` against the intermediate witness
273+ -- `g b ≡ c`, transporting `h c ≡ y` to `h (g b) ≡ y`. The backward map
274+ -- sets `c := g b` with `refl`, leaving the outer h-equation untouched.
275+ -- Both round-trips reduce definitionally once the relevant `g b ≡ c`
276+ -- has been pinned to `refl` by pattern matching, so this is a strict
277+ -- iso (no transport coherence required) and lives comfortably inside
278+ -- `--safe --without-K`.
279+
280+ Echo-comp-pent-Σ-assoc-to :
281+ ∀ {a b c d} {A : Set a} {B : Set b} {C : Set c} {D : Set d}
282+ (f : A → B) (g : B → C) (h : C → D) {y : D} →
283+ Σ C (λ c → Σ B (λ b → Echo f b × (g b ≡ c)) × (h c ≡ y)) →
284+ Σ B (λ b → Echo f b × (h (g b) ≡ y))
285+ Echo-comp-pent-Σ-assoc-to f g h (c , (b , ef , q) , p) =
286+ b , ef , trans (cong h q) p
287+
288+ Echo-comp-pent-Σ-assoc-from :
289+ ∀ {a b c d} {A : Set a} {B : Set b} {C : Set c} {D : Set d}
290+ (f : A → B) (g : B → C) (h : C → D) {y : D} →
291+ Σ B (λ b → Echo f b × (h (g b) ≡ y)) →
292+ Σ C (λ c → Σ B (λ b → Echo f b × (g b ≡ c)) × (h c ≡ y))
293+ Echo-comp-pent-Σ-assoc-from f g h (b , ef , p) =
294+ g b , (b , ef , refl) , p
295+
296+ Echo-comp-pent-Σ-assoc-from-to :
297+ ∀ {a b c d} {A : Set a} {B : Set b} {C : Set c} {D : Set d}
298+ (f : A → B) (g : B → C) (h : C → D) {y : D}
299+ (r : Σ C (λ c → Σ B (λ b → Echo f b × (g b ≡ c)) × (h c ≡ y))) →
300+ Echo-comp-pent-Σ-assoc-from f g h
301+ (Echo-comp-pent-Σ-assoc-to f g h r) ≡ r
302+ Echo-comp-pent-Σ-assoc-from-to f g h (c , (b , ef , refl) , p) = refl
303+
304+ Echo-comp-pent-Σ-assoc-to-from :
305+ ∀ {a b c d} {A : Set a} {B : Set b} {C : Set c} {D : Set d}
306+ (f : A → B) (g : B → C) (h : C → D) {y : D}
307+ (r : Σ B (λ b → Echo f b × (h (g b) ≡ y))) →
308+ Echo-comp-pent-Σ-assoc-to f g h
309+ (Echo-comp-pent-Σ-assoc-from f g h r) ≡ r
310+ Echo-comp-pent-Σ-assoc-to-from f g h (b , ef , p) = refl
0 commit comments