{-# OPTIONS --without-K --safe #-}
module Categories.Multi.Category.Indexed where
open import Level
open import Data.Fin.Base using (Fin)
open import Data.Product using (Σ; uncurry; curry; _×_; _,_; proj₁; proj₂)
open import Data.Product.Properties
open import Data.Unit.Polymorphic using (⊤; tt)
open import Data.Vec.Functional
open import Function.Base using (const) renaming (_∘_ to _●_; id to id→)
open import Function.Bundles using (_⟨$⟩_; _↔_; mk↔ₛ′; Inverse)
open import Function.Construct.Identity renaming (inverse to id↔)
open import Relation.Binary.Core using (Rel)
open import Relation.Binary.PropositionalEquality using (_≡_; refl; setoid)
pointed : {s t : Level} {S : Set s} (x : S) → ⊤ {t} → S
pointed x _ = x
⊤×K↔K : {t k : Level} {K : Set k} → (⊤ {t} × K) ↔ K
⊤×K↔K = mk↔ₛ′ proj₂ (tt ,_) (λ _ → refl) λ _ → refl
K×⊤↔K : {t k : Level} {K : Set k} → (K × ⊤ {t}) ↔ K
K×⊤↔K = mk↔ₛ′ proj₁ (_, tt) (λ _ → refl) λ _ → refl
⊤×⊤↔⊤ : {t : Level} → (⊤ {t} × ⊤) ↔ ⊤
⊤×⊤↔⊤ = mk↔ₛ′ proj₁ (λ x → x , x) (λ _ → refl) λ _ → refl
Σ-assoc : {a b c : Level} {I : Set a} {J : I → Set b} {K : Σ I J → Set c} →
Σ (Σ I J) K ↔ Σ I (λ i → Σ (J i) (curry K i))
Σ-assoc {I = I} {J} {K} = mk↔ₛ′ g f (λ _ → refl) λ _ → refl
where
f : Σ I (λ i → Σ (J i) (λ j → K (i , j))) → Σ (Σ I J) K
f (i , j , k) = (i , j) , k
g : Σ (Σ I J) K → Σ I (λ i → Σ (J i) (λ j → K (i , j)))
g ((i , j) , k) = i , j , k
record MultiCategory (o ℓ e ı : Level) : Set (suc (o ⊔ ℓ ⊔ e ⊔ ı)) where
infix 4 _≈[_]_
infixr 9 _∘_
field
Obj : Set o
Hom : {I : Set ı} → (I → Obj) → Obj → Set ℓ
id : (o : Obj) → Hom {⊤} (pointed o) o
_∘_ : {I : Set ı} {aₙ : I → Obj} {a : Obj} {J : I → Set ı}
{v : (i : I) → J i → Obj} →
Hom {I} aₙ a → ((i : I) → Hom (v i) (aₙ i)) → Hom {Σ I J} (uncurry v) a
_≈[_]_ : {I J : Set ı} {aₙ : I → Obj} {a : Obj} →
Hom {I} aₙ a → (σ : I ↔ J) → Hom {J} (aₙ ● Inverse.from σ) a → Set e
identityˡ : {K : Set ı} {aₖ : K → Obj} {a : Obj} {f : Hom aₖ a} →
id a ∘ pointed f ≈[ ⊤×K↔K ] f
identityʳ : {K : Set ı} {aₖ : K → Obj} {a : Obj} {f : Hom aₖ a} →
f ∘ (id ● aₖ) ≈[ K×⊤↔K ] f
identity² : {a : Obj} → id a ∘ pointed (id a) ≈[ ⊤×⊤↔⊤ ] id a
assoc :
{I : Set ı} {J : I → Set ı} {K : Σ I J → Set ı}
{a : Obj} {aᵢ : I → Obj}
{aᵢⱼ : (i : I) → J i → Obj}
{aᵢⱼₖ : (h : Σ I J) → K h → Obj}
{h : Hom aᵢ a}
{g : (i : I) → Hom (aᵢⱼ i) (aᵢ i)}
{f : (k : Σ I J) → Hom (aᵢⱼₖ k) (uncurry aᵢⱼ k)} →
(h ∘ g) ∘ f ≈[ Σ-assoc ] h ∘ (λ i → g i ∘ curry f i)
refl≈ : {I : Set ı} {aₙ : I → Obj} {a : Obj} →
{h : Hom {I} aₙ a} → h ≈[ id↔ (setoid I) ] h
sym≈ : {I : Set ı} {aₙ : I → Obj} {a : Obj} →
{g h : Hom {I} aₙ a} → g ≈[ id↔ (setoid I) ] h → h ≈[ id↔ (setoid I) ] g
trans≈ : {I : Set ı} {aₙ : I → Obj} {a : Obj} →
{f g h : Hom {I} aₙ a} → f ≈[ id↔ (setoid I) ] g → g ≈[ id↔ (setoid I) ] h → f ≈[ id↔ (setoid I) ] h
∘-resp-≈ : {I : Set ı} {J : I → Set ı}
{a : Obj} {aᵢ : I → Obj} {aᵢⱼ : (i : I) → J i → Obj}
{g g′ : Hom aᵢ a} {f f′ : (i : I) → Hom (aᵢⱼ i) (aᵢ i)} →
g ≈[ id↔ (setoid I) ] g′ → (∀ i → f i ≈[ id↔ (setoid (J i)) ] f′ i) →
g ∘ f ≈[ id↔ (setoid (Σ I J)) ] g′ ∘ f′