File size: 9,935 Bytes
216fb31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import OAI.Algebra.Finitistic.Bar.MultibarIndex

namespace OAI
open scoped TensorProduct DirectSum
open TensorProduct TrivSqZeroExt
noncomputable section

namespace DerivedBar.Multibar.Indexed
universe u

/-- A D/X pattern with length and X-count in its type, avoiding any degree casts. -/
inductive Shape : ℕ → ℕ → Type
  | nil : Shape 0 0
  | base {n r : ℕ} : Shape n r → Shape (n+1) r
  | ideal {n r : ℕ} : Shape n r → Shape (n+1) (r+1)

local instance (n r : ℕ) : DecidableEq (Shape n r) := Classical.decEq _

def toList : {n r : ℕ} → Shape n r → List Bool
  | _, _, .nil => []
  | _, _, .base p => false :: toList p
  | _, _, .ideal p => true :: toList p

@[simp] theorem length_toList {n r : ℕ} (p : Shape n r) : (toList p).length = n := by
  induction p <;> simp_all [toList]

@[simp] theorem count_toList {n r : ℕ} (p : Shape n r) : count (toList p) = r := by
  induction p <;> simp_all [toList, count]

variable (k D X N : Type u) [Field k] [Ring D] [Algebra k D]
  [AddCommGroup X] [Module k X] [Module D X] [Module Dᵐᵒᵖ X]
  [SMulCommClass D Dᵐᵒᵖ X] [IsScalarTower k D X] [IsScalarTower k Dᵐᵒᵖ X]
  [AddCommGroup N] [Module k N]

@[reducible] def tensor : {n r : ℕ} → Shape n r → ModuleCat k
  | _, _, .nil => ModuleCat.of k N
  | _, _, .base p => ModuleCat.of k (D ⊗[k] tensor p)
  | _, _, .ideal p => ModuleCat.of k (X ⊗[k] tensor p)

def inclusion : {n r : ℕ} → (p : Shape n r) →
    tensor k D X N p →ₗ[k] DerivedBar.term k (TrivSqZeroExt D X) N n
  | _, _, .nil => LinearMap.id
  | _, _, .base p => TensorProduct.map (inlAlgHom k D X).toLinearMap (inclusion p)
  | _, _, .ideal p => TensorProduct.map ((inrHom D X).restrictScalars k) (inclusion p)

def retraction : {n r : ℕ} → (p : Shape n r) →
    DerivedBar.term k (TrivSqZeroExt D X) N n →ₗ[k] tensor k D X N p
  | _, _, .nil => LinearMap.id
  | _, _, .base p => TensorProduct.map (fstHom k D X).toLinearMap (retraction p)
  | _, _, .ideal p => TensorProduct.map ((sndHom D X).restrictScalars k) (retraction p)

theorem retraction_inclusion {n r : ℕ} (p : Shape n r) (v : tensor k D X N p) :
    retraction k D X N p (inclusion k D X N p v) = v := by
  induction p with
  | nil => rfl
  | base p ih =>
    induction v using TensorProduct.inductionOn with
    | tmul d v =>
      change d ⊗ₜ[k] retraction k D X N p (inclusion k D X N p v) = _
      rw [ih]
    | add v w hv hw => simp only [map_add, hv, hw]
  | ideal p ih =>
    induction v using TensorProduct.inductionOn with
    | tmul x v =>
      change x ⊗ₜ[k] retraction k D X N p (inclusion k D X N p v) = _
      rw [ih]
    | add v w hv hw => simp only [map_add, hv, hw]

