File size: 19,964 Bytes
4a56cd6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
/-
Copyright 2026 The Formal Conjectures Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
This file has been modified.
-/
import OAI.AlgebraicTopology.Singular.ExcisionCoverSmall
import Mathlib.Algebra.Category.ModuleCat.Colimits
import OAI.AlgebraicTopology.Singular.ExcisionOpenCover

/-! # Chains -/

namespace OAI.AlgebraicGeometry.ComplexMultiplication.Coefficient.Chains.SingularCoefficients

noncomputable section

/-!
# Small singular chains with coefficient coefficients

This file transports the integral subdivision homotopy to coefficient simplicial chains. The
transport is constructed directly from the universal bases of the two simplicial chain
complexes. In particular, it does not assume a universal-coefficient theorem.
-/

open _root_.CategoryTheory _root_.CategoryTheory.Limits
open scoped Simplicial

variable (K : Type) [Field K]

@[simp]
lemma integralCoefficient_one :
    (AddCommGrpCat.ofHom (Int.castAddHom K)).hom (1 : ℤ) = (1 : K) :=
  Int.cast_one

/-- Coefficient chains on a simplicial set. -/
abbrev CoefficientSimplicialChainComplex (X : SSet.{0}) :
    ChainComplex (ModuleCat K) ℕ :=
  X.chainComplex (ModuleCat.of K K)

@[simp]
lemma moduleCat_toSpanSingleton_apply_one (M : ModuleCat K) (v : M) :
    (ModuleCat.ofHom (LinearMap.toSpanSingleton K M v)).hom 1 = v := by simp

/-- The coefficient map from integral to coefficient chains in one degree. -/
def integralToCoefficientChainComponent (X : SSet.{0}) (n : ℕ) :
    (X.chainComplex (AddCommGrpCat.of ℤ)).X n ⟶
      (forget₂ (ModuleCat K) AddCommGrpCat).obj ((CoefficientSimplicialChainComplex K X).X n) :=
  (X.isColimitChainComplexXCofan (AddCommGrpCat.of ℤ) n).desc
    (Cofan.mk _ fun x ↦
      AddCommGrpCat.ofHom (Int.castAddHom K) ≫
        (forget₂ (ModuleCat K) AddCommGrpCat).map (X.ιChainComplex (R := ModuleCat.of K K) x))

@[reassoc]
lemma iota_integralToCoefficientChainComponent (X : SSet.{0}) (n : ℕ)
    (x : X _⦋n⦌) :
    X.ιChainComplex (R := AddCommGrpCat.of ℤ) x ≫
        integralToCoefficientChainComponent K X n =
      AddCommGrpCat.ofHom (Int.castAddHom K) ≫
        (forget₂ (ModuleCat K) AddCommGrpCat).map (X.ιChainComplex (R := ModuleCat.of K K) x) :=
  (X.isColimitChainComplexXCofan (AddCommGrpCat.of ℤ) n).fac _ (Discrete.mk x)

/-- Extend an integral map between free simplicial-chain groups coefficient-linearly. -/
def coefficientizeSimplicialChainComponent (X Y : SSet.{0}) (n m : ℕ)
    (f : (X.chainComplex (AddCommGrpCat.of ℤ)).X n ⟶
      (Y.chainComplex (AddCommGrpCat.of ℤ)).X m) :
    (CoefficientSimplicialChainComplex K X).X n ⟶
      (CoefficientSimplicialChainComplex K Y).X m :=
  (X.isColimitChainComplexXCofan (ModuleCat.of K K) n).desc
    (Cofan.mk _ fun x ↦ ModuleCat.ofHom <|
      LinearMap.toSpanSingleton K _ <|
        (show (CoefficientSimplicialChainComplex K Y).X m from
          (integralToCoefficientChainComponent K Y m).hom
            (f.hom ((X.ιChainComplex (R := AddCommGrpCat.of ℤ) x).hom 1))))

