File: Mathlib/Algebra/BigOperators/Ring.lean

full_name: Finset.natCast_card_filter
code: lemma natCast_card_filter (p) [DecidablePred p] (s : Finset ι) :
    ((filter p s).card : α) = ∑ a ∈ s, if p a then (1 : α) else 0 
goal: ↑(Finset.filter p s).card = ∑ a ∈ s, if p a then 1 else 0

full_name: Finset.sum_boole
code: @[simp] lemma sum_boole (p) [DecidablePred p] (s : Finset ι) :
    (∑ x ∈ s, if p x then 1 else 0 : α) = (s.filter p).card 
goal: (∑ x ∈ s, if p x then 1 else 0) = ↑(Finset.filter p s).card

full_name: Finset.sum_mul
code: lemma sum_mul (s : Finset ι) (f : ι → α) (a : α) :
    (∑ i ∈ s, f i) * a = ∑ i ∈ s, f i * a 
goal: (∑ i ∈ s, f i) * a = ∑ i ∈ s, f i * a

full_name: Finset.mul_sum
code: lemma mul_sum (s : Finset ι) (f : ι → α) (a : α) :
    a * ∑ i ∈ s, f i = ∑ i ∈ s, a * f i 
goal: a * ∑ i ∈ s, f i = ∑ i ∈ s, a * f i

full_name: Finset.sum_mul_sum
code: lemma sum_mul_sum {κ : Type*} (s : Finset ι) (t : Finset κ) (f : ι → α) (g : κ → α) :
    (∑ i ∈ s, f i) * ∑ j ∈ t, g j = ∑ i ∈ s, ∑ j ∈ t, f i * g j 
goal: (∑ i ∈ s, f i) * ∑ j ∈ t, g j = ∑ i ∈ s, ∑ j ∈ t, f i * g j

full_name: Fintype.sum_mul_sum
code: lemma _root_.Fintype.sum_mul_sum {κ : Type*} [Fintype ι] [Fintype κ] (f : ι → α) (g : κ → α) :
    (∑ i, f i) * ∑ j, g j = ∑ i, ∑ j, f i * g j 
goal: (∑ i : ι, f i) * ∑ j : κ, g j = ∑ i : ι, ∑ j : κ, f i * g j

full_name: Commute.sum_right
code: lemma _root_.Commute.sum_right [NonUnitalNonAssocSemiring α] (s : Finset ι) (f : ι → α) (b : α)
    (h : ∀ i ∈ s, Commute b (f i)) : Commute b (∑ i ∈ s, f i) 
goal: Commute b (∑ i ∈ s, f i)

full_name: Commute.sum_left
code: lemma _root_.Commute.sum_left [NonUnitalNonAssocSemiring α] (s : Finset ι) (f : ι → α) (b : α)
    (h : ∀ i ∈ s, Commute (f i) b) : Commute (∑ i ∈ s, f i) b 
goal: Commute (∑ i ∈ s, f i) b

full_name: Finset.sum_range_succ_mul_sum_range_succ
code: lemma sum_range_succ_mul_sum_range_succ (m n : ℕ) (f g : ℕ → α) :
    (∑ i ∈ range (m + 1), f i) * ∑ i ∈ range (n + 1), g i =
      (∑ i ∈ range m, f i) * ∑ i ∈ range n, g i +
        f m * ∑ i ∈ range n, g i + (∑ i ∈ range m, f i) * g n + f m * g n 
goal: (∑ i ∈ Finset.range (m + 1), f i) * ∑ i ∈ Finset.range (n + 1), g i =
  (∑ i ∈ Finset.range m, f i) * ∑ i ∈ Finset.range n, g i + f m * ∑ i ∈ Finset.range n, g i +
      (∑ i ∈ Finset.range m, f i) * g n +
    f m * g n

full_name: Finset.dvd_sum
code: lemma dvd_sum (h : ∀ i ∈ s, a ∣ f i) : a ∣ ∑ i ∈ s, f i 
goal: a ∣ ∑ i ∈ s, f i

full_name: Finset.sum_mul_boole
code: lemma sum_mul_boole (s : Finset ι) (f : ι → α) (i : ι) :
    ∑ j ∈ s, f j * ite (i = j) 1 0 = ite (i ∈ s) (f i) 0 
goal: (∑ j ∈ s, f j * if i = j then 1 else 0) = if i ∈ s then f i else 0

full_name: Finset.sum_boole_mul
code: lemma sum_boole_mul (s : Finset ι) (f : ι → α) (i : ι) :
    ∑ j ∈ s, ite (i = j) 1 0 * f j = ite (i ∈ s) (f i) 0 
goal: ∑ j ∈ s, (if i = j then 1 else 0) * f j = if i ∈ s then f i else 0