/-- Distinct patterns are separated by slotwise projections, including non-flat bimodules. -/
theorem retraction_other {n r : ℕ} (p q : Shape n r) (hpq : p ≠ q)
    (v : tensor k D X N q) : retraction k D X N p (inclusion k D X N q v) = 0 := by
  induction p with
  | nil => cases q; exact (hpq rfl).elim
  | base p ih =>
    cases q with
    | base q =>
      have h : p ≠ q := fun h => hpq (congrArg Shape.base h)
      induction v using TensorProduct.inductionOn with
      | tmul d v =>
        change d ⊗ₜ[k] retraction k D X N p (inclusion k D X N q v) = 0
        rw [ih q h, TensorProduct.tmul_zero]
      | add v w hv hw => simp only [map_add, hv, hw, add_zero]
    | ideal q =>
      induction v using TensorProduct.inductionOn with
      | tmul x v => exact TensorProduct.zero_tmul _ _
      | add v w hv hw => simp only [map_add, hv, hw, add_zero]
  | ideal p ih =>
    cases q with
    | base q =>
      induction v using TensorProduct.inductionOn with
      | tmul d v => exact TensorProduct.zero_tmul _ _
      | add v w hv hw => simp only [map_add, hv, hw, add_zero]
    | ideal q =>
      have h : p ≠ q := fun h => hpq (congrArg Shape.ideal h)
      induction v using TensorProduct.inductionOn with
      | tmul x v =>
        change x ⊗ₜ[k] retraction k D X N p (inclusion k D X N q v) = 0
        rw [ih q h, TensorProduct.tmul_zero]
      | add v w hv hw => simp only [map_add, hv, hw, add_zero]

theorem inclusion_mem {n r : ℕ} (p : Shape n r) (v : tensor k D X N p) :
    inclusion k D X N p v ∈ SquareZero.weight k D X N n r := by
  induction p with
  | nil => exact Submodule.subset_span (SquareZero.Word.nil v)
  | base p ih =>
    induction v using TensorProduct.inductionOn with
    | tmul d v => exact SquareZero.base_tmul_mem d (ih v)
    | add v w hv hw => simpa only [map_add] using Submodule.add_mem _ hv hw
  | ideal p ih =>
    induction v using TensorProduct.inductionOn with
    | tmul x v => exact SquareZero.ideal_tmul_mem x (ih v)
    | add v w hv hw => simpa only [map_add] using Submodule.add_mem _ hv hw

/-- Every homogeneous word is an actual tensor in one of the prescribed blocks. -/
theorem word_inclusion {n r : ℕ} {z : DerivedBar.term k (TrivSqZeroExt D X) N n}
    (hz : SquareZero.Word k D X N n r z) :
    ∃ (p : Shape n r) (v : tensor k D X N p), inclusion k D X N p v = z := by
  induction hz with
  | nil v => exact ⟨.nil, v, rfl⟩
  | base d h ih =>
    obtain ⟨p, v, hv⟩ := ih
    exact ⟨.base p, d ⊗ₜ[k] v, by change (inl d : TrivSqZeroExt D X) ⊗ₜ[k] _ = _; rw [hv]⟩
  | ideal x h ih =>
    obtain ⟨p, v, hv⟩ := ih
    exact ⟨.ideal p, x ⊗ₜ[k] v, by change (inr x : TrivSqZeroExt D X) ⊗ₜ[k] _ = _; rw [hv]⟩

abbrev outerTensor {n r : ℕ} (p : Shape n r) := D ⊗[k] tensor k D X N p

def outerInclusion {n r : ℕ} (p : Shape n r) : outerTensor k D X N p →ₗ[D]
    D ⊗[k] DerivedBar.term k (TrivSqZeroExt D X) N n :=
  AlgebraTensorModule.lTensor D D (inclusion k D X N p)

def outerRetraction {n r : ℕ} (p : Shape n r) :
    D ⊗[k] DerivedBar.term k (TrivSqZeroExt D X) N n →ₗ[D] outerTensor k D X N p :=
  AlgebraTensorModule.lTensor D D (retraction k D X N p)

theorem outerRetraction_inclusion {n r : ℕ} (p : Shape n r) (v : outerTensor k D X N p) :
    outerRetraction k D X N p (outerInclusion k D X N p v) = v := by
  induction v using TensorProduct.inductionOn with
  | tmul d v =>
    change d ⊗ₜ[k] retraction k D X N p (inclusion k D X N p v) = _
    rw [retraction_inclusion]
  | add v w hv hw => simp only [map_add, hv, hw]

theorem outerRetraction_other {n r : ℕ} (p q : Shape n r) (hpq : p ≠ q)
    (v : outerTensor k D X N q) :
    outerRetraction k D X N p (outerInclusion k D X N q v) = 0 := by
  induction v using TensorProduct.inductionOn with
  | tmul d v =>
    change d ⊗ₜ[k] retraction k D X N p (inclusion k D X N q v) = 0
    rw [retraction_other k D X N p q hpq, TensorProduct.tmul_zero]
  | add v w hv hw => simp only [map_add, hv, hw, add_zero]

