File: .lake/packages/batteries/Batteries/Data/List/Count.lean

full_name: List.countP_nil
code: @[simp] theorem countP_nil : countP p [] = 0 
goal: List.countP p [] = 0

full_name: List.countP_go_eq_add
code: protected theorem countP_go_eq_add (l) : countP.go p l n = n + countP.go p l 0 
goal: List.countP.go p l n = n + List.countP.go p l 0

full_name: List.countP_cons_of_pos
code: @[simp] theorem countP_cons_of_pos (l) (pa : p a) : countP p (a :: l) = countP p l + 1 
goal: List.countP p (a :: l) = List.countP p l + 1

full_name: List.countP_cons_of_neg
code: @[simp] theorem countP_cons_of_neg (l) (pa : ¬p a) : countP p (a :: l) = countP p l 
goal: List.countP p (a :: l) = List.countP p l

full_name: List.countP_cons
code: theorem countP_cons (a : α) (l) : countP p (a :: l) = countP p l + if p a then 1 else 0 
goal: List.countP p (a :: l) = List.countP p l + if p a = true then 1 else 0

full_name: List.length_eq_countP_add_countP
code: theorem length_eq_countP_add_countP (l) : length l = countP p l + countP (fun a => ¬p a) l 
goal: l.length = List.countP p l + List.countP (fun a => decide ¬p a = true) l

full_name: List.countP_eq_length_filter
code: theorem countP_eq_length_filter (l) : countP p l = length (filter p l) 
goal: List.countP p l = (List.filter p l).length

full_name: List.countP_le_length
code: theorem countP_le_length : countP p l ≤ l.length 
goal: List.countP p l ≤ l.length

full_name: List.countP_append
code: @[simp] theorem countP_append (l₁ l₂) : countP p (l₁ ++ l₂) = countP p l₁ + countP p l₂ 
goal: List.countP p (l₁ ++ l₂) = List.countP p l₁ + List.countP p l₂

full_name: List.countP_pos
code: theorem countP_pos : 0 < countP p l ↔ ∃ a ∈ l, p a 
goal: 0 < List.countP p l ↔ ∃ a, a ∈ l ∧ p a = true

full_name: List.countP_eq_zero
code: theorem countP_eq_zero : countP p l = 0 ↔ ∀ a ∈ l, ¬p a 
goal: List.countP p l = 0 ↔ ∀ (a : α), a ∈ l → ¬p a = true

full_name: List.countP_eq_length
code: theorem countP_eq_length : countP p l = l.length ↔ ∀ a ∈ l, p a 
goal: List.countP p l = l.length ↔ ∀ (a : α), a ∈ l → p a = true

full_name: List.Sublist.countP_le
code: theorem Sublist.countP_le (s : l₁ <+ l₂) : countP p l₁ ≤ countP p l₂ 
goal: List.countP p l₁ ≤ List.countP p l₂

full_name: List.countP_filter
code: theorem countP_filter (l : List α) :
    countP p (filter q l) = countP (fun a => p a ∧ q a) l 
goal: List.countP p (List.filter q l) = List.countP (fun a => decide (p a = true ∧ q a = true)) l

full_name: List.countP_true
code: @[simp] theorem countP_true {l : List α} : (l.countP fun _ => true) = l.length 
goal: List.countP (fun x => true) l = l.length

full_name: List.countP_false
code: @[simp] theorem countP_false {l : List α} : (l.countP fun _ => false) = 0 
goal: List.countP (fun x => false) l = 0

full_name: List.countP_map
code: @[simp] theorem countP_map (p : β → Bool) (f : α → β) :
    ∀ l, countP p (map f l) = countP (p ∘ f) l
  
goal: List.countP p (List.map f l) = List.countP (p ∘ f) l

full_name: List.countP_mono_left
code: theorem countP_mono_left (h : ∀ x ∈ l, p x → q x) : countP p l ≤ countP q l 
goal: List.countP p l ≤ List.countP q l

full_name: List.countP_congr
code: theorem countP_congr (h : ∀ x ∈ l, p x ↔ q x) : countP p l = countP q l 
goal: List.countP p l = List.countP q l

full_name: List.count_nil
code: @[simp] theorem count_nil (a : α) : count a [] = 0 
goal: List.count a [] = 0

full_name: List.count_cons
code: theorem count_cons (a b : α) (l : List α) :
    count a (b :: l) = count a l + if a = b then 1 else 0 
goal: List.count a (b :: l) = List.count a l + if a = b then 1 else 0

full_name: List.count_cons_self
code: @[simp] theorem count_cons_self (a : α) (l : List α) : count a (a :: l) = count a l + 1 
goal: List.count a (a :: l) = List.count a l + 1

full_name: List.count_cons_of_ne
code: @[simp] theorem count_cons_of_ne (h : a ≠ b) (l : List α) : count a (b :: l) = count a l 
goal: List.count a (b :: l) = List.count a l

full_name: List.count_tail
code: theorem count_tail : ∀ (l : List α) (a : α) (h : l ≠ []),
      l.tail.count a = l.count a - if a = l.head h then 1 else 0
  
goal: List.count a l.tail = List.count a l - if a = l.head h then 1 else 0

full_name: List.count_le_length
code: theorem count_le_length (a : α) (l : List α) : count a l ≤ l.length 
goal: List.count a l ≤ l.length

