@@ -408,22 +408,70 @@ calc (∏ a in s.filter p, f a) = ∏ a in s.filter p, if p a then f a else 1 :
408
408
end
409
409
410
410
@[to_additive]
411
- lemma prod_eq_single {s : finset α} {f : α → β} (a : α)
412
- (h₀ : ∀b∈s, b ≠ a → f b = 1 ) (h₁ : a ∉ s → f a = 1 ) : (∏ x in s, f x) = f a :=
413
- by haveI := classical.dec_eq α;
414
- from classical.by_cases
415
- (assume : a ∈ s,
416
- calc (∏ x in s, f x) = ∏ x in {a}, f x :
411
+ lemma prod_eq_single_of_mem {s : finset α} {f : α → β} (a : α) (h : a ∈ s)
412
+ (h₀ : ∀ b ∈ s, b ≠ a → f b = 1 ) : (∏ x in s, f x) = f a :=
413
+ begin
414
+ haveI := classical.dec_eq α,
415
+ calc (∏ x in s, f x) = ∏ x in {a}, f x :
417
416
begin
418
417
refine (prod_subset _ _).symm,
419
418
{ intros _ H, rwa mem_singleton.1 H },
420
419
{ simpa only [mem_singleton] }
421
420
end
422
- ... = f a : prod_singleton)
421
+ ... = f a : prod_singleton
422
+ end
423
+
424
+ @[to_additive]
425
+ lemma prod_eq_single {s : finset α} {f : α → β} (a : α)
426
+ (h₀ : ∀b∈s, b ≠ a → f b = 1 ) (h₁ : a ∉ s → f a = 1 ) : (∏ x in s, f x) = f a :=
427
+ by haveI := classical.dec_eq α;
428
+ from classical.by_cases
429
+ (assume : a ∈ s, prod_eq_single_of_mem a this h₀)
423
430
(assume : a ∉ s,
424
431
(prod_congr rfl $ λ b hb, h₀ b hb $ by rintro rfl; cc).trans $
425
432
prod_const_one.trans (h₁ this ).symm)
426
433
434
+ @[to_additive]
435
+ lemma prod_eq_mul_of_mem {s : finset α} {f : α → β} (a b : α) (ha : a ∈ s) (hb : b ∈ s) (hn : a ≠ b)
436
+ (h₀ : ∀ c ∈ s, c ≠ a ∧ c ≠ b → f c = 1 ) : (∏ x in s, f x) = (f a) * (f b) :=
437
+ begin
438
+ haveI := classical.dec_eq α;
439
+ let s' := ({a, b} : finset α),
440
+ have hu : s' ⊆ s,
441
+ { refine insert_subset.mpr _, apply and.intro ha, apply singleton_subset_iff.mpr hb },
442
+ have hf : ∀ c ∈ s, c ∉ s' → f c = 1 ,
443
+ { intros c hc hcs,
444
+ apply h₀ c hc,
445
+ apply not_or_distrib.mp,
446
+ intro hab,
447
+ apply hcs,
448
+ apply mem_insert.mpr,
449
+ rw mem_singleton,
450
+ exact hab },
451
+ rw ←prod_subset hu hf,
452
+ exact finset.prod_pair hn
453
+ end
454
+
455
+ @[to_additive]
456
+ lemma prod_eq_mul {s : finset α} {f : α → β} (a b : α) (hn : a ≠ b)
457
+ (h₀ : ∀ c ∈ s, c ≠ a ∧ c ≠ b → f c = 1 ) (ha : a ∉ s → f a = 1 ) (hb : b ∉ s → f b = 1 ) :
458
+ (∏ x in s, f x) = (f a) * (f b) :=
459
+ begin
460
+ haveI := classical.dec_eq α;
461
+ by_cases h₁ : a ∈ s; by_cases h₂ : b ∈ s,
462
+ { exact prod_eq_mul_of_mem a b h₁ h₂ hn h₀ },
463
+ { rw [hb h₂, mul_one],
464
+ apply prod_eq_single_of_mem a h₁,
465
+ exact λ c hc hca, h₀ c hc ⟨hca, ne_of_mem_of_not_mem hc h₂⟩ },
466
+ { rw [ha h₁, one_mul],
467
+ apply prod_eq_single_of_mem b h₂,
468
+ exact λ c hc hcb, h₀ c hc ⟨ne_of_mem_of_not_mem hc h₁, hcb⟩ },
469
+ { rw [ha h₁, hb h₂, mul_one],
470
+ exact trans
471
+ (prod_congr rfl (λ c hc, h₀ c hc ⟨ne_of_mem_of_not_mem hc h₁, ne_of_mem_of_not_mem hc h₂⟩))
472
+ prod_const_one }
473
+ end
474
+
427
475
@[to_additive]
428
476
lemma prod_attach {f : α → β} : (∏ x in s.attach, f x) = (∏ x in s, f x) :=
429
477
by haveI := classical.dec_eq α; exact
0 commit comments