Documentation

Mathlib.Data.List.Count

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.

theorem List.countP_erase {α : Type u_1} [DecidableEq α] (p : αBool) (l : List α) (a : α) :
List.countP p (l.erase a) = List.countP p l - if a l p a = true then 1 else 0
theorem List.count_diff {α : Type u_1} [DecidableEq α] (a : α) (l₁ l₂ : List α) :
List.count a (l₁.diff l₂) = List.count a l₁ - List.count a l₂
theorem List.countP_diff {α : Type u_1} [DecidableEq α] {l₁ l₂ : List α} (hl : l₂.Subperm l₁) (p : αBool) :
List.countP p (l₁.diff l₂) = List.countP p l₁ - List.countP p l₂
@[simp]
theorem List.count_map_of_injective {α : Type u_1} {β : Type u_2} [DecidableEq α] [DecidableEq β] (l : List α) (f : αβ) (hf : Function.Injective f) (x : α) :