Module docstring
{"# Results about big operators with values in a (semi)ring
We prove results about big operators that involve some interaction between multiplicative and additive structures on the values being combined. "}
{"# Results about big operators with values in a (semi)ring
We prove results about big operators that involve some interaction between multiplicative and additive structures on the values being combined. "}
Finset.prod_neg
theorem
[CommMonoid α] [HasDistribNeg α] : ∏ x ∈ s, -f x = (-1) ^ #s * ∏ x ∈ s, f x
lemma prod_neg [CommMonoid α] [HasDistribNeg α] : ∏ x ∈ s, -f x = (-1) ^ #s * ∏ x ∈ s, f x := by
simpa using (s.1.map f).prod_map_neg
Finset.natCast_card_filter
theorem
(p) [DecidablePred p] (s : Finset ι) : (#({x ∈ s | p x}) : α) = ∑ a ∈ s, if p a then (1 : α) else 0
lemma natCast_card_filter (p) [DecidablePred p] (s : Finset ι) :
(#{x ∈ s | p x} : α) = ∑ a ∈ s, if p a then (1 : α) else 0 := by
rw [sum_ite, sum_const_zero, add_zero, sum_const, nsmul_one]
Finset.sum_boole
theorem
(p) [DecidablePred p] (s : Finset ι) : (∑ x ∈ s, if p x then 1 else 0 : α) = #({x ∈ s | p x})
@[simp] lemma sum_boole (p) [DecidablePred p] (s : Finset ι) :
(∑ x ∈ s, if p x then 1 else 0 : α) = #{x ∈ s | p x} :=
(natCast_card_filter _ _).symm
Finset.sum_mul
theorem
(s : Finset ι) (f : ι → α) (a : α) : (∑ i ∈ s, f i) * a = ∑ i ∈ s, f i * a
lemma sum_mul (s : Finset ι) (f : ι → α) (a : α) :
(∑ i ∈ s, f i) * a = ∑ i ∈ s, f i * a := map_sum (AddMonoidHom.mulRight a) _ s
Finset.mul_sum
theorem
(s : Finset ι) (f : ι → α) (a : α) : a * ∑ i ∈ s, f i = ∑ i ∈ s, a * f i
lemma mul_sum (s : Finset ι) (f : ι → α) (a : α) :
a * ∑ i ∈ s, f i = ∑ i ∈ s, a * f i := map_sum (AddMonoidHom.mulLeft a) _ s
Finset.sum_mul_sum
theorem
{κ : Type*} (s : Finset ι) (t : Finset κ) (f : ι → α) (g : κ → α) :
(∑ i ∈ s, f i) * ∑ j ∈ t, g j = ∑ i ∈ s, ∑ j ∈ t, f i * g j
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 := by
simp_rw [sum_mul, ← mul_sum]
Fintype.sum_mul_sum
theorem
{κ : Type*} [Fintype ι] [Fintype κ] (f : ι → α) (g : κ → α) : (∑ i, f i) * ∑ j, g j = ∑ i, ∑ j, f i * g j
lemma _root_.Fintype.sum_mul_sum {κ : Type*} [Fintype ι] [Fintype κ] (f : ι → α) (g : κ → α) :
(∑ i, f i) * ∑ j, g j = ∑ i, ∑ j, f i * g j :=
Finset.sum_mul_sum _ _ _ _
Commute.sum_right
theorem
(s : Finset ι) (f : ι → α) (b : α) (h : ∀ i ∈ s, Commute b (f i)) : Commute b (∑ i ∈ s, f i)
lemma _root_.Commute.sum_right (s : Finset ι) (f : ι → α) (b : α)
(h : ∀ i ∈ s, Commute b (f i)) : Commute b (∑ i ∈ s, f i) :=
(Commute.multiset_sum_right _ _) fun b hb => by
obtain ⟨i, hi, rfl⟩ := Multiset.mem_map.mp hb
exact h _ hi
Commute.sum_left
theorem
(s : Finset ι) (f : ι → α) (b : α) (h : ∀ i ∈ s, Commute (f i) b) : Commute (∑ i ∈ s, f i) b
lemma _root_.Commute.sum_left (s : Finset ι) (f : ι → α) (b : α)
(h : ∀ i ∈ s, Commute (f i) b) : Commute (∑ i ∈ s, f i) b :=
((Commute.sum_right _ _ _) fun _i hi => (h _ hi).symm).symm
Finset.sum_range_succ_mul_sum_range_succ
theorem
(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
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 := by
simp only [add_mul, mul_add, add_assoc, sum_range_succ]
Finset.dvd_sum
theorem
(h : ∀ i ∈ s, a ∣ f i) : a ∣ ∑ i ∈ s, f i
lemma dvd_sum (h : ∀ i ∈ s, a ∣ f i) : a ∣ ∑ i ∈ s, f i :=
Multiset.dvd_sum fun y hy => by rcases Multiset.mem_map.1 hy with ⟨x, hx, rfl⟩; exact h x hx
Finset.sum_mul_boole
theorem
(s : Finset ι) (f : ι → α) (i : ι) : ∑ j ∈ s, f j * ite (i = j) 1 0 = ite (i ∈ s) (f i) 0
lemma sum_mul_boole (s : Finset ι) (f : ι → α) (i : ι) :
∑ j ∈ s, f j * ite (i = j) 1 0 = ite (i ∈ s) (f i) 0 := by simp
Finset.sum_boole_mul
theorem
(s : Finset ι) (f : ι → α) (i : ι) : ∑ j ∈ s, ite (i = j) 1 0 * f j = ite (i ∈ s) (f i) 0
lemma sum_boole_mul (s : Finset ι) (f : ι → α) (i : ι) :
∑ j ∈ s, ite (i = j) 1 0 * f j = ite (i ∈ s) (f i) 0 := by simp
Finset.prod_add_prod_eq
theorem
{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
/-- 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 := by
classical
simp_rw [prod_eq_mul_prod_diff_singleton hi, ← h1, right_distrib]
congr 2 <;> apply prod_congr rfl <;> simpa
Finset.prod_sum
theorem
(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)
/-- 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) := by
classical
induction s using Finset.induction with
| empty => simp
| insert a s ha ih =>
have h₁ : ∀ x ∈ t a, ∀ y ∈ t a, x ≠ y →
Disjoint (image (Pi.cons s a x) (pi s t)) (image (Pi.cons s a y) (pi s t)) := by
intro x _ y _ h
simp only [disjoint_iff_ne, mem_image]
rintro _ ⟨p₂, _, eq₂⟩ _ ⟨p₃, _, eq₃⟩ eq
have : Pi.cons s a x p₂ a (mem_insert_self _ _)
= Pi.cons s a y p₃ a (mem_insert_self _ _) := by rw [eq₂, eq₃, eq]
rw [Pi.cons_same, Pi.cons_same] at this
exact h this
rw [prod_insert ha, pi_insert ha, ih, sum_mul, sum_biUnion h₁]
refine sum_congr rfl fun b _ => ?_
have h₂ : ∀ p₁ ∈ pi s t, ∀ p₂ ∈ pi s t, Pi.cons s a b p₁ = Pi.cons s a b p₂ → p₁ = p₂ :=
fun p₁ _ p₂ _ eq => Pi.cons_injective ha eq
rw [sum_image h₂, mul_sum]
refine sum_congr rfl fun g _ => ?_
rw [attach_insert, prod_insert, prod_image]
· simp only [Pi.cons_same]
congr with ⟨v, hv⟩
congr
exact (Pi.cons_ne (by rintro rfl; exact ha hv)).symm
· exact fun _ _ _ _ => Subtype.eqSubtype.eq ∘ Subtype.mk.inj
· simpa only [mem_image, mem_attach, Subtype.mk.injEq, true_and,
Subtype.exists, exists_prop, exists_eq_right] using ha
Finset.prod_univ_sum
theorem
[Fintype ι] (t : ∀ i, Finset (κ i)) (f : ∀ i, κ i → α) : ∏ i, ∑ j ∈ t i, f i j = ∑ x ∈ piFinset t, ∏ i, f i (x i)
/-- 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) := by
simp only [prod_attach_univ, prod_sum, Finset.sum_univ_pi]
Finset.sum_prod_piFinset
theorem
{κ : Type*} [Fintype ι] (s : Finset κ) (g : ι → κ → α) :
∑ f ∈ piFinset fun _ : ι ↦ s, ∏ i, g i (f i) = ∏ i, ∑ j ∈ s, g i j
lemma sum_prod_piFinset {κ : Type*} [Fintype ι] (s : Finset κ) (g : ι → κ → α) :
∑ f ∈ piFinset fun _ : ι ↦ s, ∏ i, g i (f i) = ∏ i, ∑ j ∈ s, g i j := by
rw [← prod_univ_sum]
Finset.sum_pow'
theorem
(s : Finset ι') (f : ι' → α) (n : ℕ) : (∑ a ∈ s, f a) ^ n = ∑ p ∈ piFinset fun _i : Fin n ↦ s, ∏ i, f (p i)
lemma sum_pow' (s : Finset ι') (f : ι' → α) (n : ℕ) :
(∑ a ∈ s, f a) ^ n = ∑ p ∈ piFinset fun _i : Fin n ↦ s, ∏ i, f (p i) := by
convert @prod_univ_sum (Fin n) _ _ _ _ _ (fun _i ↦ s) fun _i d ↦ f d; simp
Finset.prod_add
theorem
(f g : ι → α) (s : Finset ι) : ∏ i ∈ s, (f i + g i) = ∑ t ∈ s.powerset, (∏ i ∈ t, f i) * ∏ i ∈ s \ t, g i
/-- 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 := by
classical
calc
∏ i ∈ s, (f i + g i) =
∏ i ∈ s, ∑ p ∈ ({True, False} : Finset Prop), if p then f i else g i := by simp
_ = ∑ p ∈ (s.pi fun _ => {True, False} : Finset (∀ a ∈ s, Prop)),
∏ a ∈ s.attach, if p a.1 a.2 then f a.1 else g a.1 := prod_sum _ _ _
_ = ∑ t ∈ s.powerset, (∏ a ∈ t, f a) * ∏ a ∈ s \ t, g a :=
sum_bij'
(fun f _ ↦ {a ∈ s | ∃ h : a ∈ s, f a h})
(fun t _ a _ => a ∈ t)
(by simp)
(by simp [Classical.em])
(by simp_rw [mem_filter, funext_iff, eq_iff_iff, mem_pi, mem_insert]; tauto)
(by simp_rw [Finset.ext_iff, @mem_filter _ _ (id _), mem_powerset]; tauto)
(fun a _ ↦ by
simp only [prod_ite, filter_attach', prod_map, Function.Embedding.coeFn_mk,
Subtype.map_coe, id_eq, prod_attach, filter_congr_decidable]
congr 2 with x
simp only [mem_filter, mem_sdiff, not_and, not_exists, and_congr_right_iff]
tauto)
Finset.prod_one_add
theorem
{f : ι → α} (s : Finset ι) : ∏ i ∈ s, (1 + f i) = ∑ t ∈ s.powerset, ∏ i ∈ t, f i
theorem prod_one_add {f : ι → α} (s : Finset ι) :
∏ i ∈ s, (1 + f i) = ∑ t ∈ s.powerset, ∏ i ∈ t, f i := by
classical simp only [add_comm (1 : α), prod_add, prod_const_one, mul_one]
Finset.prod_add_one
theorem
{f : ι → α} (s : Finset ι) : ∏ i ∈ s, (f i + 1) = ∑ t ∈ s.powerset, ∏ i ∈ t, f i
theorem prod_add_one {f : ι → α} (s : Finset ι) :
∏ i ∈ s, (f i + 1) = ∑ t ∈ s.powerset, ∏ i ∈ t, f i := by
classical simp only [prod_add, prod_const_one, mul_one]
Finset.prod_add_ordered
theorem
[LinearOrder ι] (s : Finset ι) (f g : ι → α) :
∏ i ∈ s, (f i + g i) = (∏ i ∈ s, f i) + ∑ i ∈ s, g i * (∏ j ∈ s with j < i, (f j + g j)) * ∏ j ∈ s with i < j, f j
/-- `∏ 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 ι] (s : Finset ι) (f g : ι → α) :
∏ i ∈ s, (f i + g i) =
(∏ i ∈ s, f i) +
∑ i ∈ s, g i * (∏ j ∈ s with j < i, (f j + g j)) * ∏ j ∈ s with i < j, f j := by
refine Finset.induction_on_max s (by simp) ?_
clear s
intro a s ha ihs
have ha' : a ∉ s := fun ha' => lt_irrefl a (ha a ha')
rw [prod_insert ha', prod_insert ha', sum_insert ha', filter_insert, if_neg (lt_irrefl a),
filter_true_of_mem ha, ihs, add_mul, mul_add, mul_add, add_assoc]
congr 1
rw [add_comm]
congr 1
· rw [filter_false_of_mem, prod_empty, mul_one]
exact (forall_mem_insert _ _ _).2 ⟨lt_irrefl a, fun i hi => (ha i hi).not_lt⟩
· rw [mul_sum]
refine sum_congr rfl fun i hi => ?_
rw [filter_insert, if_neg (ha i hi).not_lt, filter_insert, if_pos (ha i hi), prod_insert,
mul_left_comm]
exact mt (fun ha => (mem_filter.1 ha).1) ha'
Finset.sum_pow_mul_eq_add_pow
theorem
(a b : α) (s : Finset ι) : (∑ t ∈ s.powerset, a ^ #t * b ^ (#s - #t)) = (a + b) ^ #s
/-- Summing `a ^ #t * b ^ (n - #t)` over all finite subsets `t` of a finset `s`
gives `(a + b) ^ #s`. -/
theorem sum_pow_mul_eq_add_pow (a b : α) (s : Finset ι) :
(∑ t ∈ s.powerset, a ^ #t * b ^ (#s - #t)) = (a + b) ^ #s := by
classical
rw [← prod_const, prod_add]
refine Finset.sum_congr rfl fun t ht => ?_
rw [prod_const, prod_const, ← card_sdiff (mem_powerset.1 ht)]
Fintype.sum_pow_mul_eq_add_pow
theorem
(ι : Type*) [Fintype ι] (a b : α) : ∑ s : Finset ι, a ^ #s * b ^ (Fintype.card ι - #s) = (a + b) ^ Fintype.card ι
/-- Summing `a^#s * b^(n-#s)` 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 * b ^ (Fintype.card ι - #s) = (a + b) ^ Fintype.card ι :=
Finset.sum_pow_mul_eq_add_pow _ _ _
Finset.prod_natCast
theorem
(s : Finset ι) (f : ι → ℕ) : ↑(∏ i ∈ s, f i : ℕ) = ∏ i ∈ s, (f i : α)
@[norm_cast]
theorem prod_natCast (s : Finset ι) (f : ι → ℕ) : ↑(∏ i ∈ s, f i : ℕ) = ∏ i ∈ s, (f i : α) :=
map_prod (Nat.castRingHom α) f s
Finset.prod_sub
theorem
[DecidableEq ι] (f g : ι → α) (s : Finset ι) :
∏ i ∈ s, (f i - g i) = ∑ t ∈ s.powerset, (-1) ^ #t * (∏ i ∈ s \ t, f i) * ∏ i ∈ t, g i
/-- The product of `f i - g i` over all of `s` is the sum over the powerset of `s` of the product of
`g` over a subset `t` times the product of `f` over the complement of `t` times `(-1) ^ #t`. -/
lemma prod_sub [DecidableEq ι] (f g : ι → α) (s : Finset ι) :
∏ i ∈ s, (f i - g i) = ∑ t ∈ s.powerset, (-1) ^ #t * (∏ i ∈ s \ t, f i) * ∏ i ∈ t, g i := by
simp [sub_eq_neg_add, prod_add, prod_neg, mul_right_comm]
Finset.prod_sub_ordered
theorem
[LinearOrder ι] (s : Finset ι) (f g : ι → α) :
∏ i ∈ s, (f i - g i) = (∏ i ∈ s, f i) - ∑ i ∈ s, g i * (∏ j ∈ s with j < i, (f j - g j)) * ∏ j ∈ s with i < j, f j
/-- `∏ 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 with j < i, (f j - g j)) * ∏ j ∈ s with i < j, f j := by
simp only [sub_eq_add_neg]
convert prod_add_ordered s f fun i => -g i
simp
Finset.prod_one_sub_ordered
theorem
[LinearOrder ι] (s : Finset ι) (f : ι → α) : ∏ i ∈ s, (1 - f i) = 1 - ∑ i ∈ s, f i * ∏ j ∈ s with j < i, (1 - f j)
/-- `∏ 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 with j < i, (1 - f j) := by
rw [prod_sub_ordered]
simp
Finset.prod_range_natCast_sub
theorem
(n k : ℕ) : ∏ i ∈ range k, (n - i : α) = (∏ i ∈ range k, (n - i) : ℕ)
theorem prod_range_natCast_sub (n k : ℕ) :
∏ i ∈ range k, (n - i : α) = (∏ i ∈ range k, (n - i) : ℕ) := by
rw [prod_natCast]
rcases le_or_lt k n with hkn | hnk
· exact prod_congr rfl fun i hi => (Nat.cast_sub <| (mem_range.1 hi).le.trans hkn).symm
· rw [← mem_range] at hnk
rw [prod_eq_zero hnk, prod_eq_zero hnk] <;> simp
Fintype.sum_pow
theorem
(f : ι → α) (n : ℕ) : (∑ a, f a) ^ n = ∑ p : Fin n → ι, ∏ i, f (p i)
lemma sum_pow (f : ι → α) (n : ℕ) : (∑ a, f a) ^ n = ∑ p : Fin n → ι, ∏ i, f (p i) := by
simp [sum_pow']
Fintype.prod_sum
theorem
{κ : ι → Type*} [∀ i, Fintype (κ i)] (f : ∀ i, κ i → α) : ∏ i, ∑ j, f i j = ∑ x : ∀ i, κ i, ∏ i, f i (x i)
/-- A product of sums can be written as a sum of products. -/
lemma prod_sum {κ : ι → Type*} [∀ i, Fintype (κ i)] (f : ∀ i, κ i → α) :
∏ i, ∑ j, f i j = ∑ x : ∀ i, κ i, ∏ i, f i (x i) := Finset.prod_univ_sum _ _
Fintype.prod_add
theorem
(f g : ι → α) : ∏ a, (f a + g a) = ∑ t, (∏ a ∈ t, f a) * ∏ a ∈ tᶜ, g a
lemma prod_add (f g : ι → α) : ∏ a, (f a + g a) = ∑ t, (∏ a ∈ t, f a) * ∏ a ∈ tᶜ, g a := by
simpa [compl_eq_univ_sdiff] using Finset.prod_add f g univ
Nat.sum_div
theorem
(hf : ∀ i ∈ s, n ∣ f i) : (∑ i ∈ s, f i) / n = ∑ i ∈ s, f i / n
protected lemma sum_div (hf : ∀ i ∈ s, n ∣ f i) : (∑ i ∈ s, f i) / n = ∑ i ∈ s, f i / n := by
obtain rfl | hn := n.eq_zero_or_pos
· simp
rw [Nat.div_eq_iff_eq_mul_left hn (dvd_sum hf), sum_mul]
refine sum_congr rfl fun s hs ↦ ?_
rw [Nat.div_mul_cancel (hf _ hs)]
Nat.cast_list_sum
theorem
[AddMonoidWithOne β] (s : List ℕ) : (↑s.sum : β) = (s.map (↑)).sum
@[simp, norm_cast]
lemma cast_list_sum [AddMonoidWithOne β] (s : List ℕ) : (↑s.sum : β) = (s.map (↑)).sum :=
map_list_sum (castAddMonoidHom β) _
Nat.cast_list_prod
theorem
[Semiring β] (s : List ℕ) : (↑s.prod : β) = (s.map (↑)).prod
@[simp, norm_cast]
lemma cast_list_prod [Semiring β] (s : List ℕ) : (↑s.prod : β) = (s.map (↑)).prod :=
map_list_prod (castRingHom β) _
Nat.cast_multiset_sum
theorem
[AddCommMonoidWithOne β] (s : Multiset ℕ) : (↑s.sum : β) = (s.map (↑)).sum
@[simp, norm_cast]
lemma cast_multiset_sum [AddCommMonoidWithOne β] (s : Multiset ℕ) :
(↑s.sum : β) = (s.map (↑)).sum :=
map_multiset_sum (castAddMonoidHom β) _
Nat.cast_multiset_prod
theorem
[CommSemiring β] (s : Multiset ℕ) : (↑s.prod : β) = (s.map (↑)).prod
@[simp, norm_cast]
lemma cast_multiset_prod [CommSemiring β] (s : Multiset ℕ) : (↑s.prod : β) = (s.map (↑)).prod :=
map_multiset_prod (castRingHom β) _
Nat.cast_sum
theorem
[AddCommMonoidWithOne β] (s : Finset α) (f : α → ℕ) : ↑(∑ x ∈ s, f x : ℕ) = ∑ x ∈ s, (f x : β)
@[simp, norm_cast]
lemma cast_sum [AddCommMonoidWithOne β] (s : Finset α) (f : α → ℕ) :
↑(∑ x ∈ s, f x : ℕ) = ∑ x ∈ s, (f x : β) :=
map_sum (castAddMonoidHom β) _ _
Nat.cast_prod
theorem
[CommSemiring β] (f : α → ℕ) (s : Finset α) : (↑(∏ i ∈ s, f i) : β) = ∏ i ∈ s, (f i : β)
@[simp, norm_cast]
lemma cast_prod [CommSemiring β] (f : α → ℕ) (s : Finset α) :
(↑(∏ i ∈ s, f i) : β) = ∏ i ∈ s, (f i : β) :=
map_prod (castRingHom β) _ _
Int.sum_div
theorem
(hf : ∀ i ∈ s, n ∣ f i) : (∑ i ∈ s, f i) / n = ∑ i ∈ s, f i / n
protected lemma sum_div (hf : ∀ i ∈ s, n ∣ f i) : (∑ i ∈ s, f i) / n = ∑ i ∈ s, f i / n := by
obtain rfl | hn := eq_or_ne n 0
· simp
rw [Int.ediv_eq_iff_eq_mul_left hn (dvd_sum hf), sum_mul]
refine sum_congr rfl fun s hs ↦ ?_
rw [Int.ediv_mul_cancel (hf _ hs)]
Int.cast_list_sum
theorem
[AddGroupWithOne β] (s : List ℤ) : (↑s.sum : β) = (s.map (↑)).sum
@[simp, norm_cast]
lemma cast_list_sum [AddGroupWithOne β] (s : List ℤ) : (↑s.sum : β) = (s.map (↑)).sum :=
map_list_sum (castAddHom β) _
Int.cast_list_prod
theorem
[Ring β] (s : List ℤ) : (↑s.prod : β) = (s.map (↑)).prod
@[simp, norm_cast]
lemma cast_list_prod [Ring β] (s : List ℤ) : (↑s.prod : β) = (s.map (↑)).prod :=
map_list_prod (castRingHom β) _
Int.cast_multiset_sum
theorem
[AddCommGroupWithOne β] (s : Multiset ℤ) : (↑s.sum : β) = (s.map (↑)).sum
@[simp, norm_cast]
lemma cast_multiset_sum [AddCommGroupWithOne β] (s : Multiset ℤ) :
(↑s.sum : β) = (s.map (↑)).sum :=
map_multiset_sum (castAddHom β) _
Int.cast_multiset_prod
theorem
{R : Type*} [CommRing R] (s : Multiset ℤ) : (↑s.prod : R) = (s.map (↑)).prod
@[simp, norm_cast]
lemma cast_multiset_prod {R : Type*} [CommRing R] (s : Multiset ℤ) :
(↑s.prod : R) = (s.map (↑)).prod :=
map_multiset_prod (castRingHom R) _
Int.cast_sum
theorem
[AddCommGroupWithOne β] (s : Finset α) (f : α → ℤ) : ↑(∑ x ∈ s, f x : ℤ) = ∑ x ∈ s, (f x : β)
@[simp, norm_cast]
lemma cast_sum [AddCommGroupWithOne β] (s : Finset α) (f : α → ℤ) :
↑(∑ x ∈ s, f x : ℤ) = ∑ x ∈ s, (f x : β) :=
map_sum (castAddHom β) _ _
Int.cast_prod
theorem
{R : Type*} [CommRing R] (f : α → ℤ) (s : Finset α) : (↑(∏ i ∈ s, f i) : R) = ∏ i ∈ s, (f i : R)
@[simp, norm_cast]
lemma cast_prod {R : Type*} [CommRing R] (f : α → ℤ) (s : Finset α) :
(↑(∏ i ∈ s, f i) : R) = ∏ i ∈ s, (f i : R) :=
map_prod (Int.castRingHom R) _ _