Datasets:

Modalities:
Text
Languages:
English
Libraries:
Datasets
License:
File size: 10,765 Bytes
4365a98
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
import algebra.homology.exact
import category_theory.abelian.opposite
import category_theory.abelian.exact
import category_theory.limits.constructions.epi_mono
import category_theory.abelian.pseudoelements

noncomputable theory

open category_theory
open category_theory.limits

universes w v u

namespace list

variables {Ξ± : Type*} (a : Ξ±) (L : list Ξ±) (m n : β„•)

/-- Returns the sublist of `L` starting at index `m` of length `n`
(or shorter, if `L` is too short). -/
def extract := (L.drop m).take n

@[simp] lemma extract_nil : [].extract m n = ([] : list Ξ±) :=
by { cases n, refl, cases m, refl, refl }

@[simp] lemma extract_zero_right : L.extract m 0 = [] := rfl

@[simp] lemma extract_cons_succ_left : (a :: L).extract m.succ n = L.extract m n := rfl

end list

example : [0,1,2,3,4,5,6,7,8,9].extract 4 3 = [4,5,6] := rfl

namespace category_theory
variables (π’ž : Type u) [category.{v} π’ž]
variables [has_zero_morphisms π’ž] [has_images π’ž] [has_kernels π’ž]
variables {π’œ : Type u} [category.{v} π’œ] [abelian π’œ]

namespace exact -- move this

variables {A B C : π’œ} (f : A ⟢ B) (g : B ⟢ C)

def kernel_op_iso : (kernel f.op).unop β‰… cokernel f :=
{ hom := (kernel.lift _ (cokernel.Ο€ f).op begin
    simp [← op_comp, limits.cokernel.condition],
  end).unop ≫ eq_to_hom (opposite.unop_op (cokernel f)),
  inv := cokernel.desc _ (eq_to_hom (opposite.unop_op B).symm ≫ (kernel.ΞΉ f.op).unop) begin
    dsimp,
    rw [category.id_comp, ← f.unop_op, ← unop_comp, f.unop_op, kernel.condition],
    refl,
  end,
  hom_inv_id' := begin
    dsimp,
    simp,
    rw [← unop_id, ← (cokernel.desc f (kernel.ΞΉ f.op).unop _).unop_op, ← unop_comp],
    congr' 1,
    apply limits.equalizer.hom_ext,
    dsimp,
    simp [← op_comp],
  end,
  inv_hom_id' := begin
    apply limits.coequalizer.hom_ext,
    dsimp,
    simp [← unop_comp],
  end }

def cokernel_op_iso : (cokernel f.op).unop β‰… kernel f :=
{ hom := kernel.lift _ ((cokernel.Ο€ f.op).unop ≫ eq_to_hom (opposite.unop_op _)) begin
    simp only [eq_to_hom_refl, category.comp_id],
    rw [← f.unop_op, ← unop_comp, f.op.op_unop, cokernel.condition],
    refl,
  end,
  inv := eq_to_hom (opposite.unop_op _).symm ≫ (cokernel.desc _ (kernel.ΞΉ f).op (by simp [← op_comp])).unop,
  hom_inv_id' := begin
    simp only [category.id_comp, eq_to_hom_refl, category.comp_id, ← unop_id, ← unop_comp],
    rw [← (kernel.lift f (cokernel.Ο€ f.op).unop _).unop_op, ← unop_comp],
    congr' 1,
    apply limits.coequalizer.hom_ext,
    dsimp,
    simp [← op_comp],
  end,
  inv_hom_id' := begin
    apply limits.equalizer.hom_ext,
    dsimp,
    simp [← unop_comp]
  end } .

@[simp]
lemma kernel.ΞΉ_op : (kernel.ΞΉ f.op).unop =
  eq_to_hom (opposite.unop_op _) ≫ cokernel.Ο€ f ≫ (kernel_op_iso f).inv :=
begin
  dsimp [kernel_op_iso],
  simp,
end

@[simp]
lemma cokernel.Ο€_op : (cokernel.Ο€ f.op).unop =
  (cokernel_op_iso f).hom ≫ kernel.ΞΉ f ≫ eq_to_hom (opposite.unop_op _).symm :=
begin
  dsimp [cokernel_op_iso],
  simp,
end

variables {f g}

lemma op (h : exact f g) : exact g.op f.op :=
begin
  rw abelian.exact_iff,
  refine ⟨_, _⟩,
  { simp only [← op_comp, h.w, op_zero], },
  apply_fun quiver.hom.unop,
  swap, { exact quiver.hom.unop_inj },
  simp only [h, unop_comp, cokernel.Ο€_op, eq_to_hom_refl, kernel.ΞΉ_op, category.id_comp,
    category.assoc, kernel_comp_cokernel_assoc, zero_comp, comp_zero, unop_zero],
end

variables (f g)

