The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V03. Sets, finite structures and big operators

Mathlib.Algebra.BigOperators.Group.List.Basic

116 declarations. Mathlib docs · Source

theorem List.rel_prod E1 #

∀ {M : Type u_4} {N : Type u_5} [inst : Monoid M] [inst_1 : Monoid N] {R : M → N → Prop},
  R 1 1 →
    (Relator.LiftFun R (Relator.LiftFun R R) (fun x1 x2 ↦ x1 * x2) fun x1 x2 ↦ x1 * x2) →
      Relator.LiftFun (List.Forall₂ R) R List.prod List.prod

theorem List.rel_sum E1 #

∀ {M : Type u_4} {N : Type u_5} [inst : AddMonoid M] [inst_1 : AddMonoid N] {R : M → N → Prop},
  R 0 0 →
    (Relator.LiftFun R (Relator.LiftFun R R) (fun x1 x2 ↦ x1 + x2) fun x1 x2 ↦ x1 + x2) →
      Relator.LiftFun (List.Forall₂ R) R List.sum List.sum

theorem List.sum_hom_nonempty E1 #

∀ {M : Type u_4} {N : Type u_5} [inst : AddMonoid M] [inst_1 : AddMonoid N] {l : List M} {F : Type u_8}
  [inst_2 : FunLike F M N] [AddHomClass F M N] (f : F), l ≠ [] → (List.map (⇑f) l).sum = f l.sum

theorem List.prod_hom_nonempty E1 #

∀ {M : Type u_4} {N : Type u_5} [inst : Monoid M] [inst_1 : Monoid N] {l : List M} {F : Type u_8}
  [inst_2 : FunLike F M N] [MulHomClass F M N] (f : F), l ≠ [] → (List.map (⇑f) l).prod = f l.prod

theorem List.prod_hom E1 #

∀ {M : Type u_4} {N : Type u_5} [inst : Monoid M] [inst_1 : Monoid N] (l : List M) {F : Type u_8}
  [inst_2 : FunLike F M N] [MonoidHomClass F M N] (f : F), (List.map (⇑f) l).prod = f l.prod

theorem List.sum_hom E1 #

∀ {M : Type u_4} {N : Type u_5} [inst : AddMonoid M] [inst_1 : AddMonoid N] (l : List M) {F : Type u_8}
  [inst_2 : FunLike F M N] [AddMonoidHomClass F M N] (f : F), (List.map (⇑f) l).sum = f l.sum

theorem List.prod_hom₂_nonempty E1 #

∀ {ι : Type u_1} {M : Type u_4} {N : Type u_5} {P : Type u_6} [inst : Monoid M] [inst_1 : Monoid N] [inst_2 : Monoid P]
  {l : List ι} (f : M → N → P),
  (∀ (a b : M) (c d : N), f (a * b) (c * d) = f a c * f b d) →
    ∀ (f₁ : ι → M) (f₂ : ι → N),
      l ≠ [] → (List.map (fun i ↦ f (f₁ i) (f₂ i)) l).prod = f (List.map f₁ l).prod (List.map f₂ l).prod

theorem List.sum_hom₂_nonempty E1 #

∀ {ι : Type u_1} {M : Type u_4} {N : Type u_5} {P : Type u_6} [inst : AddMonoid M] [inst_1 : AddMonoid N]
  [inst_2 : AddMonoid P] {l : List ι} (f : M → N → P),
  (∀ (a b : M) (c d : N), f (a + b) (c + d) = f a c + f b d) →
    ∀ (f₁ : ι → M) (f₂ : ι → N),
      l ≠ [] → (List.map (fun i ↦ f (f₁ i) (f₂ i)) l).sum = f (List.map f₁ l).sum (List.map f₂ l).sum

theorem List.sum_hom₂ E1 #

∀ {ι : Type u_1} {M : Type u_4} {N : Type u_5} {P : Type u_6} [inst : AddMonoid M] [inst_1 : AddMonoid N]
  [inst_2 : AddMonoid P] (l : List ι) (f : M → N → P),
  (∀ (a b : M) (c d : N), f (a + b) (c + d) = f a c + f b d) →
    f 0 0 = 0 →
      ∀ (f₁ : ι → M) (f₂ : ι → N),
        (List.map (fun i ↦ f (f₁ i) (f₂ i)) l).sum = f (List.map f₁ l).sum (List.map f₂ l).sum

