Mathlib.Data.Nat.Count
32 declarations. Mathlib docs · Source
theorem Nat.count.congr_simp E1 #
∀ (p p_1 : ℕ → Prop),
p = p_1 →
∀ {inst : DecidablePred p} [inst_1 : DecidablePred p_1] (n n_1 : ℕ), n = n_1 → Nat.count p n = Nat.count p_1 n_1
def Nat.count E1 #
(p : ℕ → Prop) → [DecidablePred p] → ℕ → ℕ
Count the number of naturals k < n satisfying p k.
theorem Nat.count_zero E0 #
∀ (p : ℕ → Prop) [inst : DecidablePred p], Nat.count p 0 = 0
def Nat.CountSet.fintype E1 #
(p : ℕ → Prop) → [DecidablePred p] → (n : ℕ) → Fintype { i // i < n ∧ p i }
A fintype instance for the set relevant to Nat.count. Locally an instance in scope count
theorem Nat.count_eq_card_filter_range E1 #
∀ (p : ℕ → Prop) [inst : DecidablePred p] (n : ℕ), Nat.count p n = {x ∈ Finset.range n | p x}.card
theorem Nat.count_eq_card_fintype E1 #
∀ (p : ℕ → Prop) [inst : DecidablePred p] (n : ℕ), Nat.count p n = Fintype.card { k // k < n ∧ p k }
count p n can be expressed as the cardinality of {k // k < n ∧ p k}.
theorem Nat.count_le E1 #
∀ (p : ℕ → Prop) [inst : DecidablePred p] {n : ℕ}, Nat.count p n ≤ n
theorem Nat.count_succ E1 #
∀ (p : ℕ → Prop) [inst : DecidablePred p] (n : ℕ), Nat.count p (n + 1) = Nat.count p n + if p n then 1 else 0
theorem Nat.count_monotone E1 #
∀ (p : ℕ → Prop) [inst : DecidablePred p], Monotone (Nat.count p)
theorem Nat.count_add E1 #
∀ (p : ℕ → Prop) [inst : DecidablePred p] (a b : ℕ),
Nat.count p (a + b) = Nat.count p a + Nat.count (fun k ↦ p (a + k)) b
theorem Nat.count_add' E1 #
∀ (p : ℕ → Prop) [inst : DecidablePred p] (a b : ℕ),
Nat.count p (a + b) = Nat.count (fun k ↦ p (k + b)) a + Nat.count p b
theorem Nat.count_one E1 #
∀ (p : ℕ → Prop) [inst : DecidablePred p], Nat.count p 1 = if p 0 then 1 else 0
theorem Nat.count_succ' E1 #
∀ (p : ℕ → Prop) [inst : DecidablePred p] (n : ℕ),
Nat.count p (n + 1) = Nat.count (fun k ↦ p (k + 1)) n + if p 0 then 1 else 0
theorem Nat.count_lt_count_succ_iff E0 #
∀ {p : ℕ → Prop} [inst : DecidablePred p] {n : ℕ}, Nat.count p n < Nat.count p (n + 1) ↔ p n
theorem Nat.count_succ_eq_succ_count_iff E0 #
∀ {p : ℕ → Prop} [inst : DecidablePred p] {n : ℕ}, Nat.count p (n + 1) = Nat.count p n + 1 ↔ p n
theorem Nat.count_succ_eq_count_iff E0 #
∀ {p : ℕ → Prop} [inst : DecidablePred p] {n : ℕ}, Nat.count p (n + 1) = Nat.count p n ↔ ¬p n
theorem Nat.count_succ_eq_succ_count E1 #
∀ {p : ℕ → Prop} [inst : DecidablePred p] {n : ℕ}, p n → Nat.count p (n + 1) = Nat.count p n + 1
Alias of the reverse direction of Nat.count_succ_eq_succ_count_iff.
theorem Nat.count_succ_eq_count E1 #
∀ {p : ℕ → Prop} [inst : DecidablePred p] {n : ℕ}, ¬p n → Nat.count p (n + 1) = Nat.count p n
Alias of the reverse direction of Nat.count_succ_eq_count_iff.
theorem Nat.lt_of_count_lt_count E1 #
∀ {p : ℕ → Prop} [inst : DecidablePred p] {a b : ℕ}, Nat.count p a < Nat.count p b → a < b
theorem Nat.count_strict_mono E1 #
∀ {p : ℕ → Prop} [inst : DecidablePred p] {m n : ℕ}, p m → m < n → Nat.count p m < Nat.count p n
theorem Nat.count_injective E1 #
∀ {p : ℕ → Prop} [inst : DecidablePred p] {m n : ℕ}, p m → p n → Nat.count p m = Nat.count p n → m = n
theorem Nat.count_le_card E1 #
∀ {p : ℕ → Prop} [inst : DecidablePred p] (hp : (Set.ofPred p).Finite) (n : ℕ), Nat.count p n ≤ hp.toFinset.card
theorem Nat.count_lt_card E1 #
∀ {p : ℕ → Prop} [inst : DecidablePred p] {n : ℕ} (hp : (Set.ofPred p).Finite), p n → Nat.count p n < hp.toFinset.card
theorem Nat.count_iff_forall E1 #
∀ {p : ℕ → Prop} [inst : DecidablePred p] {n : ℕ}, Nat.count p n = n ↔ ∀ n' < n, p n'
theorem Nat.count_of_forall E1 #
∀ {p : ℕ → Prop} [inst : DecidablePred p] {n : ℕ}, (∀ n' < n, p n') → Nat.count p n = n
Alias of the reverse direction of Nat.count_iff_forall.
theorem Nat.count_true E0 #
∀ (n : ℕ), Nat.count (fun x ↦ True) n = n
theorem Nat.count_iff_forall_not E1 #
∀ {p : ℕ → Prop} [inst : DecidablePred p] {n : ℕ}, Nat.count p n = 0 ↔ ∀ m < n, ¬p m
theorem Nat.count_of_forall_not E1 #
∀ {p : ℕ → Prop} [inst : DecidablePred p] {n : ℕ}, (∀ m < n, ¬p m) → Nat.count p n = 0
Alias of the reverse direction of Nat.count_iff_forall_not.
theorem Nat.count_ne_iff_exists E1 #
∀ {p : ℕ → Prop} [inst : DecidablePred p] {n : ℕ}, Nat.count p n ≠ 0 ↔ ∃ m < n, p m
theorem Nat.count_false E0 #
∀ (n : ℕ), Nat.count (fun x ↦ False) n = 0
theorem Nat.exists_of_count_lt_count E1 #
∀ {p : ℕ → Prop} [inst : DecidablePred p] {a b : ℕ}, Nat.count p a < Nat.count p b → ∃ x ∈ Set.Ico a b, p x
theorem Nat.count_mono_left E1 #
∀ {p : ℕ → Prop} [inst : DecidablePred p] {q : ℕ → Prop} [inst_1 : DecidablePred q] {n : ℕ},
(∀ k < n, p k → q k) → Nat.count p n ≤ Nat.count q n