-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathHalfAdjointEquivalences.agda
211 lines (177 loc) · 8.51 KB
/
HalfAdjointEquivalences.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
{-# OPTIONS --without-K #-}
open import Basics
open import EqualityAndPaths
open import Homotopies
open import Equivalences
open import Language
module HalfAdjointEquivalences where
record _is-an-half-adjoint-equivalence {A B : 𝒰₀} (f : A → B) : 𝒰₀ where
constructor has-inverse_by_,_and-is-half-adjoint-by_
field
g : B → A
left-invertible : g ∘ f ⇒ id
right-invertible : f ∘ g ⇒ id
half-adjoint : (a : A) → f ⁎ left-invertible a ≈ right-invertible (f a)
_≃ha_ : (A B : 𝒰₀) → 𝒰₀
A ≃ha B = ∑ (λ (f : A → B) → f is-an-half-adjoint-equivalence)
_≃ₕₐ_ = _≃ha_
underlying-map-of-the-half-adjoint :
∀ {A B : 𝒰₀}
→ A ≃ha B → (A → B)
underlying-map-of-the-half-adjoint
(e , equivalency) = e
inverse-of-the-half-adjoint :
∀ {A B : 𝒰₀}
→ A ≃ha B → (B → A)
inverse-of-the-half-adjoint
(_ , (has-inverse g by _ , _ and-is-half-adjoint-by _)) =
g
left-invertibility-of-the-half-adjoint :
∀ {A B : 𝒰₀}
→ (e : A ≃ha B)
→ inverse-of-the-half-adjoint e ∘ underlying-map-of-the-half-adjoint e ⇒ id
left-invertibility-of-the-half-adjoint
(_ , (has-inverse _ by left-invertible , _ and-is-half-adjoint-by _)) =
left-invertible
right-invertibility-of-the-half-adjoint :
∀ {A B : 𝒰₀}
→ (e : A ≃ha B)
→ underlying-map-of-the-half-adjoint e ∘ inverse-of-the-half-adjoint e ⇒ id
right-invertibility-of-the-half-adjoint
(_ , (has-inverse _ by _ , right-invertible and-is-half-adjoint-by _)) =
right-invertible
half-adjointness-of-the-half-adjoint :
∀ {A B : 𝒰₀}
→ (e : A ≃ha B)
→ (a : A)
→ (underlying-map-of-the-half-adjoint e) ⁎ (left-invertibility-of-the-half-adjoint e) a
≈ (right-invertibility-of-the-half-adjoint e) (underlying-map-of-the-half-adjoint e a)
half-adjointness-of-the-half-adjoint
(_ , (has-inverse _ by left-invertible , right-invertible and-is-half-adjoint-by half-adjoint)) =
half-adjoint
equivalences-are-half-adjoint :
∀ {A B : 𝒰₀} (f : A → B)
→ f is-an-equivalence
→ f is-an-half-adjoint-equivalence
equivalences-are-half-adjoint f
(has-left-inverse l by unit and-right-inverse r by counit) =
-- use HoTT-book-thm 4.2.3
let
l∼r = left-and-right-inverse-are-homotopic f l r unit counit
counit′ : f ∘ l ∼ id
counit′ b = f ⁎ l∼r b • counit b ⁻¹
counit′′ : f ∘ l ∼ id
counit′′ b = counit′ (f (l b)) ⁻¹ • (f ⁎ unit (l b) • counit′ b)
use-naturality : (a : _) → unit (l (f a)) ≈ (l ∘ f) ⁎ (unit a)
use-naturality a = unit (l (f a))
≈⟨ (cancel (id ⁎ (unit a)) and (unit a)
,-which-are-equal-by (id-has-trivial-application (unit a))
,-on-the-right-in (naturality-of-homotopies (l ∘ f) id unit (unit a))) ⟩
(l ∘ f) ⁎ (unit a)
≈∎
apply-f : (a : _) → f ⁎ (unit (l (f a))) ≈ f ⁎ ((l ∘ f) ⁎ (unit a))
apply-f a = (λ ξ → f ⁎ ξ) ⁎ (use-naturality a)
concatenate-counit : (a : _)
→ f ⁎ (unit (l (f a))) • counit′ (f a) ≈ f ⁎ ((l ∘ f) ⁎ (unit a)) • counit′ (f a)
concatenate-counit a = concatenate counit′ (f a) on-the-right-to apply-f a
naturality-of-counit′ : (a : _) → (f ∘ l) ⁎ (f ⁎ unit a) • counit′ (f a) ≈ counit′ (f (l (f a))) • f ⁎ unit a
naturality-of-counit′ a = (f ∘ l) ⁎ (f ⁎ unit a) • counit′ (f a)
≈⟨ naturality-of-homotopies (f ∘ l) id counit′ (f ⁎ unit a) ⁻¹ ⟩
counit′ (f (l (f a))) • id ⁎ (f ⁎ unit a)
≈⟨ (λ ξ → counit′ (f (l (f a))) • ξ) ⁎ id-has-trivial-application (f ⁎ unit a) ⟩
counit′ (f (l (f a))) • f ⁎ unit a
≈∎
combine-the-last-two : (a : _) → f ⁎ (unit (l (f a))) • counit′ (f a) ≈ counit′ (f (l (f a))) • f ⁎ unit a
combine-the-last-two a = f ⁎ (unit (l (f a))) • counit′ (f a)
≈⟨ concatenate-counit a ⟩
f ⁎ ((l ∘ f) ⁎ (unit a)) • counit′ (f a)
≈⟨ ( (λ ξ → ξ • counit′ (f a)) ⁎
(application-commutes-with-composition (l ∘ f) f (unit a) •
application-commutes-with-composition f (f ∘ l) (unit a) ⁻¹)
• naturality-of-counit′ a) ⟩
counit′ (f (l (f a))) • f ⁎ unit a
≈∎
in has-inverse l by unit , counit′′
and-is-half-adjoint-by λ a →
(move-the (counit′ (f (l (f a)))) left-of (f ⁎ unit a) in-the-equation
(combine-the-last-two a) to-the-left-hand-side) ⁻¹
_as-half-adjoint :
∀ {A B : 𝒰₀}
→ (A ≃ B)
→ A ≃ha B
(the-equivalence is-an-equivalence-because proof-of-invertibility) as-half-adjoint =
(the-equivalence ,
equivalences-are-half-adjoint the-equivalence proof-of-invertibility)
construct-half-adjoint :
∀ {A B : 𝒰₀}
→ (f : A → B) → (f⁻¹ : B → A)
→ f⁻¹ ∘ f ⇒ id → f ∘ f⁻¹ ⇒ id
→ A ≃ₕₐ B
construct-half-adjoint f f⁻¹ l r =
(f is-an-equivalence-because
(has-left-inverse f⁻¹ by l and-right-inverse f⁻¹ by (λ a → r a ⁻¹)))
as-half-adjoint
proof-that-the-equivalence_is-half-adjoint :
∀ {A B : 𝒰₀}
→ (e : A ≃ B) → (underlying-map-of e) is-an-half-adjoint-equivalence
proof-that-the-equivalence (e is-an-equivalence-because proof-of-equivalency) is-half-adjoint =
equivalences-are-half-adjoint e proof-of-equivalency
half-adjoint-equivalences-to-equivalences :
∀ {A B : 𝒰₀}
→ A ≃ha B → A ≃ B
half-adjoint-equivalences-to-equivalences
(e , (has-inverse e⁻¹ by unit , counit and-is-half-adjoint-by proof-of-half-adjointness)) =
e is-an-equivalence-because (has-left-inverse e⁻¹ by unit and-right-inverse e⁻¹ by counit ⁻¹∼)
equivalence-to-half-adjoint-equivalence :
∀ {A B : 𝒰₀}
→ A ≃ B → A ≃ha B
equivalence-to-half-adjoint-equivalence e =
((underlying-map-of e) , proof-that-the-equivalence e is-half-adjoint)
-- composition of half adjoint equivalences
infixr 70 _∘≃ha_
_∘≃ha_ : ∀ {A B C : 𝒰₀} (g : B ≃ha C) (f : A ≃ha B) → A ≃ha C
g ∘≃ha f = let
to-equivalence = half-adjoint-equivalences-to-equivalences
to-ha = equivalence-to-half-adjoint-equivalence
in to-ha (to-equivalence g ∘≃ to-equivalence f)
infix 60 _$≃ha
_$≃ha :
∀ {A B : 𝒰₀}
→ A ≃ha B → A → B
ψ $≃ha = (underlying-map-of-the-half-adjoint ψ)
-- inversion
infix 80 _⁻¹≃ha
_⁻¹≃ha :
∀ {A B : 𝒰₀}
→ A ≃ha B → B ≃ha A
f ⁻¹≃ha = equivalence-to-half-adjoint-equivalence
(half-adjoint-equivalences-to-equivalences f ⁻¹≃)
transport-as-half-adjoint :
∀ {A : 𝒰₀} {x y : A}
→ (P : A → 𝒰₀) → (γ : x ≈ y) → (P x ≃ha P y)
transport-as-half-adjoint P γ =
equivalence-to-half-adjoint-equivalence (transport-as-equivalence P γ)
{-
switching from equivalences to half adjoints...
-}
inverse-of_given-by_ :
∀ {A B : 𝒰₀}
→ (f : A → B) → f is-an-equivalence
→ (B → A)
inverse-of f given-by p =
inverse-of-the-half-adjoint
(equivalence-to-half-adjoint-equivalence (f is-an-equivalence-because p))
_is-left-invertible-by_ :
∀ {A B : 𝒰₀}
→ (f : A → B) → (p : f is-an-equivalence)
→ (inverse-of f given-by p) ∘ f ⇒ id
f is-left-invertible-by p =
left-invertibility-of-the-half-adjoint
(equivalence-to-half-adjoint-equivalence (f is-an-equivalence-because p))
_is-right-invertible-by_ :
∀ {A B : 𝒰₀}
→ (f : A → B) → (p : f is-an-equivalence)
→ f ∘ (inverse-of f given-by p) ⇒ id
f is-right-invertible-by p =
right-invertibility-of-the-half-adjoint
(equivalence-to-half-adjoint-equivalence (f is-an-equivalence-because p))