Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 842328d

Browse files
committed
feat(data/finsupp/indicator, algebra/big_operators/finsupp): add some lemmas about finsupp.indicator (#17413)
mathlib4 PR: leanprover-community/mathlib4#2258
1 parent 195fcd6 commit 842328d

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed

src/algebra/big_operators/finsupp.lean

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Kenny Lau
55
-/
66

7-
import data.finsupp.defs
7+
import data.finsupp.indicator
88
import algebra.big_operators.pi
99
import algebra.big_operators.ring
1010
import algebra.big_operators.order
@@ -488,6 +488,26 @@ begin
488488
exact h2,
489489
end
490490

491+
lemma indicator_eq_sum_single [add_comm_monoid M] (s : finset α) (f : Π a ∈ s, M) :
492+
indicator s f = ∑ x in s.attach, single x (f x x.2) :=
493+
begin
494+
rw [← sum_single (indicator s f), sum, sum_subset (support_indicator_subset _ _), ← sum_attach],
495+
{ refine finset.sum_congr rfl (λ x hx, _),
496+
rw [indicator_of_mem], },
497+
intros i _ hi,
498+
rw [not_mem_support_iff.mp hi, single_zero],
499+
end
500+
501+
@[simp, to_additive]
502+
lemma prod_indicator_index [has_zero M] [comm_monoid N]
503+
{s : finset α} (f : Π a ∈ s, M) {h : α → M → N} (h_zero : ∀ a ∈ s, h a 0 = 1) :
504+
(indicator s f).prod h = ∏ x in s.attach, h x (f x x.2) :=
505+
begin
506+
rw [prod_of_support_subset _ (support_indicator_subset _ _) h h_zero, ← prod_attach],
507+
refine finset.prod_congr rfl (λ x hx, _),
508+
rw [indicator_of_mem],
509+
end
510+
491511
end finsupp
492512

493513

src/data/finsupp/defs.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ lemma single_apply_left {f : α → β} (hf : function.injective f)
232232
single (f x) y (f z) = single x y z :=
233233
by { classical, simp only [single_apply, hf.eq_iff] }
234234

235-
lemma single_eq_indicator : ⇑(single a b) = set.indicator {a} (λ _, b) :=
235+
lemma single_eq_set_indicator : ⇑(single a b) = set.indicator {a} (λ _, b) :=
236236
by { classical, ext, simp [single_apply, set.indicator, @eq_comm _ a] }
237237

238238
@[simp] lemma single_eq_same : (single a b : α →₀ M) a = b :=
@@ -242,7 +242,7 @@ by { classical, exact pi.single_eq_same a b }
242242
by { classical, exact pi.single_eq_of_ne' h _ }
243243

244244
lemma single_eq_update [decidable_eq α] (a : α) (b : M) : ⇑(single a b) = function.update 0 a b :=
245-
by rw [single_eq_indicator, ← set.piecewise_eq_indicator, set.piecewise_singleton]
245+
by rw [single_eq_set_indicator, ← set.piecewise_eq_indicator, set.piecewise_singleton]
246246

247247
lemma single_eq_pi_single [decidable_eq α] (a : α) (b : M) : ⇑(single a b) = pi.single a b :=
248248
single_eq_update a b
@@ -284,7 +284,7 @@ have (single a b₁ : α →₀ M) a = (single a b₂ : α →₀ M) a, by rw eq
284284
by rwa [single_eq_same, single_eq_same] at this
285285

286286
lemma single_apply_eq_zero {a x : α} {b : M} : single a b x = 0 ↔ (x = a → b = 0) :=
287-
by simp [single_eq_indicator]
287+
by simp [single_eq_set_indicator]
288288

289289
lemma single_apply_ne_zero {a x : α} {b : M} : single a b x ≠ 0 ↔ (x = a ∧ b ≠ 0) :=
290290
by simp [single_apply_eq_zero]
@@ -337,7 +337,7 @@ lemma support_single_disjoint {b' : M} (hb : b ≠ 0) (hb' : b' ≠ 0) {i j : α
337337
by rw [support_single_ne_zero _ hb, support_single_ne_zero _ hb', disjoint_singleton]
338338

339339
@[simp] lemma single_eq_zero : single a b = 0 ↔ b = 0 :=
340-
by simp [ext_iff, single_eq_indicator]
340+
by simp [ext_iff, single_eq_set_indicator]
341341

342342
lemma single_swap (a₁ a₂ : α) (b : M) : single a₁ b a₂ = single a₂ b a₁ :=
343343
by { classical, simp only [single_apply], ac_refl }

src/data/finsupp/indicator.lean

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,8 @@ begin
6666
exact hi (indicator_of_not_mem h _),
6767
end
6868

69+
lemma single_eq_indicator (i : ι) (b : α) :
70+
single i b = indicator {i} (λ _ _, b) :=
71+
by { classical, ext, simp [single_apply, indicator_apply, @eq_comm _ a] }
72+
6973
end finsupp

0 commit comments

Comments
 (0)