Isomorphism.agda 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. module Isomorphism where
  2. import Sets
  3. open Sets
  4. infix 20 _≅_
  5. data _≅_ (A B : Set) : Set where
  6. iso : (i : A -> B)(j : B -> A) ->
  7. (forall x -> j (i x) == x) ->
  8. (forall y -> i (j y) == y) ->
  9. A ≅ B
  10. refl-≅ : (A : Set) -> A ≅ A
  11. refl-≅ A = iso id id (\x -> refl) (\x -> refl)
  12. iso[×] : {A₁ A₂ B₁ B₂ : Set} -> A₁ ≅ A₂ -> B₁ ≅ B₂ -> A₁ [×] B₁ ≅ A₂ [×] B₂
  13. iso[×] (iso a₁₂ a₂₁ p₁₁ p₂₂) (iso b₁₂ b₂₁ q₁₁ q₂₂) =
  14. iso ab₁₂ ab₂₁ pq₁₁ pq₂₂ where
  15. ab₁₂ = a₁₂ <×> b₁₂
  16. ab₂₁ = a₂₁ <×> b₂₁
  17. pq₂₂ : (z : _ [×] _) -> ab₁₂ (ab₂₁ z) == z
  18. pq₂₂ < x , y > =
  19. subst (\ ∙ -> < ∙ , b₁₂ (b₂₁ y) > == < x , y >) (p₂₂ x)
  20. $ cong < x ,∙> (q₂₂ y)
  21. pq₁₁ : (z : _ [×] _) -> ab₂₁ (ab₁₂ z) == z
  22. pq₁₁ < x , y > =
  23. subst (\ ∙ -> < ∙ , b₂₁ (b₁₂ y) > == < x , y >) (p₁₁ x)
  24. $ cong < x ,∙> (q₁₁ y)
  25. iso[+] : {A₁ A₂ B₁ B₂ : Set} -> A₁ ≅ A₂ -> B₁ ≅ B₂ -> A₁ [+] B₁ ≅ A₂ [+] B₂
  26. iso[+] (iso a₁₂ a₂₁ p₁₁ p₂₂) (iso b₁₂ b₂₁ q₁₁ q₂₂) =
  27. iso ab₁₂ ab₂₁ pq₁₁ pq₂₂ where
  28. ab₁₂ = a₁₂ <+> b₁₂
  29. ab₂₁ = a₂₁ <+> b₂₁
  30. pq₂₂ : (z : _ [+] _) -> ab₁₂ (ab₂₁ z) == z
  31. pq₂₂ (inl x) = cong inl (p₂₂ x)
  32. pq₂₂ (inr y) = cong inr (q₂₂ y)
  33. pq₁₁ : (z : _ [+] _) -> ab₂₁ (ab₁₂ z) == z
  34. pq₁₁ (inl x) = cong inl (p₁₁ x)
  35. pq₁₁ (inr y) = cong inr (q₁₁ y)