@[reassoc]
lemma iota_coefficientizeSimplicialChainComponent
    (X Y : SSet.{0}) (n m : ℕ)
    (f : (X.chainComplex (AddCommGrpCat.of ℤ)).X n ⟶
      (Y.chainComplex (AddCommGrpCat.of ℤ)).X m)
    (x : X _⦋n⦌) :
    X.ιChainComplex (R := ModuleCat.of K K) x ≫
        coefficientizeSimplicialChainComponent K X Y n m f =
      ModuleCat.ofHom (LinearMap.toSpanSingleton K _ <|
        (show (CoefficientSimplicialChainComplex K Y).X m from
          (integralToCoefficientChainComponent K Y m).hom
            (f.hom ((X.ιChainComplex (R := AddCommGrpCat.of ℤ) x).hom 1)))) :=
  (X.isColimitChainComplexXCofan (ModuleCat.of K K) n).fac _ (Discrete.mk x)

lemma integralToCoefficientChainComponent_naturality
    (X Y : SSet.{0}) (n m : ℕ)
    (f : (X.chainComplex (AddCommGrpCat.of ℤ)).X n ⟶
      (Y.chainComplex (AddCommGrpCat.of ℤ)).X m) :
    integralToCoefficientChainComponent K X n ≫
        (forget₂ (ModuleCat K) AddCommGrpCat).map (coefficientizeSimplicialChainComponent K X Y n m f) =
      f ≫ integralToCoefficientChainComponent K Y m := by
  refine (X.isColimitChainComplexXCofan (AddCommGrpCat.of ℤ) n).hom_ext fun x ↦ ?_
  change X.ιChainComplex (R := AddCommGrpCat.of ℤ) x.as ≫
      (integralToCoefficientChainComponent K X n ≫
        (forget₂ (ModuleCat K) AddCommGrpCat).map (coefficientizeSimplicialChainComponent K X Y n m f)) =
    X.ιChainComplex (R := AddCommGrpCat.of ℤ) x.as ≫
      (f ≫ integralToCoefficientChainComponent K Y m)
  apply AddCommGrpCat.int_hom_ext
  have hx := ConcreteCategory.congr_hom
    (iota_integralToCoefficientChainComponent K X n x.as) 1
  have hf := ConcreteCategory.congr_hom
    (iota_coefficientizeSimplicialChainComponent K X Y n m f x.as) 1
  change (coefficientizeSimplicialChainComponent K X Y n m f).hom
      ((integralToCoefficientChainComponent K X n).hom
        ((X.ιChainComplex (R := AddCommGrpCat.of ℤ) x.as).hom 1)) = _
  simp only [ConcreteCategory.comp_apply, integralCoefficient_one K] at hx
  change (integralToCoefficientChainComponent K X n).hom
      ((X.ιChainComplex (R := AddCommGrpCat.of ℤ) x.as).hom 1) =
    (X.ιChainComplex (R := ModuleCat.of K K) x.as).hom 1 at hx
  rw [hx]
  simpa using hf

lemma coefficientizeSimplicialChainComponent_comp
    (X Y Z : SSet.{0}) (n m k : ℕ)
    (f : (X.chainComplex (AddCommGrpCat.of ℤ)).X n ⟶
      (Y.chainComplex (AddCommGrpCat.of ℤ)).X m)
    (g : (Y.chainComplex (AddCommGrpCat.of ℤ)).X m ⟶
      (Z.chainComplex (AddCommGrpCat.of ℤ)).X k) :
    coefficientizeSimplicialChainComponent K X Z n k (f ≫ g) =
      coefficientizeSimplicialChainComponent K X Y n m f ≫
        coefficientizeSimplicialChainComponent K Y Z m k g := by
  refine SSet.chainComplex_hom_ext fun x ↦ ?_
  rw [iota_coefficientizeSimplicialChainComponent K,
    iota_coefficientizeSimplicialChainComponent_assoc]
  ext
  have h := ConcreteCategory.congr_hom
    (integralToCoefficientChainComponent_naturality K Y Z m k g)
    (f.hom ((X.ιChainComplex (R := AddCommGrpCat.of ℤ) x).hom 1))
  simpa using h.symm

lemma coefficientizeSimplicialChainComponent_id (X : SSet.{0}) (n : ℕ) :
    coefficientizeSimplicialChainComponent K X X n n (𝟙 _) = 𝟙 _ := by
  refine SSet.chainComplex_hom_ext fun x ↦ ?_
  rw [iota_coefficientizeSimplicialChainComponent K]
  ext
  have hx := ConcreteCategory.congr_hom
    (iota_integralToCoefficientChainComponent K X n x) 1
  simpa using hx