full_name: Finset.prod_add_prod_eq
code: /-- If `f = g = h` everywhere but at `i`, where `f i = g i + h i`, then the product of `f` over `s`
  is the sum of the products of `g` and `h`. -/
theorem prod_add_prod_eq {s : Finset ι} {i : ι} {f g h : ι → α} (hi : i ∈ s)
    (h1 : g i + h i = f i) (h2 : ∀ j ∈ s, j ≠ i → g j = f j) (h3 : ∀ j ∈ s, j ≠ i → h j = f j) :
    (∏ i ∈ s, g i) + ∏ i ∈ s, h i = ∏ i ∈ s, f i 
goal: ∏ i ∈ s, g i + ∏ i ∈ s, h i = ∏ i ∈ s, f i

full_name: Finset.prod_sum
code: /-- The product over a sum can be written as a sum over the product of sets, `Finset.Pi`.
  `Finset.prod_univ_sum` is an alternative statement when the product is over `univ`. -/
lemma prod_sum (s : Finset ι) (t : ∀ i, Finset (κ i)) (f : ∀ i, κ i → α) :
    ∏ a ∈ s, ∑ b ∈ t a, f a b = ∑ p ∈ s.pi t, ∏ x ∈ s.attach, f x.1 (p x.1 x.2) 
goal: ∏ a ∈ s, ∑ b ∈ t a, f a b = ∑ p ∈ s.pi t, ∏ x ∈ s.attach, f (↑x) (p ↑x ⋯)

full_name: Finset.prod_univ_sum
code: /-- The product over `univ` of a sum can be written as a sum over the product of sets,
`Fintype.piFinset`. `Finset.prod_sum` is an alternative statement when the product is not
over `univ`. -/
lemma prod_univ_sum [Fintype ι] (t : ∀ i, Finset (κ i)) (f : ∀ i, κ i → α) :
    ∏ i, ∑ j ∈ t i, f i j = ∑ x ∈ piFinset t, ∏ i, f i (x i) 
goal: ∏ i : ι, ∑ j ∈ t i, f i j = ∑ x ∈ Fintype.piFinset t, ∏ i : ι, f i (x i)

full_name: Finset.sum_prod_piFinset
code: lemma sum_prod_piFinset {κ : Type*} [Fintype ι] (s : Finset κ) (g : ι → κ → α) :
    ∑ f ∈ piFinset fun _ : ι ↦ s, ∏ i, g i (f i) = ∏ i, ∑ j ∈ s, g i j 
goal: ∑ f ∈ Fintype.piFinset fun x => s, ∏ i : ι, g i (f i) = ∏ i : ι, ∑ j ∈ s, g i j

full_name: Finset.sum_pow'
code: lemma sum_pow' (s : Finset ι) (f : ι → α) (n : ℕ) :
    (∑ a ∈ s, f a) ^ n = ∑ p ∈ piFinset fun _i : Fin n ↦ s, ∏ i, f (p i) 
goal: (∑ a ∈ s, f a) ^ n = ∑ p ∈ Fintype.piFinset fun _i => s, ∏ i : Fin n, f (p i)

full_name: Finset.prod_add
code: /-- The product of `f a + g a` over all of `s` is the sum over the powerset of `s` of the product of
`f` over a subset `t` times the product of `g` over the complement of `t`  -/
theorem prod_add (f g : ι → α) (s : Finset ι) :
    ∏ i ∈ s, (f i + g i) = ∑ t ∈ s.powerset, (∏ i ∈ t, f i) * ∏ i ∈ s \ t, g i 
goal: ∏ i ∈ s, (f i + g i) = ∑ t ∈ s.powerset, (∏ i ∈ t, f i) * ∏ i ∈ s \ t, g i

full_name: Finset.prod_add_ordered
code: /-- `∏ i, (f i + g i) = (∏ i, f i) + ∑ i, g i * (∏ j < i, f j + g j) * (∏ j > i, f j)`. -/
theorem prod_add_ordered [LinearOrder ι] [CommSemiring α] (s : Finset ι) (f g : ι → α) :
    ∏ i ∈ s, (f i + g i) =
      (∏ i ∈ s, f i) +
        ∑ i ∈ s,
          g i * (∏ j ∈ s.filter (· < i), (f j + g j)) * ∏ j ∈ s.filter fun j => i < j, f j 
goal: ∏ i ∈ s, (f i + g i) =
  ∏ i ∈ s, f i +
    ∑ i ∈ s, (g i * ∏ j ∈ Finset.filter (fun x => x < i) s, (f j + g j)) * ∏ j ∈ Finset.filter (fun j => i < j) s, f j

