{-# OPTIONS --safe --cubical-compatible --guardedness --exact-split --double-check #-}
module ALMA.Cosmos.ContCategoryLemmas where
open import Agda.Builtin.Equality using (_≡_; refl)
open import Data.Container.Core using (Container; shape; position; _⇒_)
open import Relation.Binary.PropositionalEquality.Core using (cong; sym; trans)
open import Categories.Category.Core using (Category)
open import Categories.Functor.Core using (Functor)
open import ALMA.Cosmos.ContCategory using
(_≈sr_; ≈sr-sym; ≈sr-trans; ∘M-assoc; ∘M-resp-≈ˡ; ∘M-resp-≈ʳ; ContCat)
shape-eq-from-≈sr : ∀ {s p} {C D : Container s p} {f g : C ⇒ D}
→ f ≈sr g → ∀ x → shape f x ≡ shape g x
shape-eq-from-≈sr eq x = let open _≈sr_ eq in shape-eq x
shape-eq-sym : ∀ {s p} {C D : Container s p} {f g : C ⇒ D}
→ (eq : f ≈sr g) (x : Container.Shape C)
→ shape-eq-from-≈sr (≈sr-sym eq) x ≡ sym (shape-eq-from-≈sr eq x)
shape-eq-sym _ _ = refl
shape-eq-trans : ∀ {s p} {C D : Container s p} {f g h : C ⇒ D}
→ (eq1 : f ≈sr g) (eq2 : g ≈sr h) (x : Container.Shape C)
→ shape-eq-from-≈sr (≈sr-trans eq1 eq2) x
≡ trans (shape-eq-from-≈sr eq1 x) (shape-eq-from-≈sr eq2 x)
shape-eq-trans _ _ _ = refl
shape-eq-assoc : ∀ {s p} {A B C D : Container s p}
→ {f : A ⇒ B} {g : B ⇒ C} {h : C ⇒ D}
→ (x : Container.Shape A)
→ shape-eq-from-≈sr (∘M-assoc {A = A} {B} {C} {D} {f} {g} {h}) x ≡ refl
shape-eq-assoc _ = refl
shape-eq-resp-ˡ : ∀ {s p} {A B C : Container s p}
→ {g₁ g₂ : B ⇒ C} {f : A ⇒ B}
→ (eq : g₁ ≈sr g₂) (x : Container.Shape A)
→ shape-eq-from-≈sr (∘M-resp-≈ˡ {f = f} eq) x
≡ shape-eq-from-≈sr eq (_⇒_.shape f x)
shape-eq-resp-ˡ {f = f} eq x = refl
shape-eq-resp-ʳ : ∀ {s p} {A B C : Container s p}
→ {g : B ⇒ C} {f₁ f₂ : A ⇒ B}
→ (eq : f₁ ≈sr f₂) (x : Container.Shape A)
→ shape-eq-from-≈sr (∘M-resp-≈ʳ {g = g} eq) x
≡ cong (shape g) (shape-eq-from-≈sr eq x)
shape-eq-resp-ʳ _ _ = refl
ShapeOf : ∀ {o ℓ e s p} {C : Category o ℓ e}
→ Functor C (ContCat s p) → Category.Obj C → Set s
ShapeOf F A = Container.Shape (Functor.₀ F A)
PosOf : ∀ {o ℓ e s p} {C : Category o ℓ e}
→ (F : Functor C (ContCat s p)) {A : Category.Obj C}
→ ShapeOf F A → Set p
PosOf F {A} s = Container.Position (Functor.₀ F A) s
actSOf : ∀ {o ℓ e s p} {C : Category o ℓ e}
→ (F : Functor C (ContCat s p)) {A B : Category.Obj C}
→ Category._⇒_ C A B → ShapeOf F A → ShapeOf F B
actSOf F f = shape (Functor.₁ F f)
actPOf : ∀ {o ℓ e s p} {C : Category o ℓ e}
→ (F : Functor C (ContCat s p)) {A B : Category.Obj C}
→ (f : Category._⇒_ C A B) (s : ShapeOf F A)
→ PosOf F (actSOf F f s) → PosOf F s
actPOf F f s = position (Functor.₁ F f) {s = s}
transport : ∀ {o h e s p} {D : Category o h e}
(FD : Functor D (ContCat s p))
{a b : Category.Obj D}
→ a ≡ b → ShapeOf FD a → ShapeOf FD b
transport FD refl x = x
transport-refl : ∀ {o h e s p} {D : Category o h e}
(FD : Functor D (ContCat s p))
{a : Category.Obj D} (x : ShapeOf FD a)
→ transport FD refl x ≡ x
transport-refl FD x = refl
transport-sym : ∀ {o h e s p} {D : Category o h e}
(FD : Functor D (ContCat s p))
{a b : Category.Obj D}
(e : a ≡ b) (x : ShapeOf FD a)
→ transport FD (sym e) (transport FD e x) ≡ x
transport-sym FD refl x = refl
transport-trans : ∀ {o h e s p} {D : Category o h e}
(FD : Functor D (ContCat s p))
{a b c : Category.Obj D}
(e₁ : a ≡ b) (e₂ : b ≡ c) (x : ShapeOf FD a)
→ transport FD (trans e₁ e₂) x
≡ transport FD e₂ (transport FD e₁ x)
transport-trans FD refl _ _ = refl
transport-cong : ∀ {o h e o′ h′ e′ s p}
{D : Category o h e} {E : Category o′ h′ e′}
(FD : Functor D (ContCat s p))
(FE : Functor E (ContCat s p))
{H : Functor D E}
{a b : Category.Obj D}
{f : ∀ {x} → ShapeOf FD x → ShapeOf FE (Functor.F₀ H x)}
(e : a ≡ b) (x : ShapeOf FD a)
→ transport FE (cong (Functor.F₀ H) e) (f x)
≡ f (transport FD e x)
transport-cong FD FE refl _ = refl