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

Commit 70245f4

Browse files
committed
feat(algebra/big_operators): prod_comp (#2594)
This is a lemma that @jcommelin looks like he could have used in Chevalley Warning, and is probably useful elsewhere.
1 parent 08a17d6 commit 70245f4

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/algebra/big_operators.lean

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,19 @@ finset.strong_induction_on s
587587
← insert_erase (mem_erase.2 ⟨h₂ x hx hx1, h₃ x hx⟩),
588588
prod_insert (not_mem_erase _ _), ih', mul_one, h₁ x hx]))
589589

590+
/-- The product of the composition of functions `f` and `g`, is the product
591+
over `b ∈ s.image g` of `f b` to the power of the cardinality of the fibre of `b` -/
592+
lemma prod_comp [decidable_eq γ] {s : finset α} (f : γ → β) (g : α → γ) :
593+
∏ a in s, f (g a) = ∏ b in s.image g, f b ^ (s.filter (λ a, g a = b)).card :=
594+
calc ∏ a in s, f (g a)
595+
= ∏ x in (s.image g).sigma (λ b : γ, s.filter (λ a, g a = b)), f (g x.2) :
596+
prod_bij (λ a ha, ⟨g a, a⟩) (by simp; tauto) (λ _ _, rfl) (by simp) (by finish)
597+
... = ∏ b in s.image g, ∏ a in s.filter (λ a, g a = b), f (g a) : prod_sigma
598+
... = ∏ b in s.image g, ∏ a in s.filter (λ a, g a = b), f b :
599+
prod_congr rfl (λ b hb, prod_congr rfl (by simp {contextual := tt}))
600+
... = ∏ b in s.image g, f b ^ (s.filter (λ a, g a = b)).card :
601+
prod_congr rfl (λ _ _, prod_const _)
602+
590603
@[to_additive]
591604
lemma prod_eq_one {f : α → β} {s : finset α} (h : ∀x∈s, f x = 1) : (∏ x in s, f x) = 1 :=
592605
calc (∏ x in s, f x) = s.prod (λx, 1) : finset.prod_congr rfl h
@@ -662,6 +675,12 @@ attribute [to_additive sum_smul'] prod_pow
662675
@prod_const _ (multiplicative β) _ _ _
663676
attribute [to_additive] prod_const
664677

678+
lemma sum_comp [add_comm_monoid β] [decidable_eq γ] {s : finset α} (f : γ → β) (g : α → γ) :
679+
∑ a in s, f (g a) = ∑ b in s.image g, add_monoid.smul (s.filter (λ a, g a = b)).card (f b) :=
680+
@prod_comp _ (multiplicative β) _ _ _ _ _ _
681+
attribute [to_additive "The sum of the composition of functions `f` and `g`, is the sum
682+
over `b ∈ s.image g` of `f b` times of the cardinality of the fibre of `b`"] prod_comp
683+
665684
lemma sum_const_nat {m : ℕ} {f : α → ℕ} (h₁ : ∀x ∈ s, f x = m) :
666685
(∑ x in s, f x) = card s * m :=
667686
begin

0 commit comments

Comments
 (0)