theorem List.prod_hom₂ E1 #

∀ {ι : Type u_1} {M : Type u_4} {N : Type u_5} {P : Type u_6} [inst : Monoid M] [inst_1 : Monoid N] [inst_2 : Monoid P]
  (l : List ι) (f : M → N → P),
  (∀ (a b : M) (c d : N), f (a * b) (c * d) = f a c * f b d) →
    f 1 1 = 1 →
      ∀ (f₁ : ι → M) (f₂ : ι → N),
        (List.map (fun i ↦ f (f₁ i) (f₂ i)) l).prod = f (List.map f₁ l).prod (List.map f₂ l).prod

theorem List.prod_map_mul E0 #

∀ {ι : Type u_1} {M : Type u_8} [inst : CommMonoid M] {l : List ι} {f g : ι → M},
  (List.map (fun i ↦ f i * g i) l).prod = (List.map f l).prod * (List.map g l).prod

theorem List.sum_map_add E0 #

∀ {ι : Type u_1} {M : Type u_8} [inst : AddCommMonoid M] {l : List ι} {f g : ι → M},
  (List.map (fun i ↦ f i + g i) l).sum = (List.map f l).sum + (List.map g l).sum

theorem List.prod_map_hom E1 #

∀ {ι : Type u_1} {M : Type u_4} {N : Type u_5} [inst : Monoid M] [inst_1 : Monoid N] (L : List ι) (f : ι → M)
  {G : Type u_8} [inst_2 : FunLike G M N] [MonoidHomClass G M N] (g : G),
  (List.map (⇑g ∘ f) L).prod = g (List.map f L).prod

theorem List.sum_map_hom E1 #

∀ {ι : Type u_1} {M : Type u_4} {N : Type u_5} [inst : AddMonoid M] [inst_1 : AddMonoid N] (L : List ι) (f : ι → M)
  {G : Type u_8} [inst_2 : FunLike G M N] [AddMonoidHomClass G M N] (g : G),
  (List.map (⇑g ∘ f) L).sum = g (List.map f L).sum

theorem List.prod_take_mul_prod_drop E0 #

∀ {M : Type u_4} [inst : Monoid M] (L : List M) (i : ℕ), (List.take i L).prod * (List.drop i L).prod = L.prod

theorem List.sum_take_add_sum_drop E0 #

∀ {M : Type u_4} [inst : AddMonoid M] (L : List M) (i : ℕ), (List.take i L).sum + (List.drop i L).sum = L.sum

theorem List.prod_take_succ E0 #

∀ {M : Type u_4} [inst : Monoid M] (L : List M) (i : ℕ) (p : i < L.length),
  (List.take (i + 1) L).prod = (List.take i L).prod * L[i]

theorem List.sum_take_succ E0 #

∀ {M : Type u_4} [inst : AddMonoid M] (L : List M) (i : ℕ) (p : i < L.length),
  (List.take (i + 1) L).sum = (List.take i L).sum + L[i]

theorem List.length_pos_of_prod_ne_one E1 #

∀ {M : Type u_4} [inst : Monoid M] (L : List M), L.prod ≠ 1 → 0 < L.length

A list with product not one must have positive length.

theorem List.length_pos_of_sum_ne_zero E1 #

∀ {M : Type u_4} [inst : AddMonoid M] (L : List M), L.sum ≠ 0 → 0 < L.length

A list with sum not zero must have positive length.

theorem List.length_pos_of_one_lt_prod E1 #

∀ {M : Type u_4} [inst : Monoid M] [inst_1 : Preorder M] (L : List M), 1 < L.prod → 0 < L.length

A list with product greater than one must have positive length.

theorem List.length_pos_of_sum_pos E1 #

∀ {M : Type u_4} [inst : AddMonoid M] [inst_1 : Preorder M] (L : List M), 0 < L.sum → 0 < L.length

A list with positive sum must have positive length.

theorem List.length_pos_of_prod_lt_one E1 #

∀ {M : Type u_4} [inst : Monoid M] [inst_1 : Preorder M] (L : List M), L.prod < 1 → 0 < L.length

