Counting in lists #
This file proves basic properties of List.countP and List.count, which count the number of
elements of a list satisfying a predicate and equal to a given element respectively. Their
definitions can be found in Batteries.Data.List.Basic.
count #
idxToSigmaCount, sigmaCountToIdx #
idxToSigmaCount is essentially a Fin-to-Fin wrapper for countBefore that also
includes the corresponding element.
For example:
idxToSigmaCount [5, 1, 3, 2, 4, 0, 1, 4] 5 = ⟨0, 0⟩
Instances For
sigmaCountToIdx is a _ × Fin-to-Fin wrapper for countBefore.
For example:
sigmaCountToIdx [5, 1, 3, 2, 4, 0, 1, 4] ⟨0, 0⟩ = 5
Equations
- xs.sigmaCountToIdx xc = ⟨List.idxOfNth xc.fst xs ↑xc.snd, ⋯⟩
Instances For
theorem
List.leftInverse_sigmaCountToIdx_idxToSigmaCount
{α : Type u_1}
[BEq α]
[ReflBEq α]
{xs : List α}
:
theorem
List.rightInverse_idxToSigmaCount_sigmaCountToIdx
{α : Type u_1}
[BEq α]
[ReflBEq α]
{xs : List α}
:
theorem
List.leftInverse_idxToSigmaCount_sigmaCountToIdx
{α : Type u_1}
[BEq α]
[LawfulBEq α]
{xs : List α}
:
theorem
List.rightInverse_sigmaCountToIdx_idxToSigmaCount
{α : Type u_1}
[BEq α]
[LawfulBEq α]
{xs : List α}
: