Sums and products from lists #
This file provides basic results about list.prod
and list.sum
, which calculate the product and
sum of elements of a list. These are defined in data.list.defs
.
If zero is an element of a list L
, then list.prod L = 0
. If the domain is a nontrivial
monoid with zero with no divisors, then this implication becomes an iff
, see
list.prod_eq_zero_iff
.
Product of elements of a list L
equals zero if and only if 0 ∈ L
. See also
list.prod_eq_zero
for an implication that needs weaker typeclass assumptions.
Alternative version of list.prod_update_nth
when the list is over a group
A list with positive sum must have positive length.
We'd like to state this as L.head * L.tail.prod = L.prod
, but because L.head
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.nth 0).get_or_else 1
and state the lemma for ℕ
as
The product of a list of positive natural numbers is positive, and likewise for any nontrivial ordered semiring.
Several lemmas about sum/head/tail for list ℕ
.
These are hard to generalize well, as they rely on the fact that default ℕ = 0
.
If desired, we could add a class stating that default α = 0
.