lemma coefficientizeSimplicialChainComponent_zero
    (X Y : SSet.{0}) (n m : ℕ) :
    coefficientizeSimplicialChainComponent K X Y n m 0 = 0 := by
  refine SSet.chainComplex_hom_ext fun x ↦ ?_
  rw [iota_coefficientizeSimplicialChainComponent K]
  simp

lemma coefficientizeSimplicialChainComponent_add
    (X Y : SSet.{0}) (n m : ℕ)
    (f g : (X.chainComplex (AddCommGrpCat.of ℤ)).X n ⟶
      (Y.chainComplex (AddCommGrpCat.of ℤ)).X m) :
    coefficientizeSimplicialChainComponent K X Y n m (f + g) =
      coefficientizeSimplicialChainComponent K X Y n m f +
        coefficientizeSimplicialChainComponent K X Y n m g := by
  refine SSet.chainComplex_hom_ext fun x ↦ ?_
  rw [iota_coefficientizeSimplicialChainComponent K, Preadditive.comp_add,
    iota_coefficientizeSimplicialChainComponent K,
    iota_coefficientizeSimplicialChainComponent K]
  ext
  simp

lemma coefficientizeSimplicialChainComponent_neg
    (X Y : SSet.{0}) (n m : ℕ)
    (f : (X.chainComplex (AddCommGrpCat.of ℤ)).X n ⟶
      (Y.chainComplex (AddCommGrpCat.of ℤ)).X m) :
    coefficientizeSimplicialChainComponent K X Y n m (-f) =
      -coefficientizeSimplicialChainComponent K X Y n m f := by
  refine SSet.chainComplex_hom_ext fun x ↦ ?_
  rw [iota_coefficientizeSimplicialChainComponent K, Preadditive.comp_neg,
    iota_coefficientizeSimplicialChainComponent K]
  ext
  simp

/-- The integral-to-coefficient coefficient map commutes with the simplicial differential. -/
lemma integralToCoefficientChainComponent_comm_d (X : SSet.{0}) (n : ℕ) :
    integralToCoefficientChainComponent K X (n + 1) ≫
        (forget₂ (ModuleCat K) AddCommGrpCat).map
          ((CoefficientSimplicialChainComplex K X).d (n + 1) n) =
      (X.chainComplex (AddCommGrpCat.of ℤ)).d (n + 1) n ≫
        integralToCoefficientChainComponent K X n := by
  refine (X.isColimitChainComplexXCofan (AddCommGrpCat.of ℤ) (n + 1)).hom_ext fun x ↦ ?_
  change X.ιChainComplex (R := AddCommGrpCat.of ℤ) x.as ≫
      (integralToCoefficientChainComponent K X (n + 1) ≫
        (forget₂ (ModuleCat K) AddCommGrpCat).map
          ((CoefficientSimplicialChainComplex K X).d (n + 1) n)) =
    X.ιChainComplex (R := AddCommGrpCat.of ℤ) x.as ≫
      ((X.chainComplex (AddCommGrpCat.of ℤ)).d (n + 1) n ≫
        integralToCoefficientChainComponent K X n)
  rw [← Category.assoc, iota_integralToCoefficientChainComponent K, Category.assoc,
    ← Functor.map_comp, SSet.ιChainComplex_d, ← Category.assoc, SSet.ιChainComplex_d,
    Preadditive.sum_comp]
  simp_rw [Preadditive.zsmul_comp, iota_integralToCoefficientChainComponent K]
  simp only [Functor.map_sum, Functor.map_zsmul]
  rw [Preadditive.comp_sum]
  refine Finset.sum_congr rfl fun i _ ↦ ?_
  rw [Preadditive.comp_zsmul]

