Product.agda 966 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. module Product where
  2. open import Base
  3. open import Category
  4. open import Unique
  5. open import Dual
  6. module Prod (ℂ : Cat) where
  7. private
  8. ℂ' = η-Cat ℂ
  9. open module C = Cat ℂ'
  10. open module U = Uniq ℂ'
  11. data _×_ (A B : Obj) : Set1 where
  12. prod : (AB : Obj)
  13. (π₀ : AB ─→ A)
  14. (π₁ : AB ─→ B) ->
  15. ((X : Obj)(f : X ─→ A)(g : X ─→ B) ->
  16. ∃! \(h : X ─→ AB) -> π₀ ∘ h == f /\ π₁ ∘ h == g
  17. ) -> A × B
  18. Product : {A B : Obj} -> A × B -> Obj
  19. Product (prod AB _ _ _) = AB
  20. π₀ : {A B : Obj}(p : A × B) -> Product p ─→ A
  21. π₀ (prod _ p _ _) = p
  22. π₁ : {A B : Obj}(p : A × B) -> Product p ─→ B
  23. π₁ (prod _ _ q _) = q
  24. module Sum (ℂ : Cat) = Prod (η-Cat ℂ op)
  25. renaming ( _×_ to _+_
  26. ; prod to sum
  27. ; Product to Sum
  28. ; π₀ to inl
  29. ; π₁ to inr
  30. )