def kernel_unop_iso {C B : π’œα΅’α΅–} (f : C ⟢ B) : opposite.op (kernel f.unop) β‰… cokernel f :=
{ hom := (kernel.lift _ (cokernel.Ο€ f).unop (by simp [← unop_comp])).op ≫
    eq_to_hom (opposite.op_unop (cokernel f)),
  inv := cokernel.desc _ (eq_to_hom (opposite.op_unop _).symm ≫ (kernel.ΞΉ f.unop).op) begin
    dsimp,
    rw [← f.op_unop, category.id_comp, ← op_comp, f.op_unop, kernel.condition],
    refl,
  end,
  hom_inv_id' := begin
    dsimp,
    simp,
    rw [← (cokernel.desc f (kernel.ΞΉ f.unop).op _).op_unop, ← op_comp, ← op_id],
    congr' 1,
    apply limits.equalizer.hom_ext,
    dsimp,
    simp [← unop_comp],
  end,
  inv_hom_id' := begin
    apply limits.coequalizer.hom_ext,
    dsimp,
    simp [← op_comp],
  end }

def cokernel_unop_iso {C B : π’œα΅’α΅–} (f : C ⟢ B) : opposite.op (cokernel f.unop) β‰… kernel f :=
{ hom := kernel.lift _ ((cokernel.Ο€ f.unop).op ≫ eq_to_hom (opposite.op_unop _)) begin
    dsimp,
    rw [← f.op_unop, category.comp_id, ← op_comp, f.op_unop, cokernel.condition],
    refl,
  end,
  inv := eq_to_hom (opposite.op_unop _).symm ≫
    (cokernel.desc _ (kernel.ΞΉ f).unop (by simp [← unop_comp])).op,
  hom_inv_id' := begin
    dsimp,
    rw category.id_comp,
    rw [← (kernel.lift f ((cokernel.Ο€ f.unop).op ≫ πŸ™ C) _).op_unop, ← op_comp, ← op_id],
    congr' 1,
    apply limits.coequalizer.hom_ext,
    dsimp,
    simp [← unop_comp],
  end,
  inv_hom_id' := begin
    apply limits.equalizer.hom_ext,
    dsimp,
    simp [← op_comp]
  end }

@[simp]
lemma cokernel.Ο€_unop {C B : π’œα΅’α΅–} (f : C ⟢ B) : (cokernel.Ο€ f.unop).op =
  (cokernel_unop_iso f).hom ≫ kernel.ΞΉ f ≫ eq_to_hom (opposite.op_unop _).symm :=
begin
  dsimp [cokernel_unop_iso],
  simp,
end

@[simp]
lemma kernel.ΞΉ_unop {C B : π’œα΅’α΅–} (f : C ⟢ B) : (kernel.ΞΉ f.unop).op =
  eq_to_hom (opposite.op_unop _) ≫ cokernel.Ο€ f ≫ (kernel_unop_iso f).inv :=
begin
  dsimp [kernel_unop_iso],
  simp,
end

lemma unop {C B A : π’œα΅’α΅–} {g : C ⟢ B} {f : B ⟢ A} (h : exact g f) : exact f.unop g.unop :=
begin
  rw abelian.exact_iff,
  refine ⟨by simp only [← unop_comp, h.w, unop_zero], _⟩,
  apply_fun quiver.hom.op,
  swap, { exact quiver.hom.op_inj },
  simp [h],
end

end exact

/-- A sequence `[f, g, ...]` of morphisms is exact if the pair `(f,g)` is exact,
and the sequence `[g, ...]` is exact.

Recall that the pair `(f,g)` is exact if `f ≫ g = 0`
and the natural map from the image of `f` to the kernel of `g` is an epimorphism
(equivalently, in abelian categories: isomorphism). -/
inductive exact_seq : list (arrow π’ž) β†’ Prop
| nil    : exact_seq []
| single : βˆ€ f, exact_seq [f]
| cons   : βˆ€ {A B C : π’ž} (f : A ⟢ B) (g : B ⟢ C) (hfg : exact f g) (L) (hgL : exact_seq (g :: L)),
              exact_seq (f :: g :: L)

variable {π’ž}

lemma exact_iff_exact_seq {A B C : π’ž} (f : A ⟢ B) (g : B ⟢ C) :
  exact f g ↔ exact_seq π’ž [f, g] :=
begin
  split,
  { intro h, exact exact_seq.cons f g h _ (exact_seq.single _), },
  { rintro (_ | _ | ⟨A, B, C, f, g, hfg, _, _ | _ | _⟩), exact hfg, }
end

namespace exact_seq

lemma extract : βˆ€ {L : list (arrow π’ž)} (h : exact_seq π’ž L) (m n : β„•),
  exact_seq π’ž (L.extract m n)
| L (nil)               m     n     := by { rw list.extract_nil, exact nil }
| L (single f)          m     0     := nil
| L (single f)          0     (n+1) := by { cases n; exact single f }
| L (single f)          (m+1) (n+1) := by { cases m; exact nil }
| _ (cons f g hfg L hL) (m+1) n     := extract hL m n
| _ (cons f g hfg L hL) 0     0     := nil
| _ (cons f g hfg L hL) 0     1     := single f
| _ (cons f g hfg L hL) 0     (n+2) := cons f g hfg (L.take n) (extract hL 0 (n+1))

