@@ -428,6 +428,37 @@ lemma prod_eq_one {f : α → β} {s : finset α} (h : ∀x∈s, f x = 1) : s.pr
428
428
calc s.prod f = s.prod (λx, 1 ) : finset.prod_congr rfl h
429
429
... = 1 : finset.prod_const_one
430
430
431
+ /-- A product over all subsets of `s ∪ {x}` is obtained by multiplying the product over all subsets
432
+ of `s`, and over all subsets of `s` to which one adds `x`. -/
433
+ @[to_additive]
434
+ lemma prod_powerset_insert [decidable_eq α] {s : finset α} {x : α} (h : x ∉ s) (f : finset α → β) :
435
+ (insert x s).powerset.prod f = s.powerset.prod f * s.powerset.prod (λt, f (insert x t)) :=
436
+ begin
437
+ rw [powerset_insert, finset.prod_union, finset.prod_image],
438
+ { assume t₁ h₁ t₂ h₂ heq,
439
+ rw [← finset.erase_insert (not_mem_of_mem_powerset_of_not_mem h₁ h),
440
+ ← finset.erase_insert (not_mem_of_mem_powerset_of_not_mem h₂ h), heq] },
441
+ { rw finset.disjoint_iff_ne,
442
+ assume t₁ h₁ t₂ h₂,
443
+ rcases finset.mem_image.1 h₂ with ⟨t₃, h₃, H₃₂⟩,
444
+ rw ← H₃₂,
445
+ exact ne_insert_of_not_mem _ _ (not_mem_of_mem_powerset_of_not_mem h₁ h) }
446
+ end
447
+
448
+ @[to_additive]
449
+ lemma prod_piecewise [decidable_eq α] (s t : finset α) (f g : α → β) :
450
+ s.prod (t.piecewise f g) = (s ∩ t).prod f * (s \ t).prod g :=
451
+ begin
452
+ refine s.induction_on (by simp) _,
453
+ assume x s hxs Hrec,
454
+ by_cases h : x ∈ t,
455
+ { simp [hxs, h, Hrec, insert_sdiff_of_mem s h, mul_assoc] },
456
+ { simp [hxs, h, Hrec, insert_sdiff_of_not_mem s h],
457
+ rw [mul_comm, mul_assoc],
458
+ congr' 1 ,
459
+ rw mul_comm }
460
+ end
461
+
431
462
end comm_monoid
432
463
433
464
lemma sum_smul' [add_comm_monoid β] (s : finset α) (n : ℕ) (f : α → β) :
0 commit comments