Sums and products from lists #
This file provides basic 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.
A list with product not one must have positive length.
A list with sum not zero must have positive length.
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.
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.
Same as get?_zero_mul_tail_prod, but avoiding the List.headI garbage complication by
requiring the list to be nonempty.
Same as get?_zero_add_tail_sum, but avoiding the List.headI garbage
complication by requiring the list to be nonempty.
A variant of prod_range_succ which pulls off the first term in the product rather than the
last.
A variant of sum_range_succ which pulls off the first term in the sum rather
than the last.
This is the List.prod version of mul_inv_rev
This is the List.sum version of add_neg_rev
A non-commutative variant of List.prod_reverse
A non-commutative variant of List.sum_reverse
Counterpart to List.prod_take_succ when we have an inverse operation
Counterpart to List.sum_take_succ when we have a negation operation
Cancellation of a telescoping product.
Cancellation of a telescoping sum.
This is the List.prod version of mul_inv
This is the List.sum version of add_neg
Cancellation of a telescoping product.
Cancellation of a telescoping sum.
Alternative version of List.prod_set when the list is over a group
Alternative version of List.sum_set when the list is over a group
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.
This relies on default ℕ = 0.
This relies on default ℕ = 0.
This relies on default ℕ = 0.
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.
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.
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.