-
Notifications
You must be signed in to change notification settings - Fork 12
/
complex_extend.lean
870 lines (762 loc) Β· 35.1 KB
/
complex_extend.lean
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
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
import algebra.homology.homotopy
import category_theory.abelian.basic
import for_mathlib.short_complex_functor_category
import for_mathlib.short_complex_homological_complex
universes v u
noncomputable theory
open category_theory category_theory.limits
variables {ΞΉ ΞΉ' ΞΉβ ΞΉβ : Type*}
namespace complex_shape
/-- An embedding `embedding cβ cβ` between two complex shapes `ΞΉβ` and `ΞΉβ` is
an injection `ΞΉβ β ΞΉβ` sending related vertices to related vertices. Recall that two
vertices are related in a complex shape iff the differential between them is allowed to
be nonzero. -/
@[nolint has_inhabited_instance]
structure embedding (cβ : complex_shape ΞΉβ) (cβ : complex_shape ΞΉβ) :=
(f : ΞΉβ β ΞΉβ)
(r : ΞΉβ β option ΞΉβ)
(eq_some : β iβ iβ, r iβ = some iβ β f iβ = iβ)
(c : β β¦i jβ¦, cβ.rel i j β cβ.rel (f i) (f j))
namespace embedding
/-- extra condition which shall be useful to compare homology -/
def c_iff {cβ : complex_shape ΞΉβ} {cβ : complex_shape ΞΉβ} (e : cβ.embedding cβ) : Prop :=
β (i j), cβ.rel i j β cβ.rel (e.f i) (e.f j)
lemma r_f {cβ : complex_shape ΞΉβ} {cβ : complex_shape ΞΉβ} (e : cβ.embedding cβ) (i : ΞΉβ) :
e.r (e.f i) = some i := by rw e.eq_some
lemma r_none {cβ : complex_shape ΞΉβ} {cβ : complex_shape ΞΉβ} (e : cβ.embedding cβ) (i : ΞΉβ)
(hi: Β¬β (iβ : ΞΉβ), i = e.f iβ) : e.r i = none :=
begin
classical,
by_contra hi2,
apply hi,
obtain β¨j, hjβ© := option.ne_none_iff_exists'.1 hi2,
use j,
rw e.eq_some at hj,
rw hj,
end
/-- The map from `β€` to `option β` which is `some n` on `n : β : β€` and `none otherwise. -/
def pos_int_to_onat : β€ β option β
| (n:β) := n
| -[1+n] := none
/-- The map from `β€` to `option β` which is `some n` on `-(n : β : β€)` and `none otherwise. -/
def neg_int_to_onat : β€ β option β
| 0 := (0:β)
| (n+1:β) := none
| -[1+n] := (n+1:β)
/-- The obvious embedding from the β-indexed "cohomological" complex `* β * β * β ...`
to the corresponding β€-indexed complex. -/
def nat_up_int_up : embedding (complex_shape.up β) (complex_shape.up β€) :=
{ f := coe,
r := pos_int_to_onat,
eq_some := begin
rintro (i|i) i',
{ split; { rintro β¨rflβ©, refl }, },
{ split; { rintro β¨β©, } }
end,
c := by { rintro i j (rfl : _ = _), dsimp, refl } }
/-- The obvious embedding from the β-indexed "homological" complex `* β * β * β ...`
to the corresponding β€-indexed homological complex. -/
def nat_down_int_down : embedding (complex_shape.down β) (complex_shape.down β€) :=
{ f := coe,
r := pos_int_to_onat,
eq_some := begin
rintro (i|i) i',
{ split; { rintro β¨rflβ©, refl }, },
{ split; { rintro β¨β©, } }
end,
c := by { rintro i j (rfl : _ = _), dsimp, refl } }
/-- Obvious embedding from the `β`-indexed homological complex `* β * β * ...`
to `β€`-indexed cohomological complex ` ... β * β * β ...` sending $n$ to $-n$
on the corresponding map `β β β€`. -/
def nat_down_int_up : embedding (complex_shape.down β) (complex_shape.up β€) :=
{ f := -coe,
r := neg_int_to_onat,
eq_some := begin
rintro ((_|i)|i) (_|i'),
any_goals { split; { rintro β¨β©, } },
any_goals { split; { rintro β¨rflβ©, refl }, },
end,
c := by { rintro i j (rfl : _ = _),
simp only [pi.neg_apply, int.coe_nat_succ, neg_add_rev, up_rel, neg_add_cancel_comm], } }
lemma nat_down_int_up_c_iff : nat_down_int_up.c_iff :=
begin
intros i j,
split,
{ apply nat_down_int_up.c, },
{ intro hij,
change j+1 = i,
dsimp [nat_down_int_up] at hij,
rw β int.coe_nat_eq_coe_nat_iff,
simp only [int.coe_nat_succ],
linarith, },
end
/-- Obvious embedding from the `β`-indexed cohomological complex `* β * β * ...`
to `β€`-indexed homological complex ` ... β * β * β ...` sending $n$ to $-n$
on the corresponding map `β β β€`. -/
def nat_up_int_down : embedding (complex_shape.up β) (complex_shape.down β€) :=
{ f := -coe,
r := neg_int_to_onat,
eq_some := begin
rintro ((_|i)|i) (_|i'),
any_goals { split; { rintro β¨β©, } },
any_goals { split; { rintro β¨rflβ©, refl }, },
end,
c := by { rintro i j (rfl : _ = _),
simp only [pi.neg_apply, int.coe_nat_succ, neg_add_rev, down_rel, neg_add_cancel_comm] } }
end embedding
end complex_shape
variables {cβ : complex_shape ΞΉβ} {cβ : complex_shape ΞΉβ}
variables {cΞΉ : complex_shape ΞΉ} {cΞΉ' : complex_shape ΞΉ'}
variables {π : Type*} [category π] [preadditive π] [has_zero_object π] -- reclaim category notation!
namespace homological_complex
open_locale zero_object
section embed_X_and_d_basics
/-
`embed`, not to be confused with `embedding` later on, is simply
the extension of constructions involving the index type `ΞΉ` of our complex,
to the larger type `option ΞΉ`, with `none` being sent to `zero`.
-/
variable (X : homological_complex π cΞΉ)
/-- If `π` is an abelian category, and `(Xα΅’)α΅’` is a `π`-valued homological
complex on a complex-shape with index `ΞΉ`, then `embed.X X oi` for `oi : option ΞΉ`
is the value `Xα΅’` of `h` at `some i` (an object of `π`), or `0` for `none`. -/
def embed.X : option ΞΉ β π
| (some i) := X.X i
| none := 0
def embed.X_iso_of_none {e : option ΞΉ} (he : e = none) :
embed.X X e β
0 :=
by { rw he, refl }
def embed.X_is_zero_of_none {e : option ΞΉ} (he : e = none) :
is_zero (embed.X X e) :=
is_zero.of_iso (category_theory.limits.is_zero_zero π) (embed.X_iso_of_none X he)
def embed.X_iso_of_some {e : option ΞΉ} {i} (he : e = some i) :
embed.X X e β
X.X i :=
by { rw he, refl }
@[simp] lemma embed.X_none : embed.X X none = 0 := rfl
@[simp] lemma embed.X_some (i : ΞΉ) : embed.X X (some i) = X.X i := rfl
/-- The morphism `Xα΅’ β Xβ±Ό` with `i j : option ΞΉ` coming from the complex `X`.
Equal to zero if either `i` or `j` is `none`. -/
def embed.d : Ξ i j, embed.X X i βΆ embed.X X j
| (some i) (some j) := X.d i j
| (some i) none := 0
| none j := 0
def embed.d_of_none_src {eβ eβ : option ΞΉ} (he : eβ = none) :
embed.d X eβ eβ = 0 :=
by { rw he, refl }
def embed.d_of_none_tgt {eβ eβ : option ΞΉ} (he : eβ = none) :
embed.d X eβ eβ = 0 :=
by { rw he, cases eβ; refl }
def embed.d_of_some_of_some {eβ eβ : option ΞΉ} {i j}
(hβ : eβ = some i) (hβ : eβ = some j) :
embed.d X eβ eβ = (embed.X_iso_of_some X hβ).hom β« X.d i j β«
(embed.X_iso_of_some X hβ).inv :=
by { subst hβ, subst hβ, change _ = π _ β« _ β« π _, simpa }
@[simp] lemma embed.d_some_some (i j : ΞΉ) : embed.d X (some i) (some j) = X.d i j :=
rfl
lemma embed.d_ne_zero (eβ eβ : option ΞΉ) (h : embed.d X eβ eβ β 0) :
β (i j : ΞΉ) (hβ : eβ = some i) (hβ : eβ = some j), X.d i j β 0 :=
begin
rcases hβ : eβ with _ | β¨iβ©,
{ exfalso,
apply h,
exact embed.d_of_none_src X hβ, },
{ rcases hβ : eβ with _ | β¨jβ©,
{ exfalso,
apply h,
exact embed.d_of_none_tgt X hβ, },
{ substs hβ hβ,
refine β¨i, j, rfl, rfl, hβ©, }, },
end
/-- Prop-valued so probably won't break anything. To deal with zerology. -/
instance homological_complex.embed.subsingleton_to_none (c : _) : subsingleton (c βΆ embed.X X none) :=
@unique.subsingleton _ (has_zero_object.unique_from c)
instance homological_complex.embed.subsingleton_of_none (c) : subsingleton (embed.X X none βΆ c) :=
@unique.subsingleton _ (has_zero_object.unique_to c)
@[simp] lemma embed.d_to_none (i : option ΞΉ) : embed.d X i none = 0 :=
by cases i; refl
@[simp] lemma embed.d_of_none (i : option ΞΉ) : embed.d X none i = 0 :=
rfl
lemma embed.shape : β (i j : option ΞΉ)
(h : β (i' j' : ΞΉ), i = some i' β j = some j' β Β¬ cΞΉ.rel i' j'),
embed.d X i j = 0
| (some i) (some j) h := X.shape _ _ $ h i j rfl rfl
| (some i) none h := rfl
| none j h := rfl
lemma embed.d_comp_d : β i j k, embed.d X i j β« embed.d X j k = 0
| (some i) (some j) (some k) := X.d_comp_d _ _ _
| (some i) (some j) none := comp_zero
| (some i) none k := comp_zero
| none j k := zero_comp
end embed_X_and_d_basics
section embedding_change_of_complex
variable (e : cΞΉ.embedding cΞΉ')
/-- Object-valued pushforward of `π`-valued homological complexes along an embedding
`ΞΉβ βͺ ΞΉβ` of complex-shapes (with all indexes not in the image going to `0`). -/
def embed.obj (X : homological_complex π cΞΉ) : homological_complex π cΞΉ' :=
{ X := Ξ» i, embed.X X (e.r i),
d := Ξ» i j, embed.d X (e.r i) (e.r j),
shape' := Ξ» i j hij, embed.shape X _ _ begin
simp only [e.eq_some],
rintro i' j' rfl rfl h',
exact hij (e.c h')
end,
d_comp_d' := Ξ» i j k hij hjk, embed.d_comp_d X _ _ _ }
variables {X Y Z : homological_complex π cΞΉ} (f : X βΆ Y) (g : Y βΆ Z)
/-- Morphism-valued pushforward of `π`-valued homological complexes along an embedding of complex-shapes
( with all morphisms not in the image being defined to be 0) -/
def embed.f : Ξ i, embed.X X i βΆ embed.X Y i
| (some i) := f.f i
| none := 0
@[simp] lemma embed.f_none : embed.f f none = 0 := rfl
@[simp] lemma embed.f_some (i : ΞΉ) : embed.f f (some i) = f.f i := rfl
lemma embed.f_add {f g : X βΆ Y} : β i, embed.f (f + g) i = embed.f f i + embed.f g i
| (some i) := by simp
| none := by simp
lemma embed.comm : β i j, embed.f f i β« embed.d Y i j = embed.d X i j β« embed.f f j
| (some i) (some j) := f.comm _ _
| (some i) none := show _ β« 0 = 0 β« 0, by simp only [comp_zero]
| none j := show 0 β« 0 = 0 β« _, by simp only [zero_comp]
/-- Pushforward of a morphism `(Xα΅’)α΅’ βΆ (Yα΅’)α΅’` of homological complexes with
the same complex-shape `ΞΉ`, along an embedding of complex shapes c.embedding `ΞΉ β ΞΉ'` -/
def embed.map : embed.obj e X βΆ embed.obj e Y :=
{ f := Ξ» i, embed.f f _,
comm' := Ξ» i j hij, embed.comm f _ _ }
lemma embed.f_id : β i, embed.f (π X) i = π (embed.X X i)
| (some i) := rfl
| none := has_zero_object.from_zero_ext _ _
lemma embed.f_comp : β i, embed.f (f β« g) i = embed.f f i β« embed.f g i
| (some i) := rfl
| none := has_zero_object.from_zero_ext _ _
lemma embed.f_of_some {e : option ΞΉ} {i} (he : e = some i) :
embed.f f e =
(embed.X_iso_of_some _ he).hom β«
f.f i β«
(embed.X_iso_of_some _ he).inv :=
by { subst he, change _ = π _ β« _ β« π _, simp, }
/-- Functor pushing forward, for a fixed abelian category `π`, the category
of `π`-valued homological complexes of shape `ΞΉβ` along an embedding `ΞΉβ βͺ ΞΉβ`
(not Lean notation -- fix somehow?) of complexes. -/
def embed : homological_complex π cΞΉ β₯€ homological_complex π cΞΉ' :=
{ obj := embed.obj e,
map := Ξ» X Y f, embed.map e f,
map_id' := Ξ» X, by { ext i, exact embed.f_id _ },
map_comp' := by { intros, ext i, exact embed.f_comp f g _ } }
.
instance embed_additive :
(embed e : homological_complex π cΞΉ β₯€ homological_complex π cΞΉ').additive :=
{ map_add' := Ξ» X Y f g, by { ext, exact embed.f_add _, }, }
def embed_iso (i : ΞΉ) : ((embed e).obj X).X (e.f i) β
X.X i :=
eq_to_iso
begin
delta embed embed.obj,
dsimp,
rw e.r_f,
refl,
end
lemma embed_eval_is_zero_of_none (i' : ΞΉ') (hi' : e.r i' = none) :
is_zero (embed e β homological_complex.eval π _ i') :=
begin
rw functor.is_zero_iff,
intro X,
exact is_zero.of_iso (limits.is_zero_zero _) (embed.X_iso_of_none X hi'),
end
@[simps]
def embed_eval_iso_of_some (i' : ΞΉ') (i : ΞΉ) (hi' : e.r i' = some i) :
embed e β homological_complex.eval π cΞΉ' i' β
homological_complex.eval π cΞΉ i :=
nat_iso.of_components (Ξ» X, embed.X_iso_of_some X hi')
(Ξ» Xβ Xβ f, begin
dsimp [embed, embed.map],
rw embed.f_of_some f hi',
simp only [category.assoc, iso.inv_hom_id, category.comp_id],
end)
@[simp]
lemma embed_nat_obj_down_up_succ
(C : chain_complex π β) (i : β) :
((embed complex_shape.embedding.nat_down_int_up).obj C).X (-[1+i]) = C.X (i+1) := rfl
@[simp]
lemma embed_nat_obj_down_up_zero
(C : chain_complex π β) :
((embed complex_shape.embedding.nat_down_int_up).obj C).X 0 = C.X 0 := rfl
@[simp]
lemma embed_nat_obj_down_up_pos
(C : chain_complex π β) (i : β) :
((embed complex_shape.embedding.nat_down_int_up).obj C).X (i+1) = 0 := rfl
@[simp]
lemma embed_nat_obj_down_up_succ_f
(Cβ Cβ : chain_complex π β) (f : Cβ βΆ Cβ) (i : β) :
((embed complex_shape.embedding.nat_down_int_up).map f).f (-[1+i]) = f.f (i+1) := rfl
@[simp]
lemma embed_nat_obj_down_up_zero_f
(Cβ Cβ : chain_complex π β) (f : Cβ βΆ Cβ) :
((embed complex_shape.embedding.nat_down_int_up).map f).f 0 = f.f 0 := rfl
@[simp]
lemma embed_nat_obj_down_up_zero_pos
(Cβ Cβ : chain_complex π β) (f : Cβ βΆ Cβ) (i : β) :
((embed complex_shape.embedding.nat_down_int_up).map f).f (i+1) = 0 := rfl
end embedding_change_of_complex
section homotopy
variables {X Y : homological_complex π cΞΉ}
variables (f f' : X βΆ Y) (h : homotopy f f')
/-- The morphism `hα΅’β±Ό: Xα΅’ βΆ Yβ±Ό` coming from a homotopy between two morphisms of type `X βΆ Y`.
Here `X` and `Y` are complexes of shape `ΞΉ` and the indices `i j` run over `option ΞΉ`. -/
def embed_homotopy_hom : Ξ (i j : option ΞΉ), embed.X X i βΆ embed.X Y j
| (some i) (some j) := h.hom i j
| (some i) none := 0
| none j := 0
@[simp] lemma embed_homotopy_hom_some (i j : ΞΉ) :
embed_homotopy_hom f f' h (some i) (some j) = h.hom i j := rfl
@[simp] lemma embed_homotopy_hom_eq_zero_of_to_none (oi : option ΞΉ) :
embed_homotopy_hom f f' h oi none = 0 := by cases oi; refl
@[simp] lemma embed_homotopy_hom_eq_zero_of_of_none (oi : option ΞΉ) :
embed_homotopy_hom f f' h none oi = 0 := rfl
lemma embed_homotopy_zero : Ξ (oi oj : option ΞΉ)
(H : β (i j : ΞΉ), oi = some i β oj = some j β Β¬ cΞΉ.rel j i),
embed_homotopy_hom f f' h oi oj = 0
| (some i) (some j) H := h.zero i j $ H _ _ rfl rfl
| (some i) none H := rfl
| none j H := rfl
def embed_homotopy (e : cΞΉ.embedding cΞΉ') :
homotopy ((embed e).map f) ((embed e).map f') :=
{ hom := Ξ» i j, embed_homotopy_hom f f' h (e.r i) (e.r j),
zero' := Ξ» i j hij, embed_homotopy_zero f f' h _ _ begin
simp only [e.eq_some],
rintro i' j' rfl rfl h',
exact hij (e.c h')
end,
comm := Ξ» i', begin
by_cases hi : β i : ΞΉ, i' = e.f i,
{ rcases hi with β¨i, rflβ©,
delta embed embed.map embed.obj embed.X embed.d embed.f
embed_homotopy_hom d_next prev_d id_rhs,
dsimp only [add_monoid_hom.mk'_apply],
rw e.r_f i,
dsimp only,
rw h.comm i,
delta d_next prev_d id_rhs,
dsimp only [add_monoid_hom.mk'_apply],
rw add_left_inj,
congr' 1,
{ by_cases aux : β j, cΞΉ.rel i j,
{ rcases aux with β¨j, hjβ©,
rw [cΞΉ.next_eq' hj, cΞΉ'.next_eq' (e.c hj), e.r_f] },
{ push_neg at aux,
induction x : e.r (cΞΉ'.next (e.f i));
simp only [X.shape _ _ (aux _), zero_comp], } },
{ by_cases aux : β j, cΞΉ.rel j i,
{ rcases aux with β¨j, hjβ©,
rw [cΞΉ.prev_eq' hj, cΞΉ'.prev_eq' (e.c hj), e.r_f] },
{ push_neg at aux,
induction x : e.r (cΞΉ'.prev (e.f i));
simp only [Y.shape _ _ (aux _), comp_zero], } } },
{ -- i' not in image
have foo := e.r_none _ hi,
suffices : subsingleton (embed.X X (e.r i') βΆ embed.X Y (e.r i')),
{ refine @subsingleton.elim _ this _ _ },
convert (homological_complex.embed.subsingleton_of_none X _), },
end }
end homotopy
section homology_comparison
def congr_eval (π : Type*) [category π] [preadditive π] (cβ : complex_shape ΞΉβ) (i j : ΞΉβ)
(h : i = j) : eval π cβ i β
eval π cβ j := eq_to_iso (by rw h)
def congr_prev_functor (π : Type*) [category π] [abelian π] (cβ : complex_shape ΞΉβ) (i j : ΞΉβ)
(h : i = j) : prev_functor π cβ i β
prev_functor π cβ j := eq_to_iso (by rw h)
def congr_next_functor (π : Type*) [category π] [abelian π] (cβ : complex_shape ΞΉβ) (i j : ΞΉβ)
(h : i = j) : next_functor π cβ i β
next_functor π cβ j := eq_to_iso (by rw h)
def embed_comp_eval (π : Type*) [category π] [preadditive π] [has_zero_object π]
{cβ : complex_shape ΞΉβ} {cβ : complex_shape ΞΉβ} (e : cβ.embedding cβ) (iβ : ΞΉβ) :
embed e β eval π cβ (e.f iβ) β
eval π cβ iβ :=
nat_iso.of_components
(Ξ» X, embed.X_iso_of_some X (e.r_f iβ))
(Ξ» X Y f, begin
dsimp [embed, embed.map],
rw embed.f_of_some f (e.r_f iβ),
simp only [category.assoc, iso.inv_hom_id, category.comp_id],
end)
/-
def embed_comp_prev_functor (π : Type*) [category π] [abelian π]
{cβ : complex_shape ΞΉβ} {cβ : complex_shape ΞΉβ} (e : cβ.embedding cβ) (he : e.c_iff) (iβ : ΞΉβ) :
embed e β prev_functor π cβ (e.f iβ) β
prev_functor π cβ iβ :=
begin
rcases hβ : cβ.prev iβ with _ | β¨j, hjβ©,
{ apply is_zero.iso,
{ rcases hβ : cβ.prev (e.f iβ) with _ | β¨k, hkβ©,
{ apply functor.is_zero_of_comp,
exact prev_functor_is_zero _ _ _ hβ, },
{ rw is_zero.iff_id_eq_zero,
ext X,
apply is_zero.eq_of_src,
dsimp,
refine is_zero.of_iso _ (((embed e).obj X).X_prev_iso hk),
dsimp [embed, embed.obj],
apply embed.X_is_zero_of_none X,
apply e.r_none,
rintro β¨i, hiβ©,
rw [hi, β he] at hk,
rw cβ.prev_eq_some hk at hβ,
simpa only using hβ, }, },
{ exact prev_functor_is_zero _ _ _ hβ, }, },
{ exact iso_whisker_left (embed e) (prev_functor_iso_eval π cβ (e.f iβ) (e.f j) (e.c hj)) βͺβ«
embed_comp_eval π e j βͺβ«
(prev_functor_iso_eval π cβ iβ j hj).symm, }
end
def embed_comp_next_functor (π : Type*) [category π] [abelian π]
{cβ : complex_shape ΞΉβ} {cβ : complex_shape ΞΉβ} (e : cβ.embedding cβ) (he : e.c_iff) (iβ : ΞΉβ) :
embed e β next_functor π cβ (e.f iβ) β
next_functor π cβ iβ :=
begin
rcases hβ : cβ.next iβ with _ | β¨j, hjβ©,
{ apply is_zero.iso,
{ rcases hβ : cβ.next (e.f iβ) with _ | β¨k, hkβ©,
{ apply functor.is_zero_of_comp,
exact next_functor_is_zero _ _ _ hβ, },
{ rw is_zero.iff_id_eq_zero,
ext X,
apply is_zero.eq_of_src,
dsimp,
refine is_zero.of_iso _ (((embed e).obj X).X_next_iso hk),
dsimp [embed, embed.obj],
apply embed.X_is_zero_of_none X,
apply e.r_none,
rintro β¨i, hiβ©,
rw [hi, β he] at hk,
rw cβ.next_eq_some hk at hβ,
simpa only using hβ,}, },
{ exact next_functor_is_zero _ _ _ hβ, }, },
{ exact iso_whisker_left (embed e) (next_functor_iso_eval π cβ (e.f iβ) (e.f j) (e.c hj)) βͺβ«
embed_comp_eval π e j βͺβ«
(next_functor_iso_eval π cβ iβ j hj).symm }
end
def embed_short_complex_functor_homological_complex_Οβ (π : Type*) [category π] [abelian π]
{cβ : complex_shape ΞΉβ} {cβ : complex_shape ΞΉβ} (e : cβ.embedding cβ) (he : e.c_iff)
(iβ : ΞΉβ) (iβ : ΞΉβ) (hββ : e.f iβ = iβ) :
(embed e β short_complex.functor_homological_complex π cβ iβ) β short_complex.Οβ β
short_complex.functor_homological_complex π cβ iβ β short_complex.Οβ :=
functor.associator _ _ _ βͺβ«
iso_whisker_left (embed e)
(short_complex.functor_homological_complex_Οβ_iso_prev_functor π cβ iβ) βͺβ«
(iso_whisker_left (embed e) (congr_prev_functor π cβ iβ (e.f iβ) hββ.symm)) βͺβ«
embed_comp_prev_functor π e he iβ βͺβ«
(short_complex.functor_homological_complex_Οβ_iso_prev_functor π cβ iβ).symm
def embed_short_complex_functor_homological_complex_Οβ (π : Type*) [category π] [abelian π]
{cβ : complex_shape ΞΉβ} {cβ : complex_shape ΞΉβ} (e : cβ.embedding cβ) (iβ : ΞΉβ) (iβ : ΞΉβ)
(hββ : e.f iβ = iβ) :
(embed e β short_complex.functor_homological_complex π cβ iβ) β short_complex.Οβ β
short_complex.functor_homological_complex π cβ iβ β short_complex.Οβ :=
functor.associator _ _ _ βͺβ«
iso_whisker_left (embed e)
(short_complex.functor_homological_complex_Οβ_iso_eval π cβ iβ) βͺβ«
(iso_whisker_left (embed e) (congr_eval π cβ iβ (e.f iβ) hββ.symm)) βͺβ«
embed_comp_eval π e iβ βͺβ«
(short_complex.functor_homological_complex_Οβ_iso_eval π cβ iβ).symm
def embed_short_complex_functor_homological_complex_Οβ (π : Type*) [category π] [abelian π]
{cβ : complex_shape ΞΉβ} {cβ : complex_shape ΞΉβ} (e : cβ.embedding cβ) (he : e.c_iff)
(iβ : ΞΉβ) (iβ : ΞΉβ) (hββ : e.f iβ = iβ) :
(embed e β short_complex.functor_homological_complex π cβ iβ) β short_complex.Οβ β
short_complex.functor_homological_complex π cβ iβ β short_complex.Οβ :=
functor.associator _ _ _ βͺβ«
iso_whisker_left (embed e)
(short_complex.functor_homological_complex_Οβ_iso_next_functor π cβ iβ) βͺβ«
(iso_whisker_left (embed e) (congr_next_functor π cβ iβ (e.f iβ) hββ.symm)) βͺβ«
embed_comp_next_functor π e he iβ βͺβ«
(short_complex.functor_homological_complex_Οβ_iso_next_functor π cβ iβ).symm
lemma embed_d_to (π : Type*) [category π] [abelian π]
{cβ : complex_shape ΞΉβ} {cβ : complex_shape ΞΉβ} (e : cβ.embedding cβ) (he : e.c_iff)
(iβ : ΞΉβ) (X : homological_complex π cβ) :
((embed e).obj X).d_to (e.f iβ) β« (embed.X_iso_of_some X (e.r_f iβ)).hom =
(embed_comp_prev_functor π e he iβ).hom.app X β« X.d_to iβ :=
begin
dsimp [embed_comp_prev_functor],
rcases hβ : cβ.prev iβ with _ | β¨j, hjβ©,
{ simp only [hβ, d_to_eq_zero, comp_zero, preadditive.is_iso.comp_right_eq_zero],
rcases hβ : cβ.prev (e.f iβ) with _ | β¨k, hkβ©,
{ apply is_zero.eq_of_src,
exact is_zero.of_iso (limits.is_zero_zero _) (((embed e).obj X).X_prev_iso_zero hβ), },
{ simp only [homological_complex.d_to_eq _ hk, preadditive.is_iso.comp_left_eq_zero],
dsimp [embed, embed.obj, embed.d],
rcases hβ : e.r k with _ | l,
{ refl, },
{ rw e.r_f iβ,
dsimp [embed.d],
by_cases hβ : cβ.rel l iβ,
{ exfalso,
simpa only [cβ.prev_eq_some hβ] using hβ, },
{ exact X.shape _ _ hβ, }, }, }, },
{ simp only [hβ, homological_complex.d_to_eq _ hj,
homological_complex.d_to_eq _ (e.c hj)],
conv_lhs { congr, congr, skip, dsimp [embed, embed.obj, embed.d], },
rw embed.d_of_some_of_some X (e.r_f j) (e.r_f iβ),
dsimp [iso_whisker_left, prev_functor_iso_eval, embed_comp_eval, nat_iso.of_components],
simp only [category.assoc, iso.inv_hom_id, category.comp_id, iso.inv_hom_id_assoc], },
end
lemma embed_d_from (π : Type*) [category π] [abelian π]
{cβ : complex_shape ΞΉβ} {cβ : complex_shape ΞΉβ} (e : cβ.embedding cβ) (he : e.c_iff)
(iβ : ΞΉβ) (X : homological_complex π cβ) :
((embed e).obj X).d_from (e.f iβ) β« (embed_comp_next_functor π e he iβ).hom.app X =
(embed.X_iso_of_some X (e.r_f iβ)).hom β« X.d_from iβ :=
begin
dsimp [embed_comp_next_functor],
rcases hβ : cβ.next iβ with _ | β¨j, hjβ©,
{ simp only [hβ, d_from_eq_zero, comp_zero, preadditive.is_iso.comp_right_eq_zero],
rcases hβ : cβ.next (e.f iβ) with _ | β¨k, hkβ©,
{ apply is_zero.eq_of_tgt,
exact is_zero.of_iso (limits.is_zero_zero _) (((embed e).obj X).X_next_iso_zero hβ), },
{ simp only [homological_complex.d_from_eq _ hk, preadditive.is_iso.comp_right_eq_zero],
dsimp [embed, embed.obj, embed.d],
rcases hβ : e.r k with _ | l,
{ exact embed.d_of_none_tgt X rfl, },
{ rw e.r_f iβ,
dsimp [embed.d],
by_cases hβ : cβ.rel iβ l,
{ exfalso,
simpa only [cβ.next_eq_some hβ] using hβ, },
{ exact X.shape _ _ hβ, }, }, }, },
{ simp only [hβ, homological_complex.d_from_eq _ hj,
homological_complex.d_from_eq _ (e.c hj)],
conv_lhs { congr, congr, dsimp [embed, embed.obj, embed.d], },
rw embed.d_of_some_of_some X (e.r_f iβ) (e.r_f j),
dsimp [iso_whisker_left, next_functor_iso_eval, embed_comp_eval, nat_iso.of_components],
simp only [category.assoc, eq_to_hom_trans, eq_to_hom_refl, category.comp_id,
iso.inv_hom_id_assoc], },
end
def embed_short_complex_functor_homological_complex (π : Type*) [category π] [abelian π]
{cβ : complex_shape ΞΉβ} {cβ : complex_shape ΞΉβ} (e : cβ.embedding cβ) (he : e.c_iff)
(iβ : ΞΉβ) (iβ : ΞΉβ) (hββ : e.f iβ = iβ) :
embed e β short_complex.functor_homological_complex π cβ iβ β
short_complex.functor_homological_complex π cβ iβ :=
begin
refine short_complex.functor_nat_iso_mk
(embed_short_complex_functor_homological_complex_Οβ π e he iβ iβ hββ)
(embed_short_complex_functor_homological_complex_Οβ π e iβ iβ hββ)
(embed_short_complex_functor_homological_complex_Οβ π e he iβ iβ hββ) _ _,
{ subst hββ,
ext X,
dsimp [nat_trans.hcomp, embed_short_complex_functor_homological_complex_Οβ,
short_complex.functor_homological_complex_Οβ_iso_eval,
embed_short_complex_functor_homological_complex_Οβ, congr_eval,
congr_prev_functor, embed_comp_eval, iso.refl,
short_complex.functor_homological_complex_Οβ_iso_prev_functor],
simp only [category.assoc],
erw [nat_trans.id_app, nat_trans.id_app],
repeat { erw category.id_comp, },
repeat { erw category.comp_id, },
apply embed_d_to, },
{ subst hββ,
ext X,
dsimp [nat_trans.hcomp, embed_short_complex_functor_homological_complex_Οβ,
short_complex.functor_homological_complex_Οβ_iso_eval,
embed_short_complex_functor_homological_complex_Οβ, congr_eval,
congr_prev_functor, embed_comp_eval, iso.refl,
short_complex.functor_homological_complex_Οβ_iso_next_functor],
simp only [category.assoc],
erw [nat_trans.id_app, nat_trans.id_app],
repeat { erw category.id_comp, },
repeat { erw category.comp_id, },
apply embed_d_from, },
end
-/
variables (π : Type*) [category π] [abelian π] (e : cβ.embedding cβ)
(iβ : ΞΉβ) (iβ : ΞΉβ)
@[simp]
def embed_short_complex_Οβ_ΞΉ :
embed e β short_complex.functor_homological_complex π cβ iβ β short_complex.Οβ βΆ
short_complex.functor_homological_complex π cβ iβ β short_complex.Οβ :=
begin
by_cases e.r (cβ.prev iβ) = some (cβ.prev iβ),
{ exact (embed_eval_iso_of_some e _ _ h).hom, },
{ exact 0, },
end
@[simp]
def embed_short_complex_Οβ_iso (hββ : e.f iβ = iβ) :
embed e β short_complex.functor_homological_complex π cβ iβ β short_complex.Οβ β
short_complex.functor_homological_complex π cβ iβ β short_complex.Οβ :=
embed_eval_iso_of_some e iβ iβ (by { rw [β hββ, e.r_f],})
@[simp]
def embed_short_complex_Οβ_ΞΉ :
embed e β short_complex.functor_homological_complex π cβ iβ β short_complex.Οβ βΆ
short_complex.functor_homological_complex π cβ iβ β short_complex.Οβ :=
begin
by_cases e.r (cβ.next iβ) = some (cβ.next iβ),
{ exact (embed_eval_iso_of_some e _ _ h).hom, },
{ exact 0, },
end
-- @[simps]
def embed_short_complex_ΞΉ (hββ : e.f iβ = iβ) :
embed e β short_complex.functor_homological_complex π cβ iβ βΆ
short_complex.functor_homological_complex π cβ iβ :=
short_complex.nat_trans_hom_mk
(embed_short_complex_Οβ_ΞΉ π e _ _)
(embed_short_complex_Οβ_iso π e _ _ hββ).hom
(embed_short_complex_Οβ_ΞΉ π e _ _)
begin
ext X,
subst hββ,
show (((embed e).obj X).d_to (e.f iβ) β« π (((embed e).obj X).X (e.f iβ))) β« (embed.X_iso_of_some X _).hom =
(embed_short_complex_Οβ_ΞΉ π e iβ (e.f iβ)).app X β« X.d_to iβ β« π (X.X iβ),
simp only [embed_short_complex_Οβ_ΞΉ, category.comp_id],
split_ifs with h,
{ show embed.d X (e.r (cβ.prev (e.f iβ))) (e.r (e.f iβ)) β« (embed.X_iso_of_some X _).hom =
(embed.X_iso_of_some X h).hom β« X.d (cβ.prev iβ) iβ,
simp only [embed.d_of_some_of_some X h (e.r_f iβ),
category.assoc, iso.inv_hom_id, category.comp_id], },
{ suffices : ((embed e).obj X).d_to (e.f iβ) = 0,
{ simp only [this, nat_trans.app_zero, zero_comp], },
rcases hβ : e.r (cβ.prev (e.f iβ)) with _ | j,
{ apply is_zero.eq_of_src,
apply embed.X_is_zero_of_none,
exact hβ, },
{ show embed.d X (e.r (cβ.prev (e.f iβ))) (e.r (e.f iβ)) = 0,
by_contra h',
rcases embed.d_ne_zero _ _ _ h' with β¨i, k, hβ, hβ, hβ
β©,
rw e.r_f at hβ,
rw hβ at hβ,
simp only at hβ hβ,
substs hβ hβ,
have hβ
' : cβ.rel j iβ,
{ by_contra hβ
'',
exact hβ
(X.shape _ _ hβ
''), },
rw cβ.prev_eq' hβ
' at h,
exact h hβ, }, },
end
begin
ext X,
show (((embed e).obj X).d_from iβ β« π (((embed e).obj X).X_next iβ)) β« _ =
(embed.X_iso_of_some X _).hom β« X.d_from iβ β« π (X.X_next iβ),
dsimp only [embed_short_complex_Οβ_ΞΉ],
subst hββ,
split_ifs with h,
{ simp only [category.comp_id],
show embed.d X (e.r (e.f iβ)) (e.r (cβ.next (e.f iβ))) β« (embed.X_iso_of_some X h).hom =
(embed.X_iso_of_some X _).hom β« X.d_from iβ,
simp only [embed.d_of_some_of_some X (e.r_f iβ) h,
category.assoc, iso.inv_hom_id, category.comp_id], },
{ suffices : X.d iβ (cβ.next iβ) = 0,
{ delta d_from, simp only [this, zero_comp, comp_zero, nat_trans.app_zero], },
apply X.shape,
rw e.eq_some at h,
contrapose! h,
rw cβ.next_eq' (e.c h) },
end
.
@[simp]
def embed_short_complex_Οβ_Ο :
short_complex.functor_homological_complex π cβ iβ β short_complex.Οβ βΆ
embed e β short_complex.functor_homological_complex π cβ iβ β short_complex.Οβ :=
begin
by_cases e.r (cβ.prev iβ) = some (cβ.prev iβ),
{ exact (embed_eval_iso_of_some e _ _ h).inv, },
{ exact 0, },
end
@[simp]
def embed_short_complex_Οβ_Ο :
short_complex.functor_homological_complex π cβ iβ β short_complex.Οβ βΆ
embed e β short_complex.functor_homological_complex π cβ iβ β short_complex.Οβ :=
begin
by_cases e.r (cβ.next iβ) = some (cβ.next iβ),
{ exact (embed_eval_iso_of_some e _ _ h).inv, },
{ exact 0, },
end
@[simps]
def embed_short_complex_Ο (hββ : e.f iβ = iβ) :
short_complex.functor_homological_complex π cβ iβ βΆ
embed e β short_complex.functor_homological_complex π cβ iβ :=
short_complex.nat_trans_hom_mk
(embed_short_complex_Οβ_Ο π e _ _)
(embed_short_complex_Οβ_iso π e _ _ hββ).inv
(embed_short_complex_Οβ_Ο π e _ _)
begin
ext X,
show (X.d_to iβ β« π (X.X iβ)) β« (embed.X_iso_of_some X _).inv =
_ β« ((embed e).obj X).d_to iβ β« π (((embed e).obj X).X iβ),
dsimp only [embed_short_complex_Οβ_Ο],
subst hββ,
split_ifs with h,
{ simp only [category.comp_id],
show X.d (cβ.prev iβ) iβ β« (embed.X_iso_of_some X _).inv =
(embed.X_iso_of_some X h).inv β« embed.d X (e.r (cβ.prev (e.f iβ))) (e.r (e.f iβ)),
simp only [embed.d_of_some_of_some X h (e.r_f iβ), category.assoc, iso.inv_hom_id_assoc], },
{ suffices : X.d (cβ.prev iβ) iβ = 0,
{ delta d_to, simp only [this, zero_comp, nat_trans.app_zero], },
apply X.shape,
rw e.eq_some at h,
contrapose! h,
rw cβ.prev_eq' (e.c h) },
end
begin
ext X,
show (X.d_from iβ β« π (X.X_next iβ)) β« _ =
(embed.X_iso_of_some X _).inv β« ((embed e).obj X).d_from iβ β« π (((embed e).obj X).X_next iβ),
dsimp only [embed_short_complex_Οβ_Ο],
subst hββ,
split_ifs with h,
{ simp only [category.comp_id],
show X.d iβ (cβ.next iβ) β« (embed.X_iso_of_some X h).inv =
(embed.X_iso_of_some X _).inv β« embed.d X (e.r (e.f iβ)) (e.r (cβ.next (e.f iβ))),
simp only [embed.d_of_some_of_some X (e.r_f iβ) h, category.assoc, iso.inv_hom_id_assoc], },
{ suffices : ((embed e).obj X).d_from (e.f iβ) = 0,
{ simp only [this, nat_trans.app_zero, zero_comp, comp_zero], },
rcases hβ : e.r (cβ.next (e.f iβ)) with _ | j,
{ apply is_zero.eq_of_tgt,
apply embed.X_is_zero_of_none,
exact hβ, },
{ show embed.d X (e.r (e.f iβ)) (e.r (cβ.next (e.f iβ))) = 0,
by_contra h',
rcases embed.d_ne_zero _ _ _ h' with β¨i, k, hβ, hβ, hβ
β©,
rw e.r_f at hβ,
rw hβ at hβ,
simp only at hβ hβ,
substs hβ hβ,
have hβ
' : cβ.rel iβ j,
{ by_contra hβ
'',
exact hβ
(X.shape _ _ hβ
''), },
rw cβ.next_eq' hβ
' at h,
exact h hβ, }, },
end
def homology_embed_nat_iso (hββ : e.f iβ = iβ) :
embed e β homology_functor π cβ iβ β
homology_functor π cβ iβ :=
{ hom := embed_short_complex_ΞΉ π e iβ iβ hββ β« (π short_complex.homology_functor),
inv := embed_short_complex_Ο π e iβ iβ hββ β« (π short_complex.homology_functor),
hom_inv_id' := begin
ext K : 2,
simp only [nat_trans.comp_app, nat_trans.hcomp_id_app, nat_trans.id_app,
β functor.map_comp],
apply short_complex.homology_functor_map_eq_id,
simp only [short_complex.comp_Οβ],
dsimp only [embed_short_complex_ΞΉ, embed_short_complex_Ο],
simpa only [short_complex.nat_trans_hom_mk_app_Οβ_eq,
iso.hom_inv_id_app],
end,
inv_hom_id' := begin
ext K : 2,
simp only [nat_trans.comp_app, nat_trans.hcomp_id_app, nat_trans.id_app,
β functor.map_comp],
apply short_complex.homology_functor_map_eq_id,
simp only [short_complex.comp_Οβ],
dsimp only [embed_short_complex_ΞΉ, embed_short_complex_Ο],
simpa only [short_complex.nat_trans_hom_mk_app_Οβ_eq,
iso.inv_hom_id_app],
end, }
end homology_comparison
end homological_complex
namespace chain_complex
def singleβ_comp_embed_iso_single_component (X : π) : Ξ (i : β€),
((singleβ π β homological_complex.embed complex_shape.embedding.nat_down_int_up).obj X).X i β
((homological_complex.single π (complex_shape.up β€) 0).obj X).X i
| 0 := iso.refl _
| (n+1:β) := iso.refl _
| -[1+n] := iso.refl _
def singleβ_comp_embed_iso_single :
singleβ π β homological_complex.embed complex_shape.embedding.nat_down_int_up β
homological_complex.single π (complex_shape.up β€) 0 :=
nat_iso.of_components
(Ξ» X, homological_complex.hom.iso_of_components
(singleβ_comp_embed_iso_single_component X)
(by rintro ((_|i)|i) ((_|j)|j) hij; exact comp_zero.trans zero_comp.symm))
begin
intros X Y f,
ext ((_|i)|i);
refine (category.comp_id _).trans (eq.trans _ (category.id_comp _).symm);
dsimp [homological_complex.single],
{ simp only [eq_self_iff_true, category.comp_id, category.id_comp, if_true, nat.cast_zero], refl },
{ rw dif_neg, swap, dec_trivial, refl },
{ rw dif_neg, swap, dec_trivial }
end
end chain_complex