full_name: Finset.sum_pow_mul_eq_add_pow
code: /-- Summing `a^s.card * b^(n-s.card)` over all finite subsets `s` of a `Finset`
gives `(a + b)^s.card`. -/
theorem sum_pow_mul_eq_add_pow (a b : α) (s : Finset ι) :
    (∑ t ∈ s.powerset, a ^ t.card * b ^ (s.card - t.card)) = (a + b) ^ s.card 
goal: ∑ t ∈ s.powerset, a ^ t.card * b ^ (s.card - t.card) = (a + b) ^ s.card

full_name: Fintype.sum_pow_mul_eq_add_pow
code: /-- Summing `a^s.card * b^(n-s.card)` over all finite subsets `s` of a fintype of cardinality `n`
gives `(a + b)^n`. The "good" proof involves expanding along all coordinates using the fact that
`x^n` is multilinear, but multilinear maps are only available now over rings, so we give instead
a proof reducing to the usual binomial theorem to have a result over semirings. -/
lemma _root_.Fintype.sum_pow_mul_eq_add_pow (ι : Type*) [Fintype ι] (a b : α) :
    ∑ s : Finset ι, a ^ s.card * b ^ (Fintype.card ι - s.card) = (a + b) ^ Fintype.card ι 
goal: ∑ s : Finset ι, a ^ s.card * b ^ (Fintype.card ι - s.card) = (a + b) ^ Fintype.card ι

full_name: Finset.prod_natCast
code: @[norm_cast]
theorem prod_natCast (s : Finset ι) (f : ι → ℕ) : ↑(∏ i ∈ s, f i : ℕ) = ∏ i ∈ s, (f i : α) 
goal: ↑(∏ i ∈ s, f i) = ∏ i ∈ s, ↑(f i)

full_name: Finset.prod_sub_ordered
code: /-- `∏ i, (f i - g i) = (∏ i, f i) - ∑ i, g i * (∏ j < i, f j - g j) * (∏ j > i, f j)`. -/
lemma prod_sub_ordered [LinearOrder ι] (s : Finset ι) (f g : ι → α) :
    ∏ i ∈ s, (f i - g i) =
      (∏ i ∈ s, f i) -
        ∑ i ∈ s,
          g i * (∏ j ∈ s.filter (· < i), (f j - g j)) * ∏ j ∈ s.filter fun j => i < j, f j 
goal: ∏ i ∈ s, (f i - g i) =
  ∏ i ∈ s, f i -
    ∑ i ∈ s, (g i * ∏ j ∈ Finset.filter (fun x => x < i) s, (f j - g j)) * ∏ j ∈ Finset.filter (fun j => i < j) s, f j

full_name: Finset.prod_one_sub_ordered
code: /-- `∏ i, (1 - f i) = 1 - ∑ i, f i * (∏ j < i, 1 - f j)`. This formula is useful in construction of
a partition of unity from a collection of “bump” functions.  -/
theorem prod_one_sub_ordered [LinearOrder ι] (s : Finset ι) (f : ι → α) :
    ∏ i ∈ s, (1 - f i) = 1 - ∑ i ∈ s, f i * ∏ j ∈ s.filter (· < i), (1 - f j) 
goal: ∏ i ∈ s, (1 - f i) = 1 - ∑ i ∈ s, f i * ∏ j ∈ Finset.filter (fun x => x < i) s, (1 - f j)

full_name: Finset.prod_range_natCast_sub
code: theorem prod_range_natCast_sub (n k : ℕ) :
    ∏ i ∈ range k, (n - i : α) = (∏ i ∈ range k, (n - i) : ℕ) 
goal: ∏ i ∈ Finset.range k, (↑n - ↑i) = ↑(∏ i ∈ Finset.range k, (n - i))

full_name: Finset.sum_div
code: lemma sum_div (s : Finset ι) (f : ι → α) (a : α) :
    (∑ i ∈ s, f i) / a = ∑ i ∈ s, f i / a 
goal: (∑ i ∈ s, f i) / a = ∑ i ∈ s, f i / a

full_name: Fintype.sum_pow
code: lemma sum_pow (f : ι → α) (n : ℕ) : (∑ a, f a) ^ n = ∑ p : Fin n → ι, ∏ i, f (p i) 
goal: (∑ a : ι, f a) ^ n = ∑ p : Fin n → ι, ∏ i : Fin n, f (p i)

full_name: Fintype.prod_sum
code: /-- A product of sums can be written as a sum of products. -/
lemma prod_sum {κ : ι → Type*} [Fintype ι] [∀ i, Fintype (κ i)] (f : ∀ i, κ i → α) :
    ∏ i, ∑ j, f i j = ∑ x : ∀ i, κ i, ∏ i, f i (x i) 
goal: ∏ i : ι, ∑ j : κ i, f i j = ∑ x : (i : ι) → κ i, ∏ i : ι, f i (x i)

