Sums and products from lists #
This file provides further results about List.prod
, List.sum
,
which calculate the product and sum of elements of a list
and List.alternatingProd
, List.alternatingSum
, their alternating counterparts.
theorem
List.Perm.sum_eq'
{M : Type u_4}
[AddMonoid M]
{l₁ l₂ : List M}
(h : l₁.Perm l₂)
(hc : Pairwise AddCommute l₁)
:
l₁.sum = l₂.sum
If elements of a list additively commute with each other, then their sum does not depend on the order of elements.
The members of l.ranges
have no duplicate
@[deprecated List.ranges_flatten (since := "2024-10-15")]
Alias of List.ranges_flatten
.
theorem
List.drop_take_succ_flatten_eq_getElem
{α : Type u_2}
(L : List (List α))
(i : ℕ)
(h : i < L.length)
:
In a flatten of sublists, taking the slice between the indices A
and B - 1
gives back the
original sublist of index i
if A
is the sum of the lengths of sublists of index < i
, and
B
is the sum of the lengths of sublists of index ≤ i
.
theorem
List.Sublist.prod_dvd_prod
{M : Type u_4}
[CommMonoid M]
{l₁ l₂ : List M}
(h : l₁.Sublist l₂)
:
l₁.prod ∣ l₂.prod
theorem
unop_map_list_prod
{M : Type u_4}
{N : Type u_5}
[Monoid M]
[Monoid N]
{F : Type u_8}
[FunLike F M Nᵐᵒᵖ]
[MonoidHomClass F M Nᵐᵒᵖ]
(f : F)
(l : List M)
:
MulOpposite.unop (f l.prod) = (List.map (MulOpposite.unop ∘ ⇑f) l).reverse.prod
A morphism into the opposite monoid acts on the product by acting on the reversed elements.