-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCartesianIsomorphism.agda
114 lines (103 loc) · 3.77 KB
/
CartesianIsomorphism.agda
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
module CartesianIsomorphism where
open import Level renaming (suc to lsuc)
open import Categorical.Raw
open import Categorical.Equiv
open import Functions (0ℓ)
open import Categorical.Laws using ()
import Categorical.Laws as L
module _ (obj : Set) (_⇨_ : obj → obj → Set) (a c d : obj)
⦃ _ : Category _⇨_ ⦄
⦃ equivl : Equivalent 0ℓ _⇨_ ⦄
⦃ catLaw : L.Category _⇨_ ⦄
⦃ _ : Products obj ⦄
⦃ _ : Cartesian _⇨_ ⦄
⦃ cartLaw : L.Cartesian _⇨_ ⦄
where
open import Function.Bundles
open import Relation.Binary.Bundles
open import Data.Product using (_,_) renaming (_×_ to _×′_)
open import Relation.Binary.Core
cat cat² : Setoid 0ℓ 0ℓ
cat = record { Carrier = a ⇨ (c × d)
; _≈_ = _≈_
; isEquivalence = equiv }
cat² = record { Carrier = (a ⇨ c) ×′ (a ⇨ d)
; _≈_ = λ (a⇨c₁ , a⇨d₁) (a⇨c₂ , a⇨d₂) → (a⇨c₁ ≈ a⇨c₂) ×′ (a⇨d₁ ≈ a⇨d₂)
; isEquivalence =
record
{ refl = refl , refl
; sym = λ (eq₁ , eq₂) → sym eq₁ , sym eq₂
; trans = λ (eq₁ , eq₂) (eq₁′ , eq₂′) → trans eq₁ eq₁′ , trans eq₂ eq₂′
}
}
open Setoid cat using () renaming (Carrier to A; _≈_ to _≈₁_)
open Setoid cat² using () renaming (Carrier to B; _≈_ to _≈₂_)
iso : Inverse cat cat²
iso = record
{ f = f
; f⁻¹ = f⁻¹
; cong₁ = cong₁
; cong₂ = cong₂
; inverse = inverseˡ , inverseʳ
}
where
f : a ⇨ (c × d) → (a ⇨ c) ×′ (a ⇨ d)
f = λ a⇨c×d → exl ∘ a⇨c×d , exr ∘ a⇨c×d
f⁻¹ : (a ⇨ c) ×′ (a ⇨ d) → a ⇨ (c × d)
f⁻¹ = λ a⇨c,a⇨d → exl a⇨c,a⇨d ▵ exr a⇨c,a⇨d
cong₁ : {x y : a ⇨ (c × d)} → x ≈₁ y → (f x ≈₂ f y)
cong₁ {x} {y} x≈₁y =
begin
f x
≡⟨⟩
exl ∘ x , exr ∘ x
≈⟨ L.∘≈ʳ x≈₁y , L.∘≈ʳ x≈₁y ⟩
exl ∘ y , exr ∘ y
≡⟨⟩
f y
∎
where
open import Relation.Binary.Reasoning.Setoid cat²
cong₂ : {x y : (a ⇨ c) ×′ (a ⇨ d)} → x ≈₂ y → (f⁻¹ x ≈₁ f⁻¹ y)
cong₂ {x} {y} x≈₂y =
begin
f⁻¹ x
≡⟨⟩
exl x ▵ exr x
≈⟨ L.▵≈ (exl x≈₂y) (exr x≈₂y) ⟩
exl y ▵ exr y
≡⟨⟩
f⁻¹ y
∎
where
open import Relation.Binary.Reasoning.Setoid cat
inverseˡ : ∀ x → f (f⁻¹ x) ≈₂ x
inverseˡ (a⇨c , a⇨d) =
begin
f (f⁻¹ (a⇨c , a⇨d))
≡⟨⟩
f (a⇨c ▵ a⇨d)
≡⟨⟩
(exl ∘ (a⇨c ▵ a⇨d) , exr ∘ (a⇨c ▵ a⇨d))
≈⟨ L.exl∘▵ , L.exr∘▵ ⟩
(a⇨c , a⇨d)
∎
where
open import Relation.Binary.Reasoning.Setoid cat²
inverseʳ : ∀ x → f⁻¹ (f x) ≈₁ x
inverseʳ a⇨c×d =
begin
f⁻¹ (f a⇨c×d)
≡⟨⟩
f⁻¹ (exl ∘ a⇨c×d , exr ∘ a⇨c×d)
≡⟨⟩
(exl ∘ a⇨c×d) ▵ (exr ∘ a⇨c×d)
≈⟨ sym L.▵∘ ⟩
(exl ▵ exr) ∘ a⇨c×d
≈⟨ L.∘≈ˡ L.exl▵exr ⟩
id ∘ a⇨c×d
≈⟨ L.identityˡ ⟩
a⇨c×d
∎
where
open ≈-Reasoning