Counting on ℕ #
This file defines the count function, which gives, for any predicate on the natural numbers,
"how many numbers under k satisfy this predicate?".
We then prove several expected lemmas about count, relating it to the cardinality of other
objects, and helping to evaluate it for specific k.
Count the number of naturals k < n satisfying p k.
Equations
Instances For
count p n can be expressed as the cardinality of {k // k < n ∧ p k}.
@[simp]
Alias of the reverse direction of Nat.count_succ_eq_succ_count_iff.
Alias of the reverse direction of Nat.count_succ_eq_count_iff.
theorem
Nat.lt_of_count_lt_count
{p : ℕ → Prop}
[DecidablePred p]
{a b : ℕ}
(h : count p a < count p b)
:
theorem
Nat.count_injective
{p : ℕ → Prop}
[DecidablePred p]
{m n : ℕ}
(hm : p m)
(hn : p n)
(heq : count p m = count p n)
:
Alias of the reverse direction of Nat.count_iff_forall.
Alias of the reverse direction of Nat.count_iff_forall_not.
theorem
Nat.exists_of_count_lt_count
{p : ℕ → Prop}
[DecidablePred p]
{a b : ℕ}
(h : count p a < count p b)
:
∃ x ∈ Set.Ico a b, p x
theorem
Nat.count_mono_left
{p : ℕ → Prop}
[DecidablePred p]
{q : ℕ → Prop}
[DecidablePred q]
{n : ℕ}
(hpq : ∀ k < n, p k → q k)
: