Documentation

Mathlib.Init.Data.Nat.Lemmas

theorem Nat.eq_zero_of_mul_eq_zero {n : } {m : } :
n * m = 0n = 0 m = 0
Equations
def Nat.strong_rec_on {p : Sort u} (n : ) (H : (n : ) → ((m : ) → m < np m) → p n) :
p n
Equations
theorem Nat.strong_induction_on {p : Prop} (n : ) (h : (n : ) → ((m : ) → m < np m) → p n) :
p n
theorem Nat.case_strong_induction_on {p : Prop} (a : ) (hz : p 0) (hi : (n : ) → ((m : ) → m np m) → p (Nat.succ n)) :
p a
def Nat.iterate {α : Sort u} (op : αα) :
αα
Equations
Equations
  • One or more equations did not get rendered due to their size.

bit0/bit1 properties

theorem Nat.bit1_ne_one {n : } :
n 0bit1 n 1
theorem Nat.bit1_ne_bit0 (n : ) (m : ) :
theorem Nat.bit0_ne_bit1 (n : ) (m : ) :
theorem Nat.bit0_inj {n : } {m : } :
bit0 n = bit0 mn = m
theorem Nat.bit1_inj {n : } {m : } :
bit1 n = bit1 mn = m
theorem Nat.bit0_ne {n : } {m : } :
n mbit0 n bit0 m
theorem Nat.bit1_ne {n : } {m : } :
n mbit1 n bit1 m
theorem Nat.zero_ne_bit0 {n : } :
n 00 bit0 n
theorem Nat.one_ne_bit1 {n : } :
n 01 bit1 n
theorem Nat.one_lt_bit1 {n : } :
n 01 < bit1 n
theorem Nat.one_lt_bit0 {n : } :
n 01 < bit0 n
theorem Nat.bit0_lt {n : } {m : } (h : n < m) :
bit0 n < bit0 m
theorem Nat.bit1_lt {n : } {m : } (h : n < m) :
bit1 n < bit1 m
theorem Nat.bit0_lt_bit1 {n : } {m : } (h : n m) :
bit0 n < bit1 m
theorem Nat.bit1_lt_bit0 {n : } {m : } :
n < mbit1 n < bit0 m
theorem Nat.one_le_bit0 (n : ) :
n 01 bit0 n
def Nat.discriminate {n : } {α : Sort u_1} (H1 : n = 0α) (H2 : (m : ) → n = Nat.succ mα) :
α
Equations
def Nat.two_step_induction {P : Sort u} (H1 : P 0) (H2 : P 1) (H3 : (n : ) → P nP (Nat.succ n)P (Nat.succ (Nat.succ n))) (a : ) :
P a
Equations
def Nat.sub_induction {P : Sort u} (H1 : (m : ) → P 0 m) (H2 : (n : ) → P (Nat.succ n) 0) (H3 : (n m : ) → P n mP (Nat.succ n) (Nat.succ m)) (n : ) (m : ) :
P n m
Equations
def Nat.lt_ge_by_cases {a : } {b : } {C : Sort u} (h₁ : a < bC) (h₂ : b aC) :
C
Equations
def Nat.lt_by_cases {a : } {b : } {C : Sort u} (h₁ : a < bC) (h₂ : a = bC) (h₃ : b < aC) :
C
Equations
def Nat.findX {p : Prop} [inst : DecidablePred p] (H : n, p n) :
{ n // p n ∀ (m : ), m < n¬p m }

Used in the definition of Nat.find. Returns the smallest natural satisfying p

Equations
  • One or more equations did not get rendered due to their size.
def Nat.find {p : Prop} [inst : DecidablePred p] (H : n, p n) :

If p is a (decidable) predicate on and hp : ∃ (n : ℕ), p n∃ (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 that Nat.find hp satisfies p.
  • Nat.find_min is the proof that if m < Nat.find hp then m does not satisfy p.
  • Nat.find_min' is the proof that if m does satisfy p then Nat.find hp ≤ m≤ m.
Equations
theorem Nat.find_spec {p : Prop} [inst : DecidablePred p] (H : n, p n) :
p (Nat.find H)
theorem Nat.find_min {p : Prop} [inst : DecidablePred p] (H : n, p n) {m : } :
m < Nat.find H¬p m
theorem Nat.find_min' {p : Prop} [inst : DecidablePred p] (H : n, p n) {m : } (h : p m) :
theorem Nat.cond_decide_mod_two (x : ) [d : Decidable (x % 2 = 1)] :
(bif decide (x % 2 = 1) then 1 else 0) = x % 2
theorem Nat.to_digits_core_lens_eq (b : ) (f : ) (n : ) (c : Char) (tl : List Char) :
theorem Nat.nat_repr_len_aux (n : ) (b : ) (e : ) (h_b_pos : 0 < b) :
n < b ^ Nat.succ en / b < b ^ e
theorem Nat.to_digits_core_length (b : ) (h : 2 b) (f : ) (n : ) (e : ) (hlt : n < b ^ e) (h_e_pos : 0 < e) :

The String representation produced by toDigitsCore has the proper length relative to the number of digits in n < e for some base b. Since this works with any base greater than one, it can be used for binary, decimal, and hex.

theorem Nat.repr_length (n : ) (e : ) :
0 < en < 10 ^ eString.length (Nat.repr n) e

The core implementation of Nat.repr returns a String with length less than or equal to the number of digits in the decimal number (represented by e). For example, the decimal string representation of any number less than 1000 (10 ^ 3) has a length less than or equal to 3.