{-# OPTIONS --safe --cubical-compatible --guardedness --exact-split --double-check #-}
module ALMA.Base.DetCat where
open import Agda.Primitive using (Level; lsuc)
open import Agda.Builtin.Equality using (_≡_; refl)
open import Relation.Binary.PropositionalEquality.Core using (cong; trans; sym)
open import Categories.Category.Core using (Category)
record DetSys (i : Level) : Set (lsuc i) where
field
I : Set i
step : I → I
open DetSys
record DM {i : Level} (X Y : DetSys i) : Set i where
field
q : I X → I Y
coh : (x : I X) → q (step X x) ≡ step Y (q x)
open DM
_≈DM_ : ∀ {i : Level} {X Y : DetSys i} → DM X Y → DM X Y → Set i
_≈DM_ f g = ∀ x → q f x ≡ q g x
idDM : ∀ {i : Level} (X : DetSys i) → DM X X
idDM X = record { q = λ x → x ; coh = λ _ → refl }
compDM : ∀ {i : Level} {X Y Z : DetSys i}
→ DM Y Z → DM X Y → DM X Z
compDM {X = X} {Y = Y} {Z = Z} g f = record
{ q = λ x → q g (q f x)
; coh = λ x → trans (cong (q g) (coh f x)) (coh g (q f x))
}
assocDM : ∀ {i : Level} {W X Y Z : DetSys i}
(h : DM Y Z) (g : DM X Y) (f : DM W X)
→ compDM (compDM h g) f ≈DM compDM h (compDM g f)
assocDM _ _ _ _ = refl
identityˡDM : ∀ {i : Level} {X Y : DetSys i} (f : DM X Y)
→ compDM (idDM Y) f ≈DM f
identityˡDM _ _ = refl
identityʳDM : ∀ {i : Level} {X Y : DetSys i} (f : DM X Y)
→ compDM f (idDM X) ≈DM f
identityʳDM _ _ = refl
DetCat : (i : Level) → Category (lsuc i) i i
DetCat i = record
{ Obj = DetSys i
; _⇒_ = DM {i}
; _≈_ = _≈DM_ {i}
; id = idDM {i} _
; _∘_ = compDM {i}
; assoc = λ {_ _ _ _ f g h} → assocDM h g f
; sym-assoc = λ {_ _ _ _ f g h} x → sym (assocDM h g f x)
; identityˡ = λ {_ _ f} → identityˡDM f
; identityʳ = λ {_ _ f} → identityʳDM f
; identity² = λ _ → refl
; equiv = record
{ refl = λ {x} _ → refl
; sym = λ {x y} e z → sym (e z)
; trans = λ {x y z} e₁ e₂ w → trans (e₁ w) (e₂ w)
}
; ∘-resp-≈ = λ {f = f} {h = h} {g = g} {i = k} efo ein z →
trans (cong (q f) (ein z)) (efo (q k z))
}