Sums over ranges, consecutive blocks and residue classes #
Small facts about list sums and lists of natural numbers.
- Sums over ranges. A list sum over
List.range nis theFinsetsum overrange n(List.sum_map_range_eq_sum_range); a list is its entries at0, …, length - 1(List.map_getD_range); sums over aflatMapand of a filter's length (List.sum_map_flatMap,List.length_filter_eq_sum), and aFinsetsum of list sums is a list sum ofFinsetsums (Finset.sum_list_sum_comm). - Consecutive blocks. Numbering blocks of sizes
w 0, w 1, …consecutively, blockbisList.blockRange w b, starting atList.blockStart w b; the blocks belowBare the numbers belowList.blockStart w B(List.flatMap_blockRange). The pairsg J + hforg < G,h < Jare the numbers belowG J(List.flatMap_range_mul). - Residue classes.
List.residueClass J m gis the numbersibelowmwithi % J = g. Summing over the residue classes moduloJ > 0sums over the list (List.sum_filter_mod), and a residue class belowmhas at mostm / J + 1numbers (List.length_residueClass_le).
Main definitions #
List.blockStart,List.blockRange: consecutive blocks.List.residueClass: a residue class belowm.
Main results #
List.sum_map_range_eq_sum_range,List.map_getD_range,List.sum_map_flatMap,List.length_filter_eq_sum,Finset.sum_list_sum_comm: sums.List.flatMap_blockRange,List.flatMap_range_mul: consecutive blocks.List.sum_filter_mod,List.sum_residueClass,List.sum_length_filter_mod,List.length_residueClass_le: residue classes.
Sums over ranges #
A list sum over List.range n is the Finset sum over range n.
Consecutive blocks #
The numbers of block b: blockStart w b, …, blockStart w b + w b - 1.
Instances For
Consecutive blocks: the numbers of the blocks below B, in order, are the numbers below
blockStart w B.
Residue classes #
The residue class of g modulo J below m: the numbers i below m with
i % J = g, in increasing order. It is empty when 0 < J ≤ g.
Instances For
A residue class below m has at most m / J + 1 numbers.