@@ -8,9 +8,10 @@ import Mathlib.Algebra.BigOperators.Group.Finset.Defs
8
8
import Mathlib.Algebra.Group.Even
9
9
import Mathlib.Data.Finset.Piecewise
10
10
import Mathlib.Data.Finset.Powerset
11
- import Mathlib.Data.Finset.Preimage
11
+ import Mathlib.Data.Finset.Lattice.Fold
12
+ import Mathlib.Order.CompleteLattice.Finset
13
+ import Mathlib.Data.Finset.Sum
12
14
import Mathlib.Data.Finset.Prod
13
- import Mathlib.Data.Fintype.Pi
14
15
15
16
/-!
16
17
# Big operators
@@ -41,6 +42,7 @@ See the documentation of `to_additive.attr` for more information.
41
42
-- TODO
42
43
-- assert_not_exists AddCommMonoidWithOne
43
44
assert_not_exists MonoidWithZero MulAction OrderedCommMonoid
45
+ assert_not_exists Finset.preimage Finset.sigma Fintype.piFinset
44
46
45
47
variable {ι κ α β γ : Type *}
46
48
@@ -289,26 +291,6 @@ theorem prod_biUnion [DecidableEq α] {s : Finset γ} {t : γ → Finset α}
289
291
(hs : Set.PairwiseDisjoint (↑s) t) : ∏ x ∈ s.biUnion t, f x = ∏ x ∈ s, ∏ i ∈ t x, f i := by
290
292
rw [← disjiUnion_eq_biUnion _ _ hs, prod_disjiUnion]
291
293
292
- /-- The product over a sigma type equals the product of the fiberwise products.
293
- For rewriting in the reverse direction, use `Finset.prod_sigma'`.
294
-
295
- See also `Fintype.prod_sigma` for the product over the whole type. -/
296
- @[to_additive "The sum over a sigma type equals the sum of the fiberwise sums. For rewriting
297
- in the reverse direction, use `Finset.sum_sigma'`.
298
-
299
- See also `Fintype.sum_sigma` for the sum over the whole type." ]
300
- theorem prod_sigma {σ : α → Type *} (s : Finset α) (t : ∀ a, Finset (σ a)) (f : Sigma σ → β) :
301
- ∏ x ∈ s.sigma t, f x = ∏ a ∈ s, ∏ s ∈ t a, f ⟨a, s⟩ := by
302
- simp_rw [← disjiUnion_map_sigma_mk, prod_disjiUnion, prod_map, Function.Embedding.sigmaMk_apply]
303
-
304
- /-- The product over a sigma type equals the product of the fiberwise products. For rewriting
305
- in the reverse direction, use `Finset.prod_sigma`. -/
306
- @[to_additive "The sum over a sigma type equals the sum of the fiberwise sums. For rewriting
307
- in the reverse direction, use `Finset.sum_sigma`" ]
308
- theorem prod_sigma' {σ : α → Type *} (s : Finset α) (t : ∀ a, Finset (σ a)) (f : ∀ a, σ a → β) :
309
- (∏ a ∈ s, ∏ s ∈ t a, f a s) = ∏ x ∈ s.sigma t, f x.1 x.2 :=
310
- Eq.symm <| prod_sigma s t fun x => f x.1 x.2
311
-
312
294
section bij
313
295
variable {ι κ α : Type *} [CommMonoid α] {s : Finset ι} {t : Finset κ} {f : ι → α} {g : κ → α}
314
296
@@ -362,50 +344,11 @@ lemma prod_fiberwise' (s : Finset ι) (g : ι → κ) (f : κ → α) :
362
344
363
345
end bij
364
346
365
- /-- Taking a product over `univ.pi t` is the same as taking the product over `Fintype.piFinset t`.
366
- `univ.pi t` and `Fintype.piFinset t` are essentially the same `Finset`, but differ
367
- in the type of their element, `univ.pi t` is a `Finset (Π a ∈ univ, t a)` and
368
- `Fintype.piFinset t` is a `Finset (Π a, t a)`. -/
369
- @[to_additive "Taking a sum over `univ.pi t` is the same as taking the sum over
370
- `Fintype.piFinset t`. `univ.pi t` and `Fintype.piFinset t` are essentially the same `Finset`,
371
- but differ in the type of their element, `univ.pi t` is a `Finset (Π a ∈ univ, t a)` and
372
- `Fintype.piFinset t` is a `Finset (Π a, t a)`." ]
373
- lemma prod_univ_pi [DecidableEq ι] [Fintype ι] {κ : ι → Type *} (t : ∀ i, Finset (κ i))
374
- (f : (∀ i ∈ (univ : Finset ι), κ i) → β) :
375
- ∏ x ∈ univ.pi t, f x = ∏ x ∈ Fintype.piFinset t, f fun a _ ↦ x a := by
376
- apply prod_nbij' (fun x i ↦ x i <| mem_univ _) (fun x i _ ↦ x i) <;> simp
377
-
378
347
@[to_additive (attr := simp)]
379
348
lemma prod_diag [DecidableEq α] (s : Finset α) (f : α × α → β) :
380
349
∏ i ∈ s.diag, f i = ∏ i ∈ s, f (i, i) := by
381
350
apply prod_nbij' Prod.fst (fun i ↦ (i, i)) <;> simp
382
351
383
- @[to_additive]
384
- theorem prod_finset_product (r : Finset (γ × α)) (s : Finset γ) (t : γ → Finset α)
385
- (h : ∀ p : γ × α, p ∈ r ↔ p.1 ∈ s ∧ p.2 ∈ t p.1 ) {f : γ × α → β} :
386
- ∏ p ∈ r, f p = ∏ c ∈ s, ∏ a ∈ t c, f (c, a) := by
387
- refine Eq.trans ?_ (prod_sigma s t fun p => f (p.1 , p.2 ))
388
- apply prod_equiv (Equiv.sigmaEquivProd _ _).symm <;> simp [h]
389
-
390
- @[to_additive]
391
- theorem prod_finset_product' (r : Finset (γ × α)) (s : Finset γ) (t : γ → Finset α)
392
- (h : ∀ p : γ × α, p ∈ r ↔ p.1 ∈ s ∧ p.2 ∈ t p.1 ) {f : γ → α → β} :
393
- ∏ p ∈ r, f p.1 p.2 = ∏ c ∈ s, ∏ a ∈ t c, f c a :=
394
- prod_finset_product r s t h
395
-
396
- @[to_additive]
397
- theorem prod_finset_product_right (r : Finset (α × γ)) (s : Finset γ) (t : γ → Finset α)
398
- (h : ∀ p : α × γ, p ∈ r ↔ p.2 ∈ s ∧ p.1 ∈ t p.2 ) {f : α × γ → β} :
399
- ∏ p ∈ r, f p = ∏ c ∈ s, ∏ a ∈ t c, f (a, c) := by
400
- refine Eq.trans ?_ (prod_sigma s t fun p => f (p.2 , p.1 ))
401
- apply prod_equiv ((Equiv.prodComm _ _).trans (Equiv.sigmaEquivProd _ _).symm) <;> simp [h]
402
-
403
- @[to_additive]
404
- theorem prod_finset_product_right' (r : Finset (α × γ)) (s : Finset γ) (t : γ → Finset α)
405
- (h : ∀ p : α × γ, p ∈ r ↔ p.2 ∈ s ∧ p.1 ∈ t p.2 ) {f : α → γ → β} :
406
- ∏ p ∈ r, f p.1 p.2 = ∏ c ∈ s, ∏ a ∈ t c, f a c :=
407
- prod_finset_product_right r s t h
408
-
409
352
@[to_additive]
410
353
theorem prod_image' [DecidableEq α] {s : Finset ι} {g : ι → α} (h : ι → β)
411
354
(eq : ∀ i ∈ s, f (g i) = ∏ j ∈ s with g j = g i, h j) :
@@ -426,55 +369,6 @@ lemma prod_mul_prod_comm (f g h i : α → β) :
426
369
(∏ a ∈ s, f a * g a) * ∏ a ∈ s, h a * i a = (∏ a ∈ s, f a * h a) * ∏ a ∈ s, g a * i a := by
427
370
simp_rw [prod_mul_distrib, mul_mul_mul_comm]
428
371
429
- /-- The product over a product set equals the product of the fiberwise products. For rewriting
430
- in the reverse direction, use `Finset.prod_product'`. -/
431
- @[to_additive "The sum over a product set equals the sum of the fiberwise sums. For rewriting
432
- in the reverse direction, use `Finset.sum_product'`" ]
433
- theorem prod_product (s : Finset γ) (t : Finset α) (f : γ × α → β) :
434
- ∏ x ∈ s ×ˢ t, f x = ∏ x ∈ s, ∏ y ∈ t, f (x, y) :=
435
- prod_finset_product (s ×ˢ t) s (fun _a => t) fun _p => mem_product
436
-
437
- /-- The product over a product set equals the product of the fiberwise products. For rewriting
438
- in the reverse direction, use `Finset.prod_product`. -/
439
- @[to_additive "The sum over a product set equals the sum of the fiberwise sums. For rewriting
440
- in the reverse direction, use `Finset.sum_product`" ]
441
- theorem prod_product' (s : Finset γ) (t : Finset α) (f : γ → α → β) :
442
- ∏ x ∈ s ×ˢ t, f x.1 x.2 = ∏ x ∈ s, ∏ y ∈ t, f x y :=
443
- prod_product ..
444
-
445
- @[to_additive]
446
- theorem prod_product_right (s : Finset γ) (t : Finset α) (f : γ × α → β) :
447
- ∏ x ∈ s ×ˢ t, f x = ∏ y ∈ t, ∏ x ∈ s, f (x, y) :=
448
- prod_finset_product_right (s ×ˢ t) t (fun _a => s) fun _p => mem_product.trans and_comm
449
-
450
- /-- An uncurried version of `Finset.prod_product_right`. -/
451
- @[to_additive "An uncurried version of `Finset.sum_product_right`"]
452
- theorem prod_product_right' (s : Finset γ) (t : Finset α) (f : γ → α → β) :
453
- ∏ x ∈ s ×ˢ t, f x.1 x.2 = ∏ y ∈ t, ∏ x ∈ s, f x y :=
454
- prod_product_right ..
455
-
456
- /-- Generalization of `Finset.prod_comm` to the case when the inner `Finset`s depend on the outer
457
- variable. -/
458
- @[to_additive "Generalization of `Finset.sum_comm` to the case when the inner `Finset`s depend on
459
- the outer variable." ]
460
- theorem prod_comm' {s : Finset γ} {t : γ → Finset α} {t' : Finset α} {s' : α → Finset γ}
461
- (h : ∀ x y, x ∈ s ∧ y ∈ t x ↔ x ∈ s' y ∧ y ∈ t') {f : γ → α → β} :
462
- (∏ x ∈ s, ∏ y ∈ t x, f x y) = ∏ y ∈ t', ∏ x ∈ s' y, f x y := by
463
- classical
464
- have : ∀ z : γ × α, (z ∈ s.biUnion fun x => (t x).map <| Function.Embedding.sectR x _) ↔
465
- z.1 ∈ s ∧ z.2 ∈ t z.1 := by
466
- rintro ⟨x, y⟩
467
- simp only [mem_biUnion, mem_map, Function.Embedding.sectR_apply, Prod.mk.injEq,
468
- exists_eq_right, ← and_assoc]
469
- exact
470
- (prod_finset_product' _ _ _ this).symm.trans
471
- ((prod_finset_product_right' _ _ _) fun ⟨x, y⟩ => (this _).trans ((h x y).trans and_comm))
472
-
473
- @[to_additive]
474
- theorem prod_comm {s : Finset γ} {t : Finset α} {f : γ → α → β} :
475
- (∏ x ∈ s, ∏ y ∈ t, f x y) = ∏ y ∈ t, ∏ x ∈ s, f x y :=
476
- prod_comm' fun _ _ => Iff.rfl
477
-
478
372
@[to_additive]
479
373
theorem prod_filter_of_ne {p : α → Prop } [DecidablePred p] (hp : ∀ x ∈ s, f x ≠ 1 → p x) :
480
374
∏ x ∈ s with p x, f x = ∏ x ∈ s, f x :=
@@ -617,26 +511,6 @@ theorem prod_subtype {p : α → Prop} {F : Fintype (Subtype p)} (s : Finset α)
617
511
rw [← prod_coe_sort]
618
512
congr!
619
513
620
- @[to_additive]
621
- lemma prod_preimage' (f : ι → κ) [DecidablePred (· ∈ Set.range f)] (s : Finset κ) (hf) (g : κ → β) :
622
- ∏ x ∈ s.preimage f hf, g (f x) = ∏ x ∈ s with x ∈ Set.range f, g x := by
623
- classical
624
- calc
625
- ∏ x ∈ preimage s f hf, g (f x) = ∏ x ∈ image f (preimage s f hf), g x :=
626
- Eq.symm <| prod_image <| by simpa only [mem_preimage, Set.InjOn] using hf
627
- _ = ∏ x ∈ s with x ∈ Set.range f, g x := by rw [image_preimage]
628
-
629
- @[to_additive]
630
- lemma prod_preimage (f : ι → κ) (s : Finset κ) (hf) (g : κ → β)
631
- (hg : ∀ x ∈ s, x ∉ Set.range f → g x = 1 ) :
632
- ∏ x ∈ s.preimage f hf, g (f x) = ∏ x ∈ s, g x := by
633
- classical rw [prod_preimage', prod_filter_of_ne]; exact fun x hx ↦ Not.imp_symm (hg x hx)
634
-
635
- @[to_additive]
636
- lemma prod_preimage_of_bij (f : ι → κ) (s : Finset κ) (hf : Set.BijOn f (f ⁻¹' ↑s) ↑s) (g : κ → β) :
637
- ∏ x ∈ s.preimage f hf.injOn, g (f x) = ∏ x ∈ s, g x :=
638
- prod_preimage _ _ hf.injOn g fun _ hs h_f ↦ (h_f <| hf.subset_range hs).elim
639
-
640
514
@[to_additive]
641
515
theorem prod_set_coe (s : Set α) [Fintype s] : (∏ i : s, f i) = ∏ i ∈ s.toFinset, f i :=
642
516
(Finset.prod_subtype s.toFinset (fun _ ↦ Set.mem_toFinset) f).symm
@@ -1410,11 +1284,6 @@ theorem prod_erase_eq_div {a : α} (h : a ∈ s) :
1410
1284
1411
1285
end CommGroup
1412
1286
1413
- @[simp]
1414
- theorem card_sigma {σ : α → Type *} (s : Finset α) (t : ∀ a, Finset (σ a)) :
1415
- #(s.sigma t) = ∑ a ∈ s, #(t a) :=
1416
- Multiset.card_sigma _ _
1417
-
1418
1287
@[simp]
1419
1288
theorem card_disjiUnion (s : Finset α) (t : α → Finset β) (h) :
1420
1289
#(s.disjiUnion t h) = ∑ a ∈ s, #(t a) :=
@@ -1674,4 +1543,4 @@ theorem nat_abs_sum_le {ι : Type*} (s : Finset ι) (f : ι → ℤ) :
1674
1543
simp only [Finset.sum_cons, not_false_iff]
1675
1544
exact (Int.natAbs_add_le _ _).trans (Nat.add_le_add_left IH _)
1676
1545
1677
- set_option linter.style.longFile 1800
1546
+ set_option linter.style.longFile 1700
0 commit comments