/-- Coefficientization sends the integral simplicial differential to the coefficient differential. -/
lemma coefficientizeSimplicialChainComponent_d (X : SSet.{0}) (n : ℕ) :
    coefficientizeSimplicialChainComponent K X X (n + 1) n
        ((X.chainComplex (AddCommGrpCat.of ℤ)).d (n + 1) n) =
      (CoefficientSimplicialChainComplex K X).d (n + 1) n := by
  refine SSet.chainComplex_hom_ext fun x ↦ ?_
  rw [iota_coefficientizeSimplicialChainComponent K]
  ext
  change (LinearMap.toSpanSingleton K _ _) 1 = _
  rw [LinearMap.toSpanSingleton_apply_one]
  have h := ConcreteCategory.congr_hom
    (integralToCoefficientChainComponent_comm_d K X n)
    ((X.ιChainComplex (R := AddCommGrpCat.of ℤ) x).hom 1)
  have hx := ConcreteCategory.congr_hom
    (iota_integralToCoefficientChainComponent K X (n + 1) x) 1
  simp only [ConcreteCategory.comp_apply, integralCoefficient_one K] at h hx ⊢
  rw [hx] at h
  exact h.symm

/-- Coefficientization of a chain map between integral simplicial chains. -/
def coefficientizeSimplicialChainMap (X Y : SSet.{0})
    (f : X.chainComplex (AddCommGrpCat.of ℤ) ⟶
      Y.chainComplex (AddCommGrpCat.of ℤ)) :
    CoefficientSimplicialChainComplex K X ⟶ CoefficientSimplicialChainComplex K Y where
  f n := coefficientizeSimplicialChainComponent K X Y n n (f.f n)
  comm' i j hij := by
    simp only [ComplexShape.down_Rel] at hij
    subst i
    rw [← coefficientizeSimplicialChainComponent_d K Y j,
      ← coefficientizeSimplicialChainComponent_comp K, f.comm,
      coefficientizeSimplicialChainComponent_comp K,
      coefficientizeSimplicialChainComponent_d K]

@[simp]
lemma coefficientizeSimplicialChainMap_f (X Y : SSet.{0})
    (f : X.chainComplex (AddCommGrpCat.of ℤ) ⟶
      Y.chainComplex (AddCommGrpCat.of ℤ)) (n : ℕ) :
    (coefficientizeSimplicialChainMap K X Y f).f n =
      coefficientizeSimplicialChainComponent K X Y n n (f.f n) :=
  rfl

lemma coefficientizeSimplicialChainMap_id (X : SSet.{0}) :
    coefficientizeSimplicialChainMap K X X (𝟙 _) = 𝟙 _ :=
  HomologicalComplex.hom_ext _ _ fun n ↦ coefficientizeSimplicialChainComponent_id K X n

lemma coefficientizeSimplicialChainMap_comp (X Y Z : SSet.{0})
    (f : X.chainComplex (AddCommGrpCat.of ℤ) ⟶
      Y.chainComplex (AddCommGrpCat.of ℤ))
    (g : Y.chainComplex (AddCommGrpCat.of ℤ) ⟶
      Z.chainComplex (AddCommGrpCat.of ℤ)) :
    coefficientizeSimplicialChainMap K X Z (f ≫ g) =
      coefficientizeSimplicialChainMap K X Y f ≫
        coefficientizeSimplicialChainMap K Y Z g :=
  HomologicalComplex.hom_ext _ _ fun n ↦
    coefficientizeSimplicialChainComponent_comp K X Y Z n n n (f.f n) (g.f n)

lemma coefficientizeSimplicialChainMap_zero (X Y : SSet.{0}) :
    coefficientizeSimplicialChainMap K X Y 0 = 0 :=
  HomologicalComplex.hom_ext _ _ fun n ↦
    coefficientizeSimplicialChainComponent_zero K X Y n n