inductive arrow_congr : Ξ  (L L' : list (arrow π’ž)), Prop
| nil  : arrow_congr [] []
| cons : βˆ€ {A B : π’ž} {f f' : A ⟢ B} {L L' : list (arrow π’ž)} (h : f = f') (H : arrow_congr L L'),
         arrow_congr (f :: L) (f' :: L')

lemma congr : βˆ€ {L L' : list (arrow π’ž)}, exact_seq π’ž L β†’ arrow_congr L L' β†’ exact_seq π’ž L'
| _ _ h arrow_congr.nil                                 := exact_seq.nil
| _ _ h (arrow_congr.cons h₁ arrow_congr.nil)           := exact_seq.single _
| _ _ h (arrow_congr.cons h₁ ((arrow_congr.cons hβ‚‚ H))) :=
begin
  substs h₁ hβ‚‚,
  rcases h with _ | _ | ⟨A, B, C, f, g, hfg, _, hL⟩,
  refine exact_seq.cons _ _ hfg _ (congr hL (arrow_congr.cons rfl H)),
end

lemma append : βˆ€ {L₁ Lβ‚‚ L₃ : list (arrow π’ž)}
  (h₁₂ : exact_seq π’ž (L₁ ++ Lβ‚‚)) (h₂₃ : exact_seq π’ž (Lβ‚‚ ++ L₃)) (hβ‚‚ : Lβ‚‚ β‰  []),
  exact_seq π’ž (L₁ ++ Lβ‚‚ ++ L₃)
| L₁         []      L₃ h₁₂                 h₂₃ h := (h rfl).elim
| []         Lβ‚‚      L₃ h₁₂                 h₂₃ h := by rwa list.nil_append
| (_::[])    (_::Lβ‚‚) L₃ (cons f g hfg L hL) h₂₃ h := cons f g hfg _ h₂₃
| (_::_::L₁) Lβ‚‚      L₃ (cons f g hfg L hL) h₂₃ h :=
suffices exact_seq π’ž ([f] ++ ([g] ++ L₁ ++ Lβ‚‚) ++ L₃), { simpa only [list.append_assoc] },
cons _ _ hfg _ $
suffices exact_seq π’ž ((g :: L₁) ++ Lβ‚‚ ++ L₃), { simpa only [list.append_assoc] },
append (by simpa only using hL) h₂₃ h

end exact_seq

namespace arrow

open _root_.opposite

variables {C : Type*} [category C]

@[simps]
def op (f : arrow C) : arrow Cα΅’α΅– :=
{ left := op f.right,
  right := op f.left,
  hom := f.hom.op }

@[simps]
def unop (f : arrow Cα΅’α΅–) : arrow C :=
{ left := unop f.right,
  right := unop f.left,
  hom := f.hom.unop }

@[simp] lemma op_unop (f : arrow C)   : f.op.unop = f := by { cases f, dsimp [op, unop], refl }
@[simp] lemma unop_op (f : arrow Cα΅’α΅–) : f.unop.op = f := by { cases f, dsimp [op, unop], refl }

@[simp] lemma op_comp_unop : (op ∘ unop : arrow Cα΅’α΅– β†’ arrow Cα΅’α΅–) = id := by { ext, exact unop_op _ }
@[simp] lemma unop_comp_op : (unop ∘ op : arrow C   β†’ arrow C  ) = id := by { ext, exact op_unop _ }

end arrow

namespace exact_seq

lemma op : βˆ€ {L : list (arrow π’œ)}, exact_seq π’œ L β†’ exact_seq π’œα΅’α΅– (L.reverse.map arrow.op)
| _ nil                 := nil
| _ (single f)          := single f.op
| _ (cons f g hfg L hL) :=
begin
  have := op hL,
  simp only [list.reverse_cons, list.map_append] at this ⊒,
  refine this.append _ (list.cons_ne_nil _ _),
  exact cons _ _ hfg.op _ (single _),
end

lemma unop : βˆ€ {L : list (arrow π’œα΅’α΅–)}, exact_seq π’œα΅’α΅– L β†’ exact_seq π’œ (L.reverse.map arrow.unop)
| _ nil                 := nil
| _ (single f)          := single f.unop
| _ (cons f g hfg L hL) :=
begin
  have := unop hL,
  simp only [list.reverse_cons, list.map_append] at this ⊒,
  refine this.append _ (list.cons_ne_nil _ _),
  exact cons _ _ hfg.unop _ (single _),
end

lemma of_op {L : list (arrow π’œ)} (h : exact_seq π’œα΅’α΅– (L.reverse.map arrow.op)) : exact_seq π’œ L :=
by simpa only [list.map_reverse, list.reverse_reverse, list.map_map,
  arrow.unop_comp_op, list.map_id] using h.unop

lemma of_unop {L : list (arrow π’œα΅’α΅–)} (h : exact_seq π’œ (L.reverse.map arrow.unop)) :
  exact_seq π’œα΅’α΅– L :=
by simpa only [list.map_reverse, list.reverse_reverse, list.map_map,
  arrow.op_comp_unop, list.map_id] using h.op

end exact_seq

end category_theory