lean4-htt/tests/lean/grind/experiments/list_count.lean
2025-06-16 02:47:46 +00:00

19 lines
678 B
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- Things I'd still like to make work for `List.count` via `grind`, but need to move on for now.
open List
variable [BEq α] [LawfulBEq α]
theorem count_eq_length {l : List α} : count a l = l.length ↔ ∀ b ∈ l, a = b := by
induction l with grind
theorem filter_eq [DecidableEq α] {l : List α} (a : α) : l.filter (· = a) = replicate (count a l) a := by
grind
theorem replicate_count_eq_of_count_eq_length {l : List α} (h : count a l = length l) :
replicate (count a l) a = l := by
grind
theorem count_filterMap {α} [BEq β] {b : β} {f : α → Option β} {l : List α} :
count b (filterMap f l) = countP (fun a => f a == some b) l := by
grind