If p is a (decidable) predicate on ℕ and hp : ∃ (n : ℕ), p n is a proof that
there exists some natural number satisfying p, then Nat.find hp is the
smallest natural number satisfying p. Note that Nat.find is protected,
meaning that you can't just write find, even if the Nat namespace is open.
The API for Nat.find is:
- Nat.find_specis the proof that- Nat.find hpsatisfies- p.
- Nat.find_minis the proof that if- m < Nat.find hpthen- mdoes not satisfy- p.
- Nat.find_min'is the proof that if- mdoes satisfy- pthen- Nat.find hp ≤ m.
Instances For
Nat.findGreatest P n is the largest i ≤ bound such that P i holds, or 0 if no such i
exists
Equations
- Nat.findGreatest P 0 = 0
- Nat.findGreatest P n.succ = if P (n + 1) then n + 1 else Nat.findGreatest P n
Instances For
@[simp]
@[simp]
theorem
Nat.findGreatest_spec
{m : ℕ}
{P : ℕ → Prop}
[DecidablePred P]
{n : ℕ}
(hmb : m ≤ n)
(hm : P m)
 :
P (findGreatest P n)
theorem
Nat.le_findGreatest
{m : ℕ}
{P : ℕ → Prop}
[DecidablePred P]
{n : ℕ}
(hmb : m ≤ n)
(hm : P m)
 :
theorem
Nat.findGreatest_mono_left
{P Q : ℕ → Prop}
[DecidablePred P]
[DecidablePred Q]
(hPQ : ∀ (n : ℕ), P n → Q n)
(n : ℕ)
 :
theorem
Nat.findGreatest_mono
{m : ℕ}
{P Q : ℕ → Prop}
[DecidablePred P]
{n : ℕ}
[DecidablePred Q]
(hPQ : ∀ (n : ℕ), P n → Q n)
(hmn : m ≤ n)
 :
theorem
Nat.findGreatest_is_greatest
{k : ℕ}
{P : ℕ → Prop}
[DecidablePred P]
{n : ℕ}
(hk : findGreatest P n < k)
(hkb : k ≤ n)
 :
¬P k
theorem
Nat.findGreatest_of_ne_zero
{m : ℕ}
{P : ℕ → Prop}
[DecidablePred P]
{n : ℕ}
(h : findGreatest P n = m)
(h0 : m ≠ 0)
 :
P m