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.
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.
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.
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.