File: Mathlib/Data/Nat/Count.lean

full_name: Nat.count
code: /-- Count the number of naturals `k < n` satisfying `p k`. -/
def count (n : ℕ) : ℕ 
goal: ℕ

full_name: Nat.count_zero
code: @[simp]
theorem count_zero : count p 0 = 0 
goal: Nat.count p 0 = 0

full_name: Nat.CountSet.fintype
code: /-- A fintype instance for the set relevant to `Nat.count`. Locally an instance in locale `count` -/
def CountSet.fintype (n : ℕ) : Fintype { i // i < n ∧ p i } 
goal: Fintype { i // i < n ∧ p i }

full_name: Nat.count_eq_card_filter_range
code: theorem count_eq_card_filter_range (n : ℕ) : count p n = ((range n).filter p).card 
goal: Nat.count p n = (Finset.filter p (Finset.range n)).card

full_name: Nat.count_eq_card_fintype
code: /-- `count p n` can be expressed as the cardinality of `{k // k < n ∧ p k}`. -/
theorem count_eq_card_fintype (n : ℕ) : count p n = Fintype.card { k : ℕ // k < n ∧ p k } 
goal: Nat.count p n = Fintype.card { k // k < n ∧ p k }

full_name: Nat.count_succ
code: theorem count_succ (n : ℕ) : count p (n + 1) = count p n + if p n then 1 else 0 
goal: Nat.count p (n + 1) = Nat.count p n + if p n then 1 else 0

full_name: Nat.count_monotone
code: @[mono]
theorem count_monotone : Monotone (count p) 
goal: Monotone (Nat.count p)

full_name: Nat.count_add
code: theorem count_add (a b : ℕ) : count p (a + b) = count p a + count (fun k ↦ p (a + k)) b 
goal: Nat.count p (a + b) = Nat.count p a + Nat.count (fun k => p (a + k)) b

full_name: Nat.count_add'
code: theorem count_add' (a b : ℕ) : count p (a + b) = count (fun k ↦ p (k + b)) a + count p b 
goal: Nat.count p (a + b) = Nat.count (fun k => p (k + b)) a + Nat.count p b

full_name: Nat.count_one
code: theorem count_one : count p 1 = if p 0 then 1 else 0 
goal: Nat.count p 1 = if p 0 then 1 else 0

full_name: Nat.count_succ'
code: theorem count_succ' (n : ℕ) :
    count p (n + 1) = count (fun k ↦ p (k + 1)) n + if p 0 then 1 else 0 
goal: Nat.count p (n + 1) = Nat.count (fun k => p (k + 1)) n + if p 0 then 1 else 0

full_name: Nat.count_lt_count_succ_iff
code: @[simp]
theorem count_lt_count_succ_iff {n : ℕ} : count p n < count p (n + 1) ↔ p n 
goal: Nat.count p n < Nat.count p (n + 1) ↔ p n

full_name: Nat.count_succ_eq_succ_count_iff
code: theorem count_succ_eq_succ_count_iff {n : ℕ} : count p (n + 1) = count p n + 1 ↔ p n 
goal: Nat.count p (n + 1) = Nat.count p n + 1 ↔ p n

full_name: Nat.count_succ_eq_count_iff
code: theorem count_succ_eq_count_iff {n : ℕ} : count p (n + 1) = count p n ↔ ¬p n 
goal: Nat.count p (n + 1) = Nat.count p n ↔ ¬p n

full_name: Nat.count_le_cardinal
code: theorem count_le_cardinal (n : ℕ) : (count p n : Cardinal) ≤ Cardinal.mk { k | p k } 
goal: ↑(Nat.count p n) ≤ Cardinal.mk ↑{k | p k}

full_name: Nat.lt_of_count_lt_count
code: theorem lt_of_count_lt_count {a b : ℕ} (h : count p a < count p b) : a < b 
goal: a < b

full_name: Nat.count_strict_mono
code: theorem count_strict_mono {m n : ℕ} (hm : p m) (hmn : m < n) : count p m < count p n 
goal: Nat.count p m < Nat.count p n

full_name: Nat.count_injective
code: theorem count_injective {m n : ℕ} (hm : p m) (hn : p n) (heq : count p m = count p n) : m = n 
goal: m = n

full_name: Nat.count_le_card
code: theorem count_le_card (hp : (setOf p).Finite) (n : ℕ) : count p n ≤ hp.toFinset.card 
goal: Nat.count p n ≤ hp.toFinset.card

full_name: Nat.count_lt_card
code: theorem count_lt_card {n : ℕ} (hp : (setOf p).Finite) (hpn : p n) : count p n < hp.toFinset.card 
goal: Nat.count p n < hp.toFinset.card

full_name: Nat.count_of_forall
code: theorem count_of_forall {n : ℕ} (hp : ∀ n' < n, p n') : count p n = n 
goal: Nat.count p n = n

full_name: Nat.count_true
code: @[simp] theorem count_true (n : ℕ) : count (fun _ ↦ True) n = n 
goal: Nat.count (fun x => True) n = n

full_name: Nat.count_of_forall_not
code: theorem count_of_forall_not {n : ℕ} (hp : ∀ n' < n, ¬p n') : count p n = 0 
goal: Nat.count p n = 0

full_name: Nat.count_false
code: @[simp] theorem count_false (n : ℕ) : count (fun _ ↦ False) n = 0 
goal: Nat.count (fun x => False) n = 0

full_name: Nat.count_mono_left
code: theorem count_mono_left {n : ℕ} (hpq : ∀ k, p k → q k) : count p n ≤ count q n 
goal: Nat.count p n ≤ Nat.count q n