|
| 1 | +-- SPDX-License-Identifier: PMPL-1.0-or-later |
| 2 | +-- SPDX-FileCopyrightText: 2026 Jonathan D.A. Jewell |
| 3 | + |
| 4 | +{-# OPTIONS --safe --without-K #-} |
| 5 | + |
| 6 | +module Echo where |
| 7 | + |
| 8 | +open import Level using (Level; _⊔_) |
| 9 | +open import Function.Base using (_∘_; id) |
| 10 | +open import Data.Product.Base using (Σ; _,_; proj₁; proj₂) |
| 11 | +open import Relation.Binary.PropositionalEquality using (_≡_; refl; trans; cong) |
| 12 | + |
| 13 | +-- Echo_f(y) := Σ (x : A) , (f x ≡ y) |
| 14 | +Echo : ∀ {a b} {A : Set a} {B : Set b} (f : A → B) → B → Set (a ⊔ b) |
| 15 | +Echo {A = A} f y = Σ A (λ x → f x ≡ y) |
| 16 | + |
| 17 | +-- Introduction into own fiber. |
| 18 | +echo-intro : ∀ {a b} {A : Set a} {B : Set b} (f : A → B) (x : A) → Echo f (f x) |
| 19 | +echo-intro f x = x , refl |
| 20 | + |
| 21 | +-- Morphisms in the slice over fixed codomain B. |
| 22 | +MapOver : |
| 23 | + ∀ {a a' b} {A : Set a} {A' : Set a'} {B : Set b} → |
| 24 | + (f : A → B) → (f' : A' → B) → Set (a ⊔ a' ⊔ b) |
| 25 | +MapOver {A = A} {A' = A'} f f' = Σ (A → A') (λ u → ∀ x → f' (u x) ≡ f x) |
| 26 | + |
| 27 | +-- Action on fibers for a map over fixed base B. |
| 28 | +map-over : |
| 29 | + ∀ {a a' b} {A : Set a} {A' : Set a'} {B : Set b} |
| 30 | + {f : A → B} {f' : A' → B} → |
| 31 | + MapOver f f' → ∀ {y : B} → Echo f y → Echo f' y |
| 32 | +map-over (u , commute) (x , p) = u x , trans (commute x) p |
| 33 | + |
| 34 | +-- Identity law (pointwise on each fiber element). |
| 35 | +map-over-id : |
| 36 | + ∀ {a b} {A : Set a} {B : Set b} {f : A → B} {y : B} (e : Echo f y) → |
| 37 | + map-over (id , (λ x → refl)) e ≡ e |
| 38 | +map-over-id (x , p) = refl |
| 39 | + |
| 40 | +trans-assoc : |
| 41 | + ∀ {a} {A : Set a} {x y z w : A} |
| 42 | + (p : x ≡ y) (q : y ≡ z) (r : z ≡ w) → |
| 43 | + trans (trans p q) r ≡ trans p (trans q r) |
| 44 | +trans-assoc refl q r = refl |
| 45 | + |
| 46 | +-- Composition law (pointwise on each fiber element). |
| 47 | +map-over-comp : |
| 48 | + ∀ {a a' a'' b} |
| 49 | + {A : Set a} {A' : Set a'} {A'' : Set a''} {B : Set b} |
| 50 | + {f : A → B} {f' : A' → B} {f'' : A'' → B} |
| 51 | + (u1 : A → A') (c1 : ∀ x → f' (u1 x) ≡ f x) |
| 52 | + (u2 : A' → A'') (c2 : ∀ x → f'' (u2 x) ≡ f' x) |
| 53 | + {y : B} (e : Echo f y) → |
| 54 | + map-over {f = f} {f' = f''} |
| 55 | + (u2 ∘ u1 , (λ x → trans (c2 (u1 x)) (c1 x))) e |
| 56 | + ≡ map-over {f = f'} {f' = f''} (u2 , c2) |
| 57 | + (map-over {f = f} {f' = f'} (u1 , c1) e) |
| 58 | +map-over-comp u1 c1 u2 c2 (x , p) |
| 59 | + rewrite trans-assoc (c2 (u1 x)) (c1 x) p = refl |
| 60 | + |
| 61 | +-- Action along a commuting square: f' ∘ u = v ∘ f. |
| 62 | +map-square : |
| 63 | + ∀ {a a' b b'} |
| 64 | + {A : Set a} {A' : Set a'} {B : Set b} {B' : Set b'} |
| 65 | + (f : A → B) (f' : A' → B') (u : A → A') (v : B → B') |
| 66 | + (square : ∀ x → f' (u x) ≡ v (f x)) {y : B} → |
| 67 | + Echo f y → Echo f' (v y) |
| 68 | +map-square f f' u v square (x , p) = u x , trans (square x) (cong v p) |
0 commit comments