A list with product less than one must have positive length.

theorem List.length_pos_of_sum_neg E1 #

∀ {M : Type u_4} [inst : AddMonoid M] [inst_1 : Preorder M] (L : List M), L.sum < 0 → 0 < L.length

A list with negative sum must have positive length.

theorem List.prod_set E1 #

∀ {M : Type u_4} [inst : Monoid M] (L : List M) (n : ℕ) (a : M),
  (L.set n a).prod = ((List.take n L).prod * if n < L.length then a else 1) * (List.drop (n + 1) L).prod

theorem List.sum_set E1 #

∀ {M : Type u_4} [inst : AddMonoid M] (L : List M) (n : ℕ) (a : M),
  (L.set n a).sum = ((List.take n L).sum + if n < L.length then a else 0) + (List.drop (n + 1) L).sum

theorem List.getElem?_zero_mul_tail_prod E1 #

∀ {M : Type u_4} [inst : Monoid M] (l : List M), l[0]?.getD 1 * l.tail.prod = l.prod

We'd like to state this as L.headI * L.tail.prod = L.prod, but because L.headI relies on an inhabited instance to return a garbage value on the empty list, this is not possible. Instead, we write the statement in terms of L[0]?.getD 1.

theorem List.getElem?_zero_add_tail_sum E1 #

∀ {M : Type u_4} [inst : AddMonoid M] (l : List M), l[0]?.getD 0 + l.tail.sum = l.sum

We'd like to state this as L.headI + L.tail.sum = L.sum, but because L.headI relies on an inhabited instance to return a garbage value on the empty list, this is not possible. Instead, we write the statement in terms of L[0]?.getD 0.

theorem List.headI_mul_tail_prod_of_ne_nil E1 #

∀ {M : Type u_4} [inst : Monoid M] [inst_1 : Inhabited M] (l : List M), l ≠ [] → l.headI * l.tail.prod = l.prod

Same as get?_zero_mul_tail_prod, but avoiding the List.headI garbage complication by requiring the list to be nonempty.

theorem List.headI_add_tail_sum_of_ne_nil E1 #

∀ {M : Type u_4} [inst : AddMonoid M] [inst_1 : Inhabited M] (l : List M), l ≠ [] → l.headI + l.tail.sum = l.sum

Same as get?_zero_add_tail_sum, but avoiding the List.headI garbage complication by requiring the list to be nonempty.

theorem AddCommute.list_sum_right E1 #

∀ {M : Type u_4} [inst : AddMonoid M] (l : List M) (y : M), (∀ x ∈ l, AddCommute y x) → AddCommute y l.sum

theorem Commute.list_prod_right E1 #

∀ {M : Type u_4} [inst : Monoid M] (l : List M) (y : M), (∀ x ∈ l, Commute y x) → Commute y l.prod

theorem Commute.list_prod_left E1 #

∀ {M : Type u_4} [inst : Monoid M] (l : List M) (y : M), (∀ x ∈ l, Commute x y) → Commute l.prod y

theorem AddCommute.list_sum_left E1 #

∀ {M : Type u_4} [inst : AddMonoid M] (l : List M) (y : M), (∀ x ∈ l, AddCommute x y) → AddCommute l.sum y

theorem List.prod_range_succ E1 #

∀ {M : Type u_4} [inst : Monoid M] (f : ℕ → M) (n : ℕ),
  (List.map f (List.range n.succ)).prod = (List.map f (List.range n)).prod * f n

theorem List.sum_range_succ E1 #

∀ {M : Type u_4} [inst : AddMonoid M] (f : ℕ → M) (n : ℕ),
  (List.map f (List.range n.succ)).sum = (List.map f (List.range n)).sum + f n

theorem List.prod_range_succ' E1 #

∀ {M : Type u_4} [inst : Monoid M] (f : ℕ → M) (n : ℕ),
  (List.map f (List.range n.succ)).prod = f 0 * (List.map (fun i ↦ f i.succ) (List.range n)).prod

A variant of prod_range_succ which pulls off the first term in the product rather than the last.

theorem List.sum_range_succ' E1 #

∀ {M : Type u_4} [inst : AddMonoid M] (f : ℕ → M) (n : ℕ),
  (List.map f (List.range n.succ)).sum = f 0 + (List.map (fun i ↦ f i.succ) (List.range n)).sum