full_name: List.Sublist.count_le
code: theorem Sublist.count_le (h : l₁ <+ l₂) (a : α) : count a l₁ ≤ count a l₂ 
goal: List.count a l₁ ≤ List.count a l₂

full_name: List.count_le_count_cons
code: theorem count_le_count_cons (a b : α) (l : List α) : count a l ≤ count a (b :: l) 
goal: List.count a l ≤ List.count a (b :: l)

full_name: List.count_singleton
code: theorem count_singleton (a : α) : count a [a] = 1 
goal: List.count a [a] = 1

full_name: List.count_singleton'
code: theorem count_singleton' (a b : α) : count a [b] = if a = b then 1 else 0 
goal: List.count a [b] = if a = b then 1 else 0

full_name: List.count_append
code: @[simp] theorem count_append (a : α) : ∀ l₁ l₂, count a (l₁ ++ l₂) = count a l₁ + count a l₂ 
goal: List.count a (l₁ ++ l₂) = List.count a l₁ + List.count a l₂

full_name: List.count_concat
code: theorem count_concat (a : α) (l : List α) : count a (concat l a) = succ (count a l) 
goal: List.count a (l.concat a) = (List.count a l).succ

full_name: List.count_pos_iff_mem
code: @[simp]
theorem count_pos_iff_mem {a : α} {l : List α} : 0 < count a l ↔ a ∈ l 
goal: 0 < List.count a l ↔ a ∈ l

full_name: List.count_eq_zero_of_not_mem
code: @[simp 900] theorem count_eq_zero_of_not_mem {a : α} {l : List α} (h : a ∉ l) : count a l = 0 
goal: List.count a l = 0

full_name: List.not_mem_of_count_eq_zero
code: theorem not_mem_of_count_eq_zero {a : α} {l : List α} (h : count a l = 0) : a ∉ l 
goal: ¬a ∈ l

full_name: List.count_eq_zero
code: theorem count_eq_zero {l : List α} : count a l = 0 ↔ a ∉ l 
goal: List.count a l = 0 ↔ ¬a ∈ l

full_name: List.count_eq_length
code: theorem count_eq_length {l : List α} : count a l = l.length ↔ ∀ b ∈ l, a = b 
goal: List.count a l = l.length ↔ ∀ (b : α), b ∈ l → a = b

full_name: List.count_replicate_self
code: @[simp] theorem count_replicate_self (a : α) (n : Nat) : count a (replicate n a) = n 
goal: List.count a (List.replicate n a) = n

full_name: List.count_replicate
code: theorem count_replicate (a b : α) (n : Nat) : count a (replicate n b) = if a = b then n else 0 
goal: List.count a (List.replicate n b) = if a = b then n else 0

full_name: List.filter_beq
code: theorem filter_beq (l : List α) (a : α) : l.filter (· == a) = replicate (count a l) a 
goal: List.filter (fun x => x == a) l = List.replicate (List.count a l) a

full_name: List.filter_eq
code: theorem filter_eq (l : List α) (a : α) : l.filter (· = a) = replicate (count a l) a 
goal: List.filter (fun x => decide (x = a)) l = List.replicate (List.count a l) a

full_name: List.filter_eq'
code: @[deprecated filter_eq (since := "2023-12-14")]
theorem filter_eq' (l : List α) (a : α) : l.filter (a = ·) = replicate (count a l) a 
goal: List.filter (fun x => decide (a = x)) l = List.replicate (List.count a l) a

full_name: List.filter_beq'
code: @[deprecated filter_beq (since := "2023-12-14")]
theorem filter_beq' (l : List α) (a : α) : l.filter (a == ·) = replicate (count a l) a 
goal: List.filter (fun x => a == x) l = List.replicate (List.count a l) a

full_name: List.le_count_iff_replicate_sublist
code: theorem le_count_iff_replicate_sublist {l : List α} : n ≤ count a l ↔ replicate n a <+ l 
goal: n ≤ List.count a l ↔ List.replicate n a <+ l

full_name: List.replicate_count_eq_of_count_eq_length
code: theorem replicate_count_eq_of_count_eq_length {l : List α} (h : count a l = length l) :
    replicate (count a l) a = l 
goal: List.replicate (List.count a l) a = l

full_name: List.count_filter
code: @[simp] theorem count_filter {l : List α} (h : p a) : count a (filter p l) = count a l 
goal: List.count a (List.filter p l) = List.count a l

full_name: List.count_le_count_map
code: theorem count_le_count_map [DecidableEq β] (l : List α) (f : α → β) (x : α) :
    count x l ≤ count (f x) (map f l) 
goal: List.count x l ≤ List.count (f x) (List.map f l)

full_name: List.count_erase
code: theorem count_erase (a b : α) :
    ∀ l : List α, count a (l.erase b) = count a l - if a = b then 1 else 0
  
goal: List.count a (l.erase b) = List.count a l - if a = b then 1 else 0

full_name: List.count_erase_self
code: @[simp] theorem count_erase_self (a : α) (l : List α) :
    count a (List.erase l a) = count a l - 1 
goal: List.count a (l.erase a) = List.count a l - 1

full_name: List.count_erase_of_ne
code: @[simp] theorem count_erase_of_ne (ab : a ≠ b) (l : List α) : count a (l.erase b) = count a l 
goal: List.count a (l.erase b) = List.count a l