theorem outerInclusion_mem {n r : ℕ} (p : Shape n r) (v : outerTensor k D X N p) :
    outerInclusion k D X N p v ∈ SquareZero.twoSidedWeight k D X N n r := by
  induction v using TensorProduct.inductionOn with
  | tmul d v => exact SquareZero.tensor_weight_mem d (inclusion_mem k D X N p v)
  | add v w hv hw => simpa only [map_add] using Submodule.add_mem _ hv hw

/-- The actual sum of all tensor-block inclusions in count r and degree n. -/
def assemble (n r : ℕ) : (⨁ p : Shape n r, outerTensor k D X N p) →ₗ[D]
    SquareZero.twoSidedWeight k D X N n r :=
  DirectSum.toModule D (Shape n r) _ (fun p =>
    (outerInclusion k D X N p).codRestrict _ (outerInclusion_mem k D X N p))

/-- Surjectivity is proved from the original homogeneous-word spanning definition. -/
theorem assemble_surjective (n r : ℕ) : Function.Surjective (assemble k D X N n r) := by
  let S := LinearMap.range (assemble k D X N n r)
  have hle : SquareZero.twoSidedWeight k D X N n r ≤
      S.map (SquareZero.twoSidedWeight k D X N n r).subtype := by
    apply Submodule.span_le.mpr
    rintro z ⟨d, v, hv, rfl⟩
    obtain ⟨p, w, hw⟩ := word_inclusion k D X N hv
    refine ⟨assemble k D X N n r (DirectSum.lof D _ _ p (d ⊗ₜ[k] w)), ⟨_, rfl⟩, ?_⟩
    simp only [assemble, DirectSum.toModule_lof, LinearMap.codRestrict_apply,
      Submodule.subtype_apply]
    change d ⊗ₜ[k] inclusion k D X N p w = d ⊗ₜ[k] v
    rw [hw]
  intro v
  obtain ⟨w, ⟨z, hz⟩, hw⟩ := hle v.property
  refine ⟨z, ?_⟩
  apply Subtype.ext
  rw [hz]
  exact hw

/-- Projection onto an actual block after summation recovers the direct-sum component. -/
theorem outerRetraction_assemble (n r : ℕ) (p : Shape n r)
    (z : ⨁ p : Shape n r, outerTensor k D X N p) :
    outerRetraction k D X N p (assemble k D X N n r z) = z p := by
  have h : (outerRetraction k D X N p).comp
      ((SquareZero.twoSidedWeight k D X N n r).subtype.comp (assemble k D X N n r)) =
      DirectSum.component D (Shape n r) (outerTensor k D X N) p := by
    apply DirectSum.linearMap_ext
    intro q
    apply LinearMap.ext
    intro v
    by_cases hpq : p = q
    · subst q
      simpa only [LinearMap.comp_apply, assemble, DirectSum.toModule_lof,
        LinearMap.codRestrict_apply, Submodule.subtype_apply,
        DirectSum.component.lof_self] using
          outerRetraction_inclusion k D X N p v
    · simpa only [LinearMap.comp_apply, assemble, DirectSum.toModule_lof,
        LinearMap.codRestrict_apply, Submodule.subtype_apply,
        DirectSum.component.of, Ne.symm hpq, dite_eq_right, dite_false] using
          outerRetraction_other k D X N p q hpq v
  exact LinearMap.congr_fun h z

/-- The block direct sum is linearly isomorphic to the entire actual count submodule. -/
def decomposition (n r : ℕ) : (⨁ p : Shape n r, outerTensor k D X N p) ≃ₗ[D]
    SquareZero.twoSidedWeight k D X N n r :=
  LinearEquiv.ofBijective (assemble k D X N n r)
    ⟨by
      intro z w h
      apply DFinsupp.ext
      intro p
      rw [← outerRetraction_assemble k D X N n r p z,
        ← outerRetraction_assemble k D X N n r p w, h],
     assemble_surjective k D X N n r⟩
end DerivedBar.Multibar.Indexed

end

end OAI