full_name: Fintype.prod_add
code: lemma prod_add (f g : ι → α) : ∏ a, (f a + g a) = ∑ t, (∏ a ∈ t, f a) * ∏ a ∈ tᶜ, g a 
goal: ∏ a : ι, (f a + g a) = ∑ t : Finset ι, (∏ a ∈ t, f a) * ∏ a ∈ tᶜ, g a

full_name: Nat.sum_div
code: protected lemma sum_div (hf : ∀ i ∈ s, n ∣ f i) : (∑ i ∈ s, f i) / n = ∑ i ∈ s, f i / n 
goal: (∑ i ∈ s, f i) / n = ∑ i ∈ s, f i / n

full_name: Nat.cast_list_sum
code: @[simp, norm_cast]
lemma cast_list_sum [AddMonoidWithOne β] (s : List ℕ) : (↑s.sum : β) = (s.map (↑)).sum 
goal: ↑s.sum = (List.map Nat.cast s).sum

full_name: Nat.cast_list_prod
code: @[simp, norm_cast]
lemma cast_list_prod [Semiring β] (s : List ℕ) : (↑s.prod : β) = (s.map (↑)).prod 
goal: ↑s.prod = (List.map Nat.cast s).prod

full_name: Nat.cast_multiset_sum
code: @[simp, norm_cast]
lemma cast_multiset_sum [AddCommMonoidWithOne β] (s : Multiset ℕ) :
    (↑s.sum : β) = (s.map (↑)).sum 
goal: ↑s.sum = (Multiset.map Nat.cast s).sum

full_name: Nat.cast_multiset_prod
code: @[simp, norm_cast]
lemma cast_multiset_prod [CommSemiring β] (s : Multiset ℕ) : (↑s.prod : β) = (s.map (↑)).prod 
goal: ↑s.prod = (Multiset.map Nat.cast s).prod

full_name: Nat.cast_sum
code: @[simp, norm_cast]
lemma cast_sum [AddCommMonoidWithOne β] (s : Finset α) (f : α → ℕ) :
    ↑(∑ x ∈ s, f x : ℕ) = ∑ x ∈ s, (f x : β) 
goal: ↑(∑ x ∈ s, f x) = ∑ x ∈ s, ↑(f x)

full_name: Nat.cast_prod
code: @[simp, norm_cast]
lemma cast_prod [CommSemiring β] (f : α → ℕ) (s : Finset α) :
    (↑(∏ i ∈ s, f i) : β) = ∏ i ∈ s, (f i : β) 
goal: ↑(∏ i ∈ s, f i) = ∏ i ∈ s, ↑(f i)

full_name: Int.sum_div
code: protected lemma sum_div (hf : ∀ i ∈ s, n ∣ f i) : (∑ i ∈ s, f i) / n = ∑ i ∈ s, f i / n 
goal: (∑ i ∈ s, f i) / n = ∑ i ∈ s, f i / n

full_name: Int.cast_list_sum
code: @[simp, norm_cast]
lemma cast_list_sum [AddGroupWithOne β] (s : List ℤ) : (↑s.sum : β) = (s.map (↑)).sum 
goal: ↑s.sum = (List.map Int.cast s).sum

full_name: Int.cast_list_prod
code: @[simp, norm_cast]
lemma cast_list_prod [Ring β] (s : List ℤ) : (↑s.prod : β) = (s.map (↑)).prod 
goal: ↑s.prod = (List.map Int.cast s).prod

full_name: Int.cast_multiset_sum
code: @[simp, norm_cast]
lemma cast_multiset_sum [AddCommGroupWithOne β] (s : Multiset ℤ) :
    (↑s.sum : β) = (s.map (↑)).sum 
goal: ↑s.sum = (Multiset.map Int.cast s).sum

full_name: Int.cast_multiset_prod
code: @[simp, norm_cast]
lemma cast_multiset_prod {R : Type*} [CommRing R] (s : Multiset ℤ) :
    (↑s.prod : R) = (s.map (↑)).prod 
goal: ↑s.prod = (Multiset.map Int.cast s).prod

full_name: Int.cast_sum
code: @[simp, norm_cast]
lemma cast_sum [AddCommGroupWithOne β] (s : Finset α) (f : α → ℤ) :
    ↑(∑ x ∈ s, f x : ℤ) = ∑ x ∈ s, (f x : β) 
goal: ↑(∑ x ∈ s, f x) = ∑ x ∈ s, ↑(f x)

full_name: Int.cast_prod
code: @[simp, norm_cast]
lemma cast_prod {R : Type*} [CommRing R] (f : α → ℤ) (s : Finset α) :
    (↑(∏ i ∈ s, f i) : R) = ∏ i ∈ s, (f i : R) 
goal: ↑(∏ i ∈ s, f i) = ∏ i ∈ s, ↑(f i)