Occurrence counts in finite families #
occCount f y counts the indices at which a family f takes the value y.
For an infinite fiber its value is zero, following the convention of Nat.card.
Occurrence counts regroup sums over a finite family by fibers: each value in a finite set
covering the range is weighted by its occurrence count.
Main results #
Function.occCount_pos: for a finite fiber, the count is positive exactly when it is nonempty.Function.occCount_of_injective: an injective function has count one on its range and zero outside.Function.occCount_le_of_comp,Function.occCount_lt_of_comp: comparison along embeddings.Function.occCount_eq_card_preimage: the count as the cardinality of a singleton preimage.Function.prod_occCount_powand its additive formFunction.sum_occCount_nsmul: regroup a product or sum by counting the occurrences of each value.Function.occCount_castSucc,Function.occCount_succ: split off the last or first position.Function.sum_occCount_eq_card: the total occurrence count is the cardinality of the index type.Function.exists_perm_of_occCount_eq: equal counts on finite families give a permutation.
The occurrence count is the Finset.card of the indices taking the given value.
When the target fiber is finite, an embedding that misses an occurrence gives a strictly smaller occurrence count.
Raising each weight to its occurrence count gives the product over all indices.
Weighting each value by its occurrence count gives the sum over all indices.
Splitting off the last position: the occurrences of a in a word are those in its initial
segment together with a possible occurrence at the last position.
Splitting off the first position: the occurrences of a in a word are those in its final
segment together with a possible occurrence at the first position.