A variant of sum_range_succ which pulls off the first term in the sum rather than the last.

theorem List.sum_eq_zero E1 #

∀ {M : Type u_4} [inst : AddMonoid M] {l : List M}, (∀ x ∈ l, x = 0) → l.sum = 0

theorem List.prod_eq_one E1 #

∀ {M : Type u_4} [inst : Monoid M] {l : List M}, (∀ x ∈ l, x = 1) → l.prod = 1

theorem List.exists_mem_ne_one_of_prod_ne_one E1 #

∀ {M : Type u_4} [inst : Monoid M] {l : List M}, l.prod ≠ 1 → ∃ x ∈ l, x ≠ 1

theorem List.exists_mem_ne_zero_of_sum_ne_zero E1 #

∀ {M : Type u_4} [inst : AddMonoid M] {l : List M}, l.sum ≠ 0 → ∃ x ∈ l, x ≠ 0

theorem List.sum_erase_of_comm E1 #

∀ {M : Type u_4} [inst : AddMonoid M] {l : List M} {a : M} [inst_1 : DecidableEq M],
  a ∈ l → (∀ x ∈ l, ∀ y ∈ l, x + y = y + x) → a + (l.erase a).sum = l.sum

theorem List.prod_erase_of_comm E1 #

∀ {M : Type u_4} [inst : Monoid M] {l : List M} {a : M} [inst_1 : DecidableEq M],
  a ∈ l → (∀ x ∈ l, ∀ y ∈ l, x * y = y * x) → a * (l.erase a).prod = l.prod

theorem List.prod_map_eq_pow_single E1 #

