{-# OPTIONS --without-K --safe #-} module Nat.Properties where open import Data.Empty using (⊥-elim) open import Data.Fin using (Fin; #_; toℕ) open import Data.Fin.Properties using (¬Fin0) open import Data.Nat using (ℕ; s≤s) open import Data.Product using (_,_; proj₁; proj₂; Σ-syntax) open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; cong) open import Relation.Binary.PropositionalEquality.Properties using (module ≡-Reasoning) open import Categories.Category.Core using (Category) open import Categories.Category.Instance.Nat using (Nat; Coprod) open import Categories.Diagram.Coequalizer Nat using (IsCoequalizer; Coequalizer) open import Categories.Diagram.Pushout Nat using (Pushout) open import Categories.Diagram.Pushout.Properties Nat using (Coproduct×Coequalizer⇒Pushout) open import Categories.Object.Coproduct Nat using (Coproduct; IsCoproduct; IsCoproduct⇒Coproduct) open import Coeq using (coequalizer-on-coproduct) open import FinMerge using (glue-iter; glue-unglue-once) open import FinMerge.Properties using (lemma₂; merge-unmerge; unmerge-merge) open import Util using (compare; less; equal; greater; _<_<_) open Category Nat makeZeroCoequalizer : {B : ℕ} {f g : 0 ⇒ B} → Coequalizer f g makeZeroCoequalizer = record { arr = id ; isCoequalizer = record { equality = λ() ; coequalize = λ {_} {h} _ → h ; universal = λ _ → refl ; unique = λ h≈i∘id → Equiv.sym h≈i∘id } } makeSimpleCoequalizer : {B : ℕ} {f g : 1 ⇒ B} → Coequalizer f g makeSimpleCoequalizer {ℕ.zero} {f} = ⊥-elim (¬Fin0 (f (# 0))) makeSimpleCoequalizer {ℕ.suc B} {f} {g} = record { arr = proj₂ (glue-iter f g id) ; isCoequalizer = record { equality = λ { Fin.zero → lemma₂ f g } ; coequalize = λ {_} {h} h∘f≈h∘g → h ∘ proj₂ (proj₂ (glue-unglue-once (compare (f (# 0)) (g (# 0))))) ; universal = λ { {C} {h} {eq} → univ {C} {h} {eq} } ; unique = λ { {C} {h} {i} {eq} h≈i∘m → uniq {C} {h} {i} {eq} h≈i∘m } } } where univ : {C : Obj} {h : ℕ.suc B ⇒ C} {eq : h ∘ f ≈ h ∘ g} → ∀ x → h x ≡ h ((proj₂ (proj₂ (glue-unglue-once (compare (f (# 0)) (g (# 0)))))) (proj₂ (glue-iter f g id) x)) univ {C} {h} {eq} x with compare (f ( # 0)) (g (# 0)) ... | less (f0