{-# OPTIONS --without-K --safe #-}
module Categories.Category.Instance.Simplex where
open import Level using (0ℓ)
open import Data.Product
open import Data.Fin.Base using (Fin; zero; suc; _≤_; _<_; inject₁; punchIn; pinch)
open import Data.Nat.Base using (ℕ; zero; suc; z≤n; s≤s)
open import Function renaming (id to idF; _∘_ to _∙_)
open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; trans; cong)
open import Categories.Category.Core using (Category)
infix 4 _Δ⇒_
infixr 9 _⊚_
data _Δ⇒_ : ℕ → ℕ → Set where
ε : ∀ {n} → n Δ⇒ n
δ : ∀ {n} → (i : Fin (suc n)) → n Δ⇒ (suc n)
σ : ∀ {n} → (j : Fin n) → (suc n) Δ⇒ n
_⊚_ : ∀ {l m n} → m Δ⇒ n → l Δ⇒ m → l Δ⇒ n
face : ∀ {n} → Fin (ℕ.suc n) → Fin n → Fin (ℕ.suc n)
face = punchIn
degen : ∀ {n} → Fin n → Fin (ℕ.suc n) → Fin n
degen = pinch
⟦_⟧ : ∀ {m n} → m Δ⇒ n → (Fin m → Fin n)
⟦ ε ⟧ x = x
⟦ δ i ⟧ x = face i x
⟦ σ j ⟧ x = degen j x
⟦ f ⊚ g ⟧ x = ⟦ f ⟧ (⟦ g ⟧ x)
infix 4 _≗_
record _≗_ {m n} (f g : m Δ⇒ n) : Set where
constructor Δ-eq
field
Δ-pointwise : ∀ {x} → ⟦ f ⟧ x ≡ ⟦ g ⟧ x
open _≗_ public
Δ : Category 0ℓ 0ℓ 0ℓ
Δ = record
{ Obj = ℕ
; _⇒_ = _Δ⇒_
; _≈_ = _≗_
; id = ε
; _∘_ = _⊚_
; assoc = Δ-eq refl
; sym-assoc = Δ-eq refl
; identityˡ = Δ-eq refl
; identityʳ = Δ-eq refl
; identity² = Δ-eq refl
; equiv = record
{ refl = Δ-eq refl
; sym = λ eq → Δ-eq (sym (Δ-pointwise eq))
; trans = λ eq₁ eq₂ → Δ-eq (trans (Δ-pointwise eq₁) (Δ-pointwise eq₂))
}
; ∘-resp-≈ = λ {_ _ _ f g h i} eq₁ eq₂ → Δ-eq (trans (cong ⟦ f ⟧ (Δ-pointwise eq₂)) (Δ-pointwise eq₁))
}
open Category Δ
face-comm : ∀ {n} (i j : Fin (suc n)) → i ≤ j → δ (inject₁ i) ∘ δ j ≈ δ (suc j) ∘ δ i
face-comm zero _ z≤n = Δ-eq refl
face-comm (suc i) (suc j) (s≤s le) = Δ-eq (λ { {zero} → refl ; {suc x} → cong suc (Δ-pointwise (face-comm i j le)) })
degen-comm : ∀ {n} (i j : Fin n) → i ≤ j → σ j ∘ σ (inject₁ i) ≈ σ i ∘ σ (suc j)
degen-comm zero zero z≤n = Δ-eq λ { {zero} → refl ; {suc x} → refl }
degen-comm zero (suc _) z≤n = Δ-eq λ { {zero} → refl ; {suc x} → refl }
degen-comm (suc i) (suc j) (s≤s le) = Δ-eq (λ { {zero} → refl ; {suc x} → cong suc (Δ-pointwise (degen-comm i j le) {x = x}) })
degen-face-comm : ∀ {n} (i : Fin (suc n)) (j : Fin n) → i < suc j → σ (suc j) ∘ δ (inject₁ i) ≈ δ i ∘ σ j
degen-face-comm zero _ (s≤s _) = Δ-eq refl
degen-face-comm (suc i) (suc j) (s≤s le) = Δ-eq (λ { {zero} → refl ; {suc x} → cong suc (Δ-pointwise (degen-face-comm i j le)) })
degen-face-id : ∀ {n} (i j : Fin n) → i ≡ j → σ j ∘ δ (inject₁ i) ≈ id
degen-face-id zero zero refl = Δ-eq refl
degen-face-id (suc i) (suc i) refl = Δ-eq (λ { {zero} → refl ; {suc x} → cong suc (Δ-pointwise (degen-face-id i i refl)) })
degen-face-suc-id : ∀ {n} (i : Fin (suc n)) (j : Fin n) → i ≡ suc j → σ j ∘ δ i ≈ id
degen-face-suc-id (suc zero) zero refl = Δ-eq λ { {zero} → refl ; {suc x} → refl }
degen-face-suc-id (suc (suc i)) (suc i) refl = Δ-eq λ { {zero} → refl ; {suc x} → cong suc (Δ-pointwise (degen-face-suc-id (suc i) i refl)) }
degen-face-suc-comm : ∀ {n} (i : Fin (suc n)) (j : Fin n) → suc j < i → σ (inject₁ j) ∘ δ (suc i) ≈ δ i ∘ σ j
degen-face-suc-comm (suc (suc i)) zero (s≤s (s≤s z≤n)) = Δ-eq (λ { {zero} → refl ; {suc x} → refl })
degen-face-suc-comm (suc (suc i)) (suc j) (s≤s le) = Δ-eq (λ { {zero} → refl ; {suc x} → cong suc (Δ-pointwise (degen-face-suc-comm (suc i) j le)) })