/-- Coefficientization preserves a chain homotopy between integral simplicial chain maps. -/
def coefficientizeSimplicialChainHomotopy (X Y : SSet.{0})
    {f g : X.chainComplex (AddCommGrpCat.of ℤ) ⟶
      Y.chainComplex (AddCommGrpCat.of ℤ)} (h : Homotopy f g) :
    Homotopy (coefficientizeSimplicialChainMap K X Y f)
      (coefficientizeSimplicialChainMap K X Y g) where
  hom i j := coefficientizeSimplicialChainComponent K X Y i j (h.hom i j)
  zero i j hij := by
    rw [h.zero i j hij, coefficientizeSimplicialChainComponent_zero K]
  comm i := by
    cases i with
    | zero =>
        have hh := congrArg
          (coefficientizeSimplicialChainComponent K X Y 0 0) (h.comm 0)
        rw [Homotopy.dNext_zero_chainComplex,
          Homotopy.prevD_chainComplex] at hh ⊢
        simp only [coefficientizeSimplicialChainComponent_add K,
          coefficientizeSimplicialChainComponent_comp K,
          coefficientizeSimplicialChainComponent_d K, zero_add] at hh
        change coefficientizeSimplicialChainComponent K X Y 0 0 (f.f 0) =
          0 + coefficientizeSimplicialChainComponent K X Y 0 1 (h.hom 0 1) ≫
            (CoefficientSimplicialChainComplex K Y).d 1 0 +
              coefficientizeSimplicialChainComponent K X Y 0 0 (g.f 0)
        simpa only [zero_add] using hh
    | succ n =>
        have hh := congrArg
          (coefficientizeSimplicialChainComponent K X Y (n + 1) (n + 1))
            (h.comm (n + 1))
        rw [Homotopy.dNext_succ_chainComplex,
          Homotopy.prevD_chainComplex] at hh ⊢
        simp only [coefficientizeSimplicialChainComponent_add K,
          coefficientizeSimplicialChainComponent_comp K,
          coefficientizeSimplicialChainComponent_d K] at hh
        exact hh

/-- Coefficientization preserves a chain-homotopy equivalence of simplicial chain complexes. -/
def coefficientizeSimplicialChainHomotopyEquiv (X Y : SSet.{0})
    (e : HomotopyEquiv (X.chainComplex (AddCommGrpCat.of ℤ))
      (Y.chainComplex (AddCommGrpCat.of ℤ))) :
    HomotopyEquiv (CoefficientSimplicialChainComplex K X)
      (CoefficientSimplicialChainComplex K Y) where
  hom := coefficientizeSimplicialChainMap K X Y e.hom
  inv := coefficientizeSimplicialChainMap K Y X e.inv
  homotopyHomInvId :=
    (Homotopy.ofEq (coefficientizeSimplicialChainMap_comp K X Y X e.hom e.inv).symm).trans
      ((coefficientizeSimplicialChainHomotopy K X X e.homotopyHomInvId).trans
        (Homotopy.ofEq (coefficientizeSimplicialChainMap_id K X)))
  homotopyInvHomId :=
    (Homotopy.ofEq (coefficientizeSimplicialChainMap_comp K Y X Y e.inv e.hom).symm).trans
      ((coefficientizeSimplicialChainHomotopy K Y Y e.homotopyInvHomId).trans
        (Homotopy.ofEq (coefficientizeSimplicialChainMap_id K Y)))

/-- Coefficientization of an integral chain map induced by a simplicial map is the corresponding
coefficient chain map. -/
lemma coefficientizeSimplicialChainComponent_chainComplexMap
    {X Y : SSet.{0}} (f : X ⟶ Y) (n : ℕ) :
    coefficientizeSimplicialChainComponent K X Y n n
        ((SSet.chainComplexMap f (AddCommGrpCat.of ℤ)).f n) =
      (SSet.chainComplexMap f (ModuleCat.of K K)).f n := by
  refine SSet.chainComplex_hom_ext fun x ↦ ?_
  rw [iota_coefficientizeSimplicialChainComponent K,
    SSet.ι_chainComplexMap_f]
  ext
  change (LinearMap.toSpanSingleton K _ _) 1 = _
  rw [LinearMap.toSpanSingleton_apply_one]
  have hf := ConcreteCategory.congr_hom
    (SSet.ι_chainComplexMap_f X Y f (AddCommGrpCat.of ℤ) x) 1
  have hcoeff := ConcreteCategory.congr_hom
    (iota_integralToCoefficientChainComponent K Y n (f.app _ x)) 1
  simp only [ConcreteCategory.comp_apply, integralCoefficient_one K] at hf hcoeff
  rw [hf]
  exact hcoeff

lemma coefficientizeSimplicialChainMap_chainComplexMap
    {X Y : SSet.{0}} (f : X ⟶ Y) :
    coefficientizeSimplicialChainMap K X Y
        (SSet.chainComplexMap f (AddCommGrpCat.of ℤ)) =
      SSet.chainComplexMap f (ModuleCat.of K K) :=
  HomologicalComplex.hom_ext _ _ fun n ↦
    coefficientizeSimplicialChainComponent_chainComplexMap K f n

