addition
multiplication
properties of inequality
@[protected, instance]
Equations
- nat.linear_order = {le := nat.less_than_or_equal, lt := nat.lt, le_refl := nat.le_refl, le_trans := nat.le_trans, lt_iff_le_not_le := nat.lt_iff_le_not_le, le_antisymm := nat.le_antisymm, le_total := nat.le_total, decidable_le := nat.decidable_le, decidable_eq := nat.decidable_eq, decidable_lt := nat.decidable_lt, max := max_default (λ (a b : ℕ), a.decidable_le b), max_def := nat.linear_order._proof_1, min := min_default (λ (a b : ℕ), a.decidable_le b), min_def := nat.linear_order._proof_2}
@[protected]
Equations
- nat.lt_ge_by_cases h₁ h₂ = decidable.by_cases h₁ (λ (h : ¬a < b), h₂ _)
@[protected]
Equations
- nat.lt_by_cases h₁ h₂ h₃ = nat.lt_ge_by_cases h₁ (λ (h₁ : b ≤ a), nat.lt_ge_by_cases h₃ (λ (h : a ≤ b), h₂ _))
bit0/bit1 properties
successor and predecessor
subtraction
Many lemmas are proven more generally in mathlib algebra/order/sub
min
induction principles
def
nat.two_step_induction
{P : ℕ → Sort u}
(H1 : P 0)
(H2 : P 1)
(H3 : Π (n : ℕ), P n → P n.succ → P n.succ.succ)
(a : ℕ) :
P a
Equations
- nat.two_step_induction H1 H2 H3 n.succ.succ = H3 n (nat.two_step_induction H1 H2 H3 n) (nat.two_step_induction H1 H2 H3 n.succ)
- nat.two_step_induction H1 H2 H3 1 = H2
- nat.two_step_induction H1 H2 H3 0 = H1
def
nat.sub_induction
{P : ℕ → ℕ → Sort u}
(H1 : Π (m : ℕ), P 0 m)
(H2 : Π (n : ℕ), P n.succ 0)
(H3 : Π (n m : ℕ), P n m → P n.succ m.succ)
(n m : ℕ) :
P n m
Equations
- nat.sub_induction H1 H2 H3 n.succ m.succ = H3 n m (nat.sub_induction H1 H2 H3 n m)
- nat.sub_induction H1 H2 H3 n.succ 0 = H2 n
- nat.sub_induction H1 H2 H3 0 m = H1 m
mod
div
dvd
@[protected, instance]
Equations
- nat.decidable_dvd = λ (m n : ℕ), decidable_of_decidable_of_iff (nat.decidable_eq (n % m) 0) _
iterate
find
@[protected]
Equations
- nat.find_x H = _.fix (λ (m : ℕ) (IH : Π (y : ℕ), lbp y m → (λ (k : ℕ), (∀ (n : ℕ), n < k → ¬p n) → {n // p n ∧ ∀ (m : ℕ), m < n → ¬p m}) y) (al : ∀ (n : ℕ), n < m → ¬p n), dite (p m) (λ (pm : p m), ⟨m, _⟩) (λ (pm : ¬p m), have this : ∀ (n : ℕ), n ≤ m → ¬p n, from _, IH (m + 1) _ _)) 0 nat.find_x._proof_5
@[protected]
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_spec
is the proof thatnat.find hp
satisfiesp
.nat.find_min
is the proof that ifm < nat.find hp
thenm
does not satisfyp
.nat.find_min'
is the proof that ifm
does satisfyp
thennat.find hp ≤ m
.
Equations
- nat.find H = (nat.find_x H).val
@[protected]
@[protected]
@[protected]