Terminal.agda 995 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. module Terminal where
  2. open import Base
  3. open import Category
  4. open import Unique
  5. open import Dual
  6. import Iso
  7. module Term (ℂ : Cat) where
  8. private ℂ' = η-Cat ℂ
  9. private open module C = Cat ℂ'
  10. private open module U = Uniq ℂ'
  11. private open module I = Iso ℂ'
  12. Terminal : (A : Obj) -> Set1
  13. Terminal A = (B : Obj) -> ∃! \(f : B ─→ A) -> True
  14. toTerminal : {A B : Obj} -> Terminal A -> B ─→ A
  15. toTerminal term = getWitness (term _)
  16. terminalIso : {A B : Obj} -> Terminal A -> Terminal B -> A ≅ B
  17. terminalIso tA tB = iso (toTerminal tB)
  18. (toTerminal tA)
  19. p q
  20. where
  21. p : toTerminal tB ∘ toTerminal tA == id
  22. p = witnessEqual (tB _) tt tt
  23. q : toTerminal tA ∘ toTerminal tB == id
  24. q = witnessEqual (tA _) tt tt
  25. module Init (ℂ : Cat) = Term (η-Cat ℂ op)
  26. renaming
  27. ( Terminal to Initial
  28. ; toTerminal to fromInitial
  29. ; terminalIso to initialIso
  30. )