variable {ι : Type} (X : TopCat.{0}) (U : ι → Set X)

/-- Coefficient chains generated by singular simplices subordinate to one member of a cover. -/
abbrev CoverSmallCoefficientSingularChainComplex :
    ChainComplex (ModuleCat K) ℕ :=
  (AlgebraicTopology.Singular.ExcisionCoverSmall.coverSmallSingularSubcomplex X U : SSet).chainComplex (ModuleCat.of K K)

/-- Inclusion of cover-small coefficient singular chains into all coefficient singular chains. -/
def coverSmallCoefficientSingularChainInclusion :
    CoverSmallCoefficientSingularChainComplex K X U ⟶
      (TopCat.toSSet.obj X).chainComplex (ModuleCat.of K K) :=
  SSet.chainComplexMap (AlgebraicTopology.Singular.ExcisionCoverSmall.coverSmallSingularSubcomplex X U).ι (ModuleCat.of K K)

instance coverSmallCoefficientSingularChainInclusion_mono :
    Mono (coverSmallCoefficientSingularChainInclusion K X U) := by
  dsimp [coverSmallCoefficientSingularChainInclusion, SSet.chainComplexMap,
    SSet.chainComplexFunctor]
  apply +allowSynthFailures Functor.map_mono

/-- The integral subdivision-and-prism homotopy transported to field coefficients: the
all-open-cover small-chain theorem over `K`. -/
theorem coverSmallCoefficientChainApproximation_of_openCover
    (hUopen : ∀ i, IsOpen (U i)) (hUcover : ⋃ i, U i = Set.univ) :
    HomologicalComplex.homotopyEquivalences (ModuleCat K) (ComplexShape.down ℕ)
      (coverSmallCoefficientSingularChainInclusion K X U) := by
  let eZ := AlgebraicTopology.Singular.ExcisionOpenCover.coverSmallChainHomotopyEquiv_of_openCover X U hUopen hUcover
  refine ⟨coefficientizeSimplicialChainHomotopyEquiv K
    (AlgebraicTopology.Singular.ExcisionCoverSmall.coverSmallSingularSubcomplex X U : SSet) (TopCat.toSSet.obj X) eZ, ?_⟩
  change coefficientizeSimplicialChainMap K
      (AlgebraicTopology.Singular.ExcisionCoverSmall.coverSmallSingularSubcomplex X U : SSet) (TopCat.toSSet.obj X) eZ.hom =
    coverSmallCoefficientSingularChainInclusion K X U
  rw [show eZ.hom = AlgebraicTopology.Singular.ExcisionCoverSmall.coverSmallIntegralSingularChainInclusion X U from
    AlgebraicTopology.Singular.ExcisionOpenCover.coverSmallChainHomotopyEquiv_of_openCover_hom X U hUopen hUcover]
  exact coefficientizeSimplicialChainMap_chainComplexMap K
    (AlgebraicTopology.Singular.ExcisionCoverSmall.coverSmallSingularSubcomplex X U).ι

/-- A selected coefficient small-chain homotopy equivalence for an open cover. -/
def coverSmallCoefficientChainHomotopyEquiv_of_openCover
    (hUopen : ∀ i, IsOpen (U i)) (hUcover : ⋃ i, U i = Set.univ) :
    HomotopyEquiv (CoverSmallCoefficientSingularChainComplex K X U)
      ((TopCat.toSSet.obj X).chainComplex (ModuleCat.of K K)) :=
  (coverSmallCoefficientChainApproximation_of_openCover K X U hUopen hUcover).choose

lemma coverSmallCoefficientChainHomotopyEquiv_of_openCover_hom
    (hUopen : ∀ i, IsOpen (U i)) (hUcover : ⋃ i, U i = Set.univ) :
    (coverSmallCoefficientChainHomotopyEquiv_of_openCover K X U hUopen hUcover).hom =
      coverSmallCoefficientSingularChainInclusion K X U :=
  (coverSmallCoefficientChainApproximation_of_openCover K X U hUopen hUcover).choose_spec

end

end OAI.AlgebraicGeometry.ComplexMultiplication.Coefficient.Chains.SingularCoefficients