∀ {α : Type u_2} {M : Type u_4} [inst : Monoid M] [inst_1 : DecidableEq α] {l : List α} (a : α) (f : α → M),
  (∀ (a' : α), a' ≠ a → a' ∈ l → f a' = 1) → (List.map f l).prod = f a ^ List.count a l

theorem List.sum_map_eq_nsmul_single E1 #

∀ {α : Type u_2} {M : Type u_4} [inst : AddMonoid M] [inst_1 : DecidableEq α] {l : List α} (a : α) (f : α → M),
  (∀ (a' : α), a' ≠ a → a' ∈ l → f a' = 0) → (List.map f l).sum = List.count a l • f a

theorem List.prod_eq_pow_single E1 #

∀ {M : Type u_4} [inst : Monoid M] {l : List M} [inst_1 : DecidableEq M] (a : M),
  (∀ (a' : M), a' ≠ a → a' ∈ l → a' = 1) → l.prod = a ^ List.count a l

theorem List.sum_eq_nsmul_single E1 #

∀ {M : Type u_4} [inst : AddMonoid M] {l : List M} [inst_1 : DecidableEq M] (a : M),
  (∀ (a' : M), a' ≠ a → a' ∈ l → a' = 0) → l.sum = List.count a l • a

theorem List.sum_insertIdx E0 #

∀ {M : Type u_4} [inst : AddMonoid M] {l : List M} {a : M} {i : ℕ},
  i ≤ l.length → (∀ a' ∈ List.take i l, AddCommute a a') → (l.insertIdx i a).sum = a + l.sum

theorem List.prod_insertIdx E0 #

∀ {M : Type u_4} [inst : Monoid M] {l : List M} {a : M} {i : ℕ},
  i ≤ l.length → (∀ a' ∈ List.take i l, Commute a a') → (l.insertIdx i a).prod = a * l.prod

theorem List.add_sum_eraseIdx E0 #

∀ {M : Type u_4} [inst : AddMonoid M] {l : List M} {i : ℕ} (hlen : i < l.length),
  (∀ a' ∈ List.take i l, AddCommute l[i] a') → l[i] + (l.eraseIdx i).sum = l.sum

theorem List.mul_prod_eraseIdx E0 #

∀ {M : Type u_4} [inst : Monoid M] {l : List M} {i : ℕ} (hlen : i < l.length),
  (∀ a' ∈ List.take i l, Commute l[i] a') → l[i] * (l.eraseIdx i).prod = l.prod

theorem List.sum_filter_bne_zero E0 #

∀ {M : Type u_4} [inst : AddMonoid M] [inst_1 : BEq M] [LawfulBEq M] (l : List M),
  (List.filter (fun x ↦ x != 0) l).sum = l.sum

theorem List.prod_filter_bne_one E0 #

∀ {M : Type u_4} [inst : Monoid M] [inst_1 : BEq M] [LawfulBEq M] (l : List M),
  (List.filter (fun x ↦ x != 1) l).prod = l.prod

theorem List.CommMonoid.prod_insertIdx E0 #

∀ {M : Type u_4} [inst : CommMonoid M] {a : M} {l : List M} {i : ℕ}, i ≤ l.length → (l.insertIdx i a).prod = a * l.prod

theorem List.CommMonoid.sum_insertIdx E0 #

∀ {M : Type u_4} [inst : AddCommMonoid M] {a : M} {l : List M} {i : ℕ}, i ≤ l.length → (l.insertIdx i a).sum = a + l.sum

theorem List.CommMonoid.add_sum_eraseIdx E0 #

∀ {M : Type u_4} [inst : AddCommMonoid M] {l : List M} {i : ℕ} (h : i < l.length), l[i] + (l.eraseIdx i).sum = l.sum

theorem List.CommMonoid.mul_prod_eraseIdx E0 #

∀ {M : Type u_4} [inst : CommMonoid M] {l : List M} {i : ℕ} (h : i < l.length), l[i] * (l.eraseIdx i).prod = l.prod

theorem List.prod_erase E0 #

∀ {M : Type u_4} [inst : CommMonoid M] {a : M} {l : List M} [inst_1 : DecidableEq M],
  a ∈ l → a * (l.erase a).prod = l.prod

theorem List.sum_erase E0 #

∀ {M : Type u_4} [inst : AddCommMonoid M] {a : M} {l : List M} [inst_1 : DecidableEq M],
  a ∈ l → a + (l.erase a).sum = l.sum

theorem List.sum_map_erase E0 #

∀ {α : Type u_2} {M : Type u_4} [inst : AddCommMonoid M] [inst_1 : DecidableEq α] (f : α → M) {a : α} {l : List α},
  a ∈ l → f a + (List.map f (l.erase a)).sum = (List.map f l).sum

theorem List.prod_map_erase E0 #

∀ {α : Type u_2} {M : Type u_4} [inst : CommMonoid M] [inst_1 : DecidableEq α] (f : α → M) {a : α} {l : List α},
  a ∈ l → f a * (List.map f (l.erase a)).prod = (List.map f l).prod

theorem List.Perm.prod_eq E0 #

∀ {M : Type u_4} [inst : CommMonoid M] {l₁ l₂ : List M}, l₁.Perm l₂ → l₁.prod = l₂.prod

theorem List.Perm.sum_eq E0 #

∀ {M : Type u_4} [inst : AddCommMonoid M] {l₁ l₂ : List M}, l₁.Perm l₂ → l₁.sum = l₂.sum

theorem List.sum_add_sum_eq_sum_zipWith_add_sum_drop E1 #

∀ {M : Type u_4} [inst : AddCommMonoid M] (l l' : List M),
  l.sum + l'.sum =
    (List.zipWith (fun x1 x2 ↦ x1 + x2) l l').sum + (List.drop l'.length l).sum + (List.drop l.length l').sum

theorem List.prod_mul_prod_eq_prod_zipWith_mul_prod_drop E1 #

∀ {M : Type u_4} [inst : CommMonoid M] (l l' : List M),
  l.prod * l'.prod =
    (List.zipWith (fun x1 x2 ↦ x1 * x2) l l').prod * (List.drop l'.length l).prod * (List.drop l.length l').prod

theorem List.sum_add_sum_eq_sum_zipWith_of_length_eq E0 #

∀ {M : Type u_4} [inst : AddCommMonoid M] (l l' : List M),
  l.length = l'.length → l.sum + l'.sum = (List.zipWith (fun x1 x2 ↦ x1 + x2) l l').sum

theorem List.prod_mul_prod_eq_prod_zipWith_of_length_eq E0 #

∀ {M : Type u_4} [inst : CommMonoid M] (l l' : List M),
  l.length = l'.length → l.prod * l'.prod = (List.zipWith (fun x1 x2 ↦ x1 * x2) l l').prod

theorem List.sum_map_ite E1 #

∀ {α : Type u_2} {M : Type u_4} [inst : AddCommMonoid M] (p : α → Prop) [inst_1 : DecidablePred p] (f g : α → M)
  (l : List α),
  (List.map (fun a ↦ if p a then f a else g a) l).sum =
    (List.map f (List.filter (fun b ↦ decide (p b)) l)).sum + (List.map g (List.filter (fun a ↦ decide ¬p a) l)).sum

theorem List.prod_map_ite E1 #

∀ {α : Type u_2} {M : Type u_4} [inst : CommMonoid M] (p : α → Prop) [inst_1 : DecidablePred p] (f g : α → M)
  (l : List α),
  (List.map (fun a ↦ if p a then f a else g a) l).prod =
    (List.map f (List.filter (fun b ↦ decide (p b)) l)).prod * (List.map g (List.filter (fun a ↦ decide ¬p a) l)).prod

theorem List.prod_map_filter_mul_prod_map_filter_not E1 #

∀ {α : Type u_2} {M : Type u_4} [inst : CommMonoid M] (p : α → Prop) [inst_1 : DecidablePred p] (f : α → M)
  (l : List α),
  (List.map f (List.filter (fun b ↦ decide (p b)) l)).prod * (List.map f (List.filter (fun x ↦ decide ¬p x) l)).prod =
    (List.map f l).prod

theorem List.sum_map_filter_add_sum_map_filter_not E1 #

∀ {α : Type u_2} {M : Type u_4} [inst : AddCommMonoid M] (p : α → Prop) [inst_1 : DecidablePred p] (f : α → M)
  (l : List α),
  (List.map f (List.filter (fun b ↦ decide (p b)) l)).sum + (List.map f (List.filter (fun x ↦ decide ¬p x) l)).sum =
    (List.map f l).sum

theorem List.prod_inv_reverse E1 #

∀ {G : Type u_7} [inst : Group G] (L : List G), L.prod⁻¹ = (List.map (fun x ↦ x⁻¹) L).reverse.prod

This is the List.prod version of mul_inv_rev

theorem List.sum_neg_reverse E1 #

∀ {G : Type u_7} [inst : AddGroup G] (L : List G), -L.sum = (List.map (fun x ↦ -x) L).reverse.sum

This is the List.sum version of add_neg_rev

theorem List.prod_reverse_noncomm E1 #

∀ {G : Type u_7} [inst : Group G] (L : List G), L.reverse.prod = (List.map (fun x ↦ x⁻¹) L).prod⁻¹

A non-commutative variant of List.prod_reverse

theorem List.sum_reverse_noncomm E1 #

∀ {G : Type u_7} [inst : AddGroup G] (L : List G), L.reverse.sum = -(List.map (fun x ↦ -x) L).sum

A non-commutative variant of List.sum_reverse

theorem List.prod_drop_succ E0 #

∀ {G : Type u_7} [inst : Group G] (L : List G) (i : ℕ) (p : i < L.length),
  (List.drop (i + 1) L).prod = L[i]⁻¹ * (List.drop i L).prod

Counterpart to List.prod_take_succ when we have an inverse operation

theorem List.sum_drop_succ E0 #

∀ {G : Type u_7} [inst : AddGroup G] (L : List G) (i : ℕ) (p : i < L.length),
  (List.drop (i + 1) L).sum = -L[i] + (List.drop i L).sum

Counterpart to List.sum_take_succ when we have a negation operation

theorem List.prod_range_div' E1 #

∀ {G : Type u_7} [inst : Group G] (n : ℕ) (f : ℕ → G),
  (List.map (fun k ↦ f k / f (k + 1)) (List.range n)).prod = f 0 / f n

Cancellation of a telescoping product.

theorem List.sum_range_sub' E1 #

∀ {G : Type u_7} [inst : AddGroup G] (n : ℕ) (f : ℕ → G),
  (List.map (fun k ↦ f k - f (k + 1)) (List.range n)).sum = f 0 - f n

Cancellation of a telescoping sum.

theorem List.prod_inv E1 #

∀ {K : Type u_8} [inst : DivisionCommMonoid K] (L : List K), L.prod⁻¹ = (List.map (fun x ↦ x⁻¹) L).prod

This is the List.prod version of mul_inv

theorem List.sum_neg E1 #

∀ {K : Type u_8} [inst : SubtractionCommMonoid K] (L : List K), -L.sum = (List.map (fun x ↦ -x) L).sum

This is the List.sum version of add_neg

theorem List.prod_range_div E1 #

∀ {G : Type u_7} [inst : CommGroup G] (n : ℕ) (f : ℕ → G),
  (List.map (fun k ↦ f (k + 1) / f k) (List.range n)).prod = f n / f 0

Cancellation of a telescoping product.

theorem List.sum_range_sub E1 #

∀ {G : Type u_7} [inst : AddCommGroup G] (n : ℕ) (f : ℕ → G),
  (List.map (fun k ↦ f (k + 1) - f k) (List.range n)).sum = f n - f 0

Cancellation of a telescoping sum.

theorem List.prod_set' E1 #

∀ {G : Type u_7} [inst : CommGroup G] (L : List G) (n : ℕ) (a : G),
  (L.set n a).prod = L.prod * if hn : n < L.length then L[n]⁻¹ * a else 1

Alternative version of List.prod_set when the list is over a group

theorem List.sum_set' E1 #

∀ {G : Type u_7} [inst : AddCommGroup G] (L : List G) (n : ℕ) (a : G),
  (L.set n a).sum = L.sum + if hn : n < L.length then -L[n] + a else 0

Alternative version of List.sum_set when the list is over a group

theorem List.prod_map_ite_eq E0 #

∀ {G : Type u_7} [inst : CommGroup G] {A : Type u_8} [inst_1 : DecidableEq A] (l : List A) (f g : A → G) (a : A),
  (List.map (fun x ↦ if x = a then f x else g x) l).prod = (f a / g a) ^ List.count a l * (List.map g l).prod

theorem List.sum_map_ite_eq E0 #

∀ {G : Type u_7} [inst : AddCommGroup G] {A : Type u_8} [inst_1 : DecidableEq A] (l : List A) (f g : A → G) (a : A),
  (List.map (fun x ↦ if x = a then f x else g x) l).sum = List.count a l • (f a - g a) + (List.map g l).sum

theorem List.sum_const_nat E1 #

∀ (m n : ℕ), (List.replicate m n).sum = m * n

theorem List.headI_add_tail_sum E1 #

∀ (L : List ℕ), L.headI + L.tail.sum = L.sum

This relies on default ℕ = 0.

theorem List.headI_le_sum E1 #

∀ (L : List ℕ), L.headI ≤ L.sum

This relies on default ℕ = 0.

theorem List.tail_sum E1 #

∀ (L : List ℕ), L.tail.sum = L.sum - L.headI

This relies on default ℕ = 0.

theorem List.alternatingProd_nil E0 #

∀ {G : Type u_7} [inst : One G] [inst_1 : Mul G] [inst_2 : Inv G], [].alternatingProd = 1

theorem List.alternatingSum_nil E0 #

∀ {G : Type u_7} [inst : Zero G] [inst_1 : Add G] [inst_2 : Neg G], [].alternatingSum = 0

theorem List.alternatingSum_singleton E0 #

∀ {G : Type u_7} [inst : Zero G] [inst_1 : Add G] [inst_2 : Neg G] (a : G), [a].alternatingSum = a

theorem List.alternatingProd_singleton E0 #

∀ {G : Type u_7} [inst : One G] [inst_1 : Mul G] [inst_2 : Inv G] (a : G), [a].alternatingProd = a

theorem List.alternatingSum_cons_cons' E1 #

∀ {G : Type u_7} [inst : Zero G] [inst_1 : Add G] [inst_2 : Neg G] (a b : G) (l : List G),
  (a :: b :: l).alternatingSum = a + -b + l.alternatingSum

theorem List.alternatingProd_cons_cons' E1 #

∀ {G : Type u_7} [inst : One G] [inst_1 : Mul G] [inst_2 : Inv G] (a b : G) (l : List G),
  (a :: b :: l).alternatingProd = a * b⁻¹ * l.alternatingProd

theorem List.alternatingSum_cons_cons E1 #

∀ {G : Type u_7} [inst : SubNegMonoid G] (a b : G) (l : List G), (a :: b :: l).alternatingSum = a - b + l.alternatingSum

theorem List.alternatingProd_cons_cons E1 #

∀ {G : Type u_7} [inst : DivInvMonoid G] (a b : G) (l : List G),
  (a :: b :: l).alternatingProd = a / b * l.alternatingProd

theorem List.alternatingProd_cons' E1 #

∀ {G : Type u_7} [inst : CommGroup G] (a : G) (l : List G), (a :: l).alternatingProd = a * l.alternatingProd⁻¹

theorem List.alternatingSum_cons' E1 #

∀ {G : Type u_7} [inst : AddCommGroup G] (a : G) (l : List G), (a :: l).alternatingSum = a + -l.alternatingSum

theorem List.alternatingSum_cons E0 #

∀ {G : Type u_7} [inst : AddCommGroup G] (a : G) (l : List G), (a :: l).alternatingSum = a - l.alternatingSum

theorem List.alternatingProd_cons E0 #

∀ {G : Type u_7} [inst : CommGroup G] (a : G) (l : List G), (a :: l).alternatingProd = a / l.alternatingProd

theorem List.sum_nat_mod E1 #

∀ (l : List ℕ) (n : ℕ), l.sum % n = (List.map (fun x ↦ x % n) l).sum % n

theorem List.prod_nat_mod E1 #

∀ (l : List ℕ) (n : ℕ), l.prod % n = (List.map (fun x ↦ x % n) l).prod % n

theorem List.sum_int_mod E1 #

∀ (l : List ℤ) (n : ℤ), l.sum % n = (List.map (fun x ↦ x % n) l).sum % n

theorem List.prod_int_mod E1 #

∀ (l : List ℤ) (n : ℤ), l.prod % n = (List.map (fun x ↦ x % n) l).prod % n

theorem map_list_prod E0 #

∀ {M : Type u_4} {N : Type u_5} [inst : Monoid M] [inst_1 : Monoid N] {F : Type u_8} [inst_2 : FunLike F M N]
  [MonoidHomClass F M N] (f : F) (l : List M), f l.prod = (List.map (⇑f) l).prod

theorem map_list_sum E0 #

∀ {M : Type u_4} {N : Type u_5} [inst : AddMonoid M] [inst_1 : AddMonoid N] {F : Type u_8} [inst_2 : FunLike F M N]
  [AddMonoidHomClass F M N] (f : F) (l : List M), f l.sum = (List.map (⇑f) l).sum

theorem MonoidHom.map_list_prod E0 #

∀ {M : Type u_4} {N : Type u_5} [inst : Monoid M] [inst_1 : Monoid N] (f : M →* N) (l : List M),
  f l.prod = (List.map (⇑f) l).prod

theorem AddMonoidHom.map_list_sum E0 #

∀ {M : Type u_4} {N : Type u_5} [inst : AddMonoid M] [inst_1 : AddMonoid N] (f : M →+ N) (l : List M),
  f l.sum = (List.map (⇑f) l).sum

theorem List.prod_zpow E1 #

∀ {β : Type u_8} [inst : DivisionCommMonoid β] {r : ℤ} {l : List β}, l.prod ^ r = (List.map (fun x ↦ x ^ r) l).prod

theorem List.take_sum_flatten E1 #

∀ {α : Type u_2} (L : List (List α)) (i : ℕ),
  List.take (List.take i (List.map List.length L)).sum L.flatten = (List.take i L).flatten

In a flatten, taking the first elements up to an index which is the sum of the lengths of the first i sublists, is the same as taking the flatten of the first i sublists.

theorem List.drop_sum_flatten E1 #

∀ {α : Type u_2} (L : List (List α)) (i : ℕ),
  List.drop (List.take i (List.map List.length L)).sum L.flatten = (List.drop i L).flatten

In a flatten, dropping all the elements up to an index which is the sum of the lengths of the first i sublists, is the same as taking the join after dropping the first i sublists.

theorem List.length_le_sum_of_one_le E1 #

∀ (L : List ℕ), (∀ i ∈ L, 1 ≤ i) → L.length ≤ L.sum

If all elements in a list are bounded below by 1, then the length of the list is bounded by the sum of the elements.