@@ -21,7 +21,7 @@ The best is to define a copy and select the instances best suited.
21
21
22
22
-/
23
23
24
- import data.set.finite data.finset algebra.big_operators
24
+ import data.set.finite data.finset algebra.big_operators algebra.module
25
25
noncomputable theory
26
26
27
27
open classical set function
@@ -38,7 +38,8 @@ def finsupp (α : Type u) (β : Type v) [has_zero β] := {f : α → β // finit
38
38
infix →₀ := finsupp
39
39
40
40
namespace finsupp
41
- variables {α : Type u} {β : Type v} {α₁ : Type u₁} {α₂ : Type u₂} {β₁ : Type v₁} {β₂ : Type v₂}
41
+ variables {α : Type u} {β : Type v} {γ : Type w}
42
+ {α₁ : Type u₁} {α₂ : Type u₂} {β₁ : Type v₁} {β₂ : Type v₂}
42
43
43
44
section
44
45
variable [has_zero β]
@@ -156,27 +157,27 @@ finset.ext.mpr $ assume a, by by_cases p a; simp *
156
157
end filter
157
158
158
159
-- [to_additive finsupp.sum] for finsupp.prod doesn't work, the equation lemmas are not generated
159
- def sum {γ : Type w} [has_zero β] [add_comm_monoid γ] (f : α →₀ β) (g : α → β → γ) : γ :=
160
+ def sum [has_zero β] [add_comm_monoid γ] (f : α →₀ β) (g : α → β → γ) : γ :=
160
161
f.support.sum (λa, g a (f a))
161
162
162
163
@[to_additive finsupp.sum]
163
- def prod {γ : Type w} [has_zero β] [comm_monoid γ] (f : α →₀ β) (g : α → β → γ) : γ :=
164
+ def prod [has_zero β] [comm_monoid γ] (f : α →₀ β) (g : α → β → γ) : γ :=
164
165
f.support.prod (λa, g a (f a))
165
166
attribute [to_additive finsupp.sum.equations._eqn_1] finsupp.prod.equations._eqn_1
166
167
167
168
@[to_additive finsupp.sum_map_range_index]
168
- lemma prod_map_range_index {γ : Type w} [has_zero β₁] [has_zero β₂] [comm_monoid γ]
169
+ lemma prod_map_range_index [has_zero β₁] [has_zero β₂] [comm_monoid γ]
169
170
{f : β₁ → β₂} {hf : f 0 = 0 } {g : α →₀ β₁} {h : α → β₂ → γ} (h0 : ∀a, h a 0 = 1 ) :
170
171
(map_range f hf g).prod h = g.prod (λa b, h a (f b)) :=
171
172
finset.prod_subset support_map_range $ by simp [h0] {contextual := tt}
172
173
173
174
@[to_additive finsupp.sum_zero_index]
174
- lemma prod_zero_index {γ : Type w} [add_comm_monoid β] [comm_monoid γ] {h : α → β → γ} :
175
+ lemma prod_zero_index [add_comm_monoid β] [comm_monoid γ] {h : α → β → γ} :
175
176
(0 : α →₀ β).prod h = 1 :=
176
177
by simp [finsupp.prod]
177
178
178
179
@[to_additive finsupp.sum_single_index]
179
- lemma prod_single_index {γ : Type w} [add_comm_monoid β] [comm_monoid γ] {a : α} {b : β}
180
+ lemma prod_single_index [add_comm_monoid β] [comm_monoid γ] {a : α} {b : β}
180
181
{h : α → β → γ} (h_zero : h a 0 = 1 ) : (single a b).prod h = h a b :=
181
182
begin
182
183
by_cases b = 0 with h,
@@ -226,18 +227,13 @@ instance [add_group β] : add_group (α →₀ β) :=
226
227
.. finsupp.add_monoid }
227
228
228
229
@[to_additive finsupp.sum_neg_index]
229
- lemma prod_neg_index {γ : Type w} [add_group β] [comm_monoid γ]
230
- {g : α →₀ β} {h : α → β → γ} (h0 : ∀a, h a 0 = 1 ) :
231
- (-g).prod h = g.prod (λa b, h a (- b)) :=
230
+ lemma prod_neg_index [add_group β] [comm_monoid γ] {g : α →₀ β} {h : α → β → γ}
231
+ (h0 : ∀a, h a 0 = 1 ) : (-g).prod h = g.prod (λa b, h a (- b)) :=
232
232
prod_map_range_index h0
233
233
234
- @[simp] lemma neg_apply [add_group β] {g : α →₀ β} {a : α} :
235
- (- g) a = - g a :=
236
- rfl
234
+ @[simp] lemma neg_apply [add_group β] {g : α →₀ β} {a : α} : (- g) a = - g a := rfl
237
235
238
- @[simp] lemma sub_apply [add_group β] {g₁ g₂ : α →₀ β} {a : α} :
239
- (g₁ - g₂) a = g₁ a - g₂ a :=
240
- rfl
236
+ @[simp] lemma sub_apply [add_group β] {g₁ g₂ : α →₀ β} {a : α} : (g₁ - g₂) a = g₁ a - g₂ a := rfl
241
237
242
238
@[simp] lemma support_neg [add_group β] {f : α →₀ β} : support (-f) = support f :=
243
239
finset.subset.antisymm
414
410
415
411
section comap_domain
416
412
417
- variables {α' : Type u₁} {γ : Type x} { δ : Type y} [has_zero δ]
413
+ variables {α' : Type u₁} {δ : Type y} [has_zero δ]
418
414
{f : α → α'} {hf : injective f} {p : α → Prop }
419
415
420
416
section zero
@@ -565,4 +561,23 @@ lemma prod_single {ι : Type x} [add_comm_monoid α] [comm_semiring β] {s : fin
565
561
s.prod (λi, single (a i) (b i)) = single (s.sum a) (s.prod b) :=
566
562
finset.induction_on s (by simp [one_def]) (by simp [single_mul_single] {contextual := tt})
567
563
564
+ def to_has_scalar [semiring β] : has_scalar β (α →₀ β) := ⟨λa v, v.map_range ((*) a) (mul_zero a)⟩
565
+ local attribute [instance] to_has_scalar
566
+
567
+ @[simp] lemma smul_apply [semiring β] {a : α} {b : β} {v : α →₀ β} : (b • v) a = b * v a :=
568
+ rfl
569
+
570
+ /- should this be stronger? [module γ β] → module γ (α →₀ β) -/
571
+ def to_module [ring β] : module β (α →₀ β) :=
572
+ { smul := (•),
573
+ smul_add := assume a x y, finsupp.ext $ by simp [mul_add],
574
+ add_smul := assume a x y, finsupp.ext $ by simp [add_mul],
575
+ one_smul := assume x, finsupp.ext $ by simp,
576
+ mul_smul := assume r s x, finsupp.ext $ by simp [mul_assoc],
577
+ .. finsupp.add_comm_group }
578
+
579
+ lemma sum_smul_index [ring β] [add_comm_monoid γ] {g : α →₀ β} {b : β} {h : α → β → γ}
580
+ (h0 : ∀i, h i 0 = 0 ) : (b • g).sum h = g.sum (λi a, h i (b * a)) :=
581
+ finsupp.sum_map_range_index h0
582
+
568
583
end finsupp
0 commit comments