Documentation

Projects.Util.Nat

noncomputable def Nat.find! (p : Prop) :
Equations
Instances For
    @[irreducible]
    def Nat.powTwo (n : ) :
    Equations
    Instances For
      def Nat.chkLe (n : ) (p : Bool) :
      Equations
      Instances For
        def Nat.chkLt (n : ) (p : Bool) :
        Equations
        Instances For
          noncomputable def Nat.ofProp (p : Prop) :
          Equations
          Instances For
            theorem Nat.rec_const (n m : ) :
            rec m (fun (x a : ) => a) n = m
            theorem Nat.rec_succ' {α : Type u_1} {z : α} (f : αα) {n : } :
            rec z f (n + 1) = rec (f 0 z) (fun (m : ) => f (m + 1)) n
            theorem Nat.infi_eq_zero_of {f : } (k : ) (h : f k = 0) :
            ⨅ (x : ), f x = 0
            theorem Nat.le_sub_add_of {a b c : } (h : a b) :
            a b - c + c
            theorem Nat.le_sub_add_add_of {a b c d : } (h : a b) :
            a b - c + d + c
            theorem Nat.rec_le_of_sub_sub {n z : } (f g : ) :
            rec z (fun (k x : ) => x - f k - g k) n rec z (fun (k x : ) => x - f k) n
            @[simp]
            theorem Nat.ite_11_iff {P Q : Prop} {h₁ : Decidable P} {h₂ : Decidable Q} :
            ((if P then 1 else 0) = if Q then 1 else 0) (P Q)
            @[simp]
            theorem Nat.ite_00_iff {P Q : Prop} {h₁ : Decidable P} {h₂ : Decidable Q} :
            ((if P then 0 else 1) = if Q then 0 else 1) (P Q)
            @[simp]
            theorem Nat.ite_10_iff {P Q : Prop} {h₁ : Decidable P} {h₂ : Decidable Q} :
            ((if P then 1 else 0) = if Q then 0 else 1) (P ¬Q)
            @[simp]
            theorem Nat.ite_01_iff {P Q : Prop} {h₁ : Decidable P} {h₂ : Decidable Q} :
            ((if P then 0 else 1) = if Q then 1 else 0) (P ¬Q)
            theorem Nat.rec_sub {n k m : } {f : } :
            rec (n - k) (fun (k a : ) => a - f k) m = rec n (fun (k a : ) => a - f k) m - k
            @[simp]
            theorem Nat.add_succ_max_ne_left {x a b : } :
            x + (max a b + 1) a
            @[simp]
            theorem Nat.add_succ_max_ne_right {x a b : } :
            x + (max a b + 1) b
            @[simp]
            theorem Nat.left_lt_succ_max {a b : } :
            a < max a b + 1
            @[simp]
            theorem Nat.right_lt_succ_max {a b : } :
            b < max a b + 1
            theorem Nat.add_add_sub_cancel {a b c : } :
            a + b + c - b = a + c
            theorem Nat.add_succ_ne_right {a b : } :
            a + (b + 1) b
            theorem Nat.fn_set_add {a b : } {f : } {x : } :
            fn_set a (f a + b) f x = f x + if x = a then b else 0
            theorem Nat.eq_add_of_sub_eq_succ {a b c : } (h : a - b = c + 1) :
            a = c + 1 + b
            theorem Nat.eq_add_iff_sub_eq_succ {a b c : } :
            a = c + 1 + b a - b = c + 1
            theorem Nat.eq_add_of_one_eq_sub {a b : } (h : 1 = a - b) :
            a = b + 1
            theorem Nat.one_eq_sub_iff {a b : } :
            1 = a - b a = b + 1
            @[simp]
            theorem Nat.not_lt_sub {a b : } :
            ¬a < a - b
            theorem Nat.sub_eq_left_iff {a b : } :
            a - b = a a = 0 b = 0
            @[simp]
            theorem Nat.ite_10_le_one {P : Prop} [Decidable P] :
            (if P then 1 else 0) 1
            @[simp]
            theorem Nat.ite_01_le_one {P : Prop} [Decidable P] :
            (if P then 0 else 1) 1
            theorem Nat.even_iff_exi {n : } :
            Even n ∃ (k : ), n = k * 2
            theorem Nat.odd_iff_exi {n : } :
            Odd n ∃ (k : ), n = k * 2 + 1
            theorem Nat.mod_2_ind {p : Prop} (h₁ : ∀ (n : ), p (n * 2)) (h₂ : ∀ (n : ), p (n * 2 + 1)) (n : ) :
            p n
            theorem Nat.not_even_mul_2_succ {n : } :
            ¬Even (n * 2 + 1)
            @[simp]
            theorem Nat.not_odd_mul_2 {n : } :
            ¬Odd (n * 2)
            @[simp]
            theorem Nat.even_succ_iff {n : } :
            Even (n + 1) Odd n
            @[simp]
            theorem Nat.odd_succ_iff {n : } :
            Odd (n + 1) Even n
            theorem Nat.even_of_succ_div_2_eq {n : } (h : (n + 1) / 2 = n / 2) :
            theorem Nat.odd_of_succ_div_2_eq {n : } (h : (n + 1) / 2 = n / 2 + 1) :
            Odd n
            theorem Nat.le_one_iff {n : } :
            n 1 n = 0 n = 1
            theorem Nat.of_between_succ {a b : } (h₁ : a b) (h₂ : b a + 1) :
            b = a b = a + 1
            theorem Nat.succ_div_2_eq_or_eq (n : ) :
            (n + 1) / 2 = n / 2 (n + 1) / 2 = n / 2 + 1
            @[simp]
            theorem Nat.succ_div_2_eq_div_iff {n : } :
            (n + 1) / 2 = n / 2 Even n
            @[simp]
            theorem Nat.succ_div_2_eq_div_iff' {n : } :
            n / 2 = (n + 1) / 2 Even n
            @[simp]
            theorem Nat.succ_div_2_eq_div_succ_iff {n : } :
            (n + 1) / 2 = n / 2 + 1 Odd n
            @[simp]
            theorem Nat.succ_div_2_eq_div_succ_iff' {n : } :
            n / 2 + 1 = (n + 1) / 2 Odd n
            @[simp]
            theorem Nat.mul_2_succ_div_2_eq (n : ) :
            (n * 2 + 1) / 2 = n
            theorem Nat.find!_eq {p : Prop} :
            find! p = if h : ∃ (n : ), p n then Nat.find h else 0
            theorem Nat.find!_spec' {p : Prop} (h : ∃ (n : ), p n) :
            p (find! p) ∀ (k : ), p kfind! p k
            theorem Nat.find!_spec {p : Prop} (h : ∃ (n : ), p n) :
            p (find! p)
            theorem Nat.find!_eq_of {p : Prop} {n : } (h₁ : p n) (h₂ : k < n, ¬p k) :
            find! p = n
            theorem Nat.find!_eq_zero_of {p : Prop} (h : ∀ (n : ), ¬p n) :
            find! p = 0
            theorem Nat.find!_eq_iff {p : Prop} {n : } :
            find! p = n if ∃ (n : ), p n then p n k < n, ¬p k else n = 0
            theorem Nat.find!_min {p : Prop} {n : } (h : n < find! p) :
            ¬p n
            theorem Nat.find!_eq_of_not_ap_zero {p : Prop} (h₁ : ∃ (n : ), p n) (h₂ : ¬p 0) :
            find! p = (find! fun (m : ) => p (m + 1)) + 1
            theorem Nat.find!_eq_of_not_ap_le {p : Prop} (n : ) (h₁ : ∃ (n : ), p n) (h₂ : kn, ¬p k) :
            find! p = (find! fun (m : ) => p (n + m)) + n
            theorem Nat.add_one_add {a b : } :
            a + 1 + b = a + b + 1
            theorem Nat.add_one_sub {a b : } (h : b a) :
            a + 1 - b = a - b + 1
            theorem Nat.le_exp_left {a b : } (h : 2 b) :
            a b ^ a
            theorem Nat.le_exp_right {a b : } (h : b 0) :
            a a ^ b
            theorem Nat.find_le_find_of_imp {P Q : Prop} [hp : DecidablePred P] [hq : DecidablePred Q] {h₁ : ∃ (n : ), P n} {h₂ : ∃ (n : ), Q n} (h₃ : ∀ (n : ), Q nP n) :
            @[simp]
            theorem Nat.le_self_mul_iff {a b : } :
            a a * b a = 0 b 0
            @[simp]
            theorem Nat.lt_self_add_iff {a b : } :
            a < a + b 0 < b
            @[simp]
            theorem Nat.div_mul_sub_one_le {n k : } :
            n / k * (k - 1) n / k * k
            @[simp]
            theorem Nat.div_mul_le_self' {m n : } :
            m / n * n m
            @[simp]
            theorem Nat.mod_add_div₁ {m k : } :
            m % k + k * (m / k) = m
            @[simp]
            theorem Nat.mod_add_div₂ {m k : } :
            m % k + m / k * k = m
            @[simp]
            theorem Nat.div_add_mod₁ {m k : } :
            k * (m / k) + m % k = m
            @[simp]
            theorem Nat.div_add_mod₂ {m k : } :
            m / k * k + m % k = m
            theorem Nat.div_mul_le_of_le {a b c : } (h : c b) :
            a / b * c a
            theorem Nat.add_sub_lt_add_of_sub_lt {a b c d : } (h : b - c < d) :
            a + b - c < a + d
            theorem Nat.mod_self_sub_one_eq_one {n : } (h : 3 n) :
            n % (n - 1) = 1
            theorem Nat.ne_zero_of_mod_ne_zero {n k : } (h : n % k 0) :
            n 0
            @[simp]
            theorem Nat.even_or_odd₁ {n : } :
            @[simp]
            theorem Nat.odd_or_even₁ {n : } :
            theorem Nat.ite_odd {α : Type u_1} {n : } {x y : α} :
            (if Odd n then x else y) = if Even n then y else x
            theorem Nat.ite_even {α : Type u_1} {n : } {x y : α} :
            (if Even n then x else y) = if Odd n then y else x
            theorem Nat.exi_least_of_exi {p : Prop} (h : ∃ (n : ), p n) :
            ∃ (n : ), p n k < n, ¬p k
            theorem Nat.exi_iff_exi_least {p : Prop} :
            (∃ (n : ), p n) ∃ (n : ), p n k < n, ¬p k
            @[simp]
            theorem Nat.le_self_sub_add_one_iff {a b : } :
            a a - (b + 1) a = 0
            theorem Nat.find!_pos_of {p : Prop} (h₁ : ¬p 0) (h₂ : ∃ (n : ), p n) :
            0 < find! p
            theorem Nat.odd_add_two {n : } :
            Odd (n + 2) Odd n
            theorem Nat.even_add_two {n : } :
            Even (n + 2) Even n
            @[simp]
            theorem Nat.odd_sub_one_iff {n : } :
            Odd (n - 1) n 0 Even n
            @[simp]
            theorem Nat.even_sub_one_iff {n : } :
            Even (n - 1) n = 0 Odd n
            theorem Nat.mul_div_mul {a b c : } (hb : b 0) :
            a * b / (b * c) = a / c
            @[simp]
            theorem Nat.mul_div_mul_succ {a b c : } :
            a * (b + 1) / ((b + 1) * c) = a / c
            theorem Nat.one_le_of_odd {n : } (h : Odd n) :
            1 n
            @[simp]
            theorem Nat.fn_max_zero :
            max 0 = id
            @[simp]
            theorem Nat.odd_two_pow_iff {n : } :
            Odd (2 ^ n) n = 0
            @[simp]
            theorem Nat.powTwo_eq_true_iff {n : } :
            n.powTwo = true ∃ (k : ), 2 ^ k = n
            @[simp]
            theorem Nat.powTwo_eq_false_iff {n : } :
            n.powTwo = false ∀ (k : ), 2 ^ k n
            @[simp]
            theorem Nat.chkLe_eq_true_iff {n : } {p : Bool} :
            n.chkLe p = true kn, p k = true
            @[simp]
            theorem Nat.chkLe_eq_false_iff {n : } {p : Bool} :
            n.chkLe p = false kn, (!p k) = true
            @[simp]
            theorem Nat.chkLt_eq_true_iff {n : } {p : Bool} :
            n.chkLt p = true k < n, p k = true
            @[simp]
            theorem Nat.chkLt_eq_false_iff {n : } {p : Bool} :
            n.chkLt p = false k < n, (!p k) = true
            @[instance_reducible]
            instance Nat.instDecidableForallForallLe_projects {n : } {p : Prop} [h : (k : ) → Decidable (p k)] :
            Decidable (∀ kn, p k)
            Equations
            @[instance_reducible]
            instance Nat.instDecidableExistsAndLe_projects {n : } {p : Prop} [h : (k : ) → Decidable (p k)] :
            Decidable (∃ kn, p k)
            Equations
            @[instance_reducible]
            instance Nat.instDecidableForallForallLt_projects {n : } {p : Prop} [h : (k : ) → Decidable (p k)] :
            Decidable (∀ k < n, p k)
            Equations
            @[instance_reducible]
            instance Nat.instDecidableExistsAndLt_projects {n : } {p : Prop} [h : (k : ) → Decidable (p k)] :
            Decidable (∃ k < n, p k)
            Equations
            @[simp]
            theorem Nat.mul_two_lor_mul_two {n m : } :
            n * 2 ||| m * 2 = (n ||| m) * 2
            @[simp]
            theorem Nat.mul_two_succ_lor_mul_two {n m : } :
            n * 2 + 1 ||| m * 2 = (n ||| m) * 2 + 1
            @[simp]
            theorem Nat.mul_two_lor_mul_two_succ {n m : } :
            n * 2 ||| m * 2 + 1 = (n ||| m) * 2 + 1
            @[simp]
            theorem Nat.mul_two_succ_lor_mul_two_succ {n m : } :
            n * 2 + 1 ||| m * 2 + 1 = (n ||| m) * 2 + 1
            @[simp]
            theorem Nat.odd_lor_iff {n m : } :
            Odd (n ||| m) Odd n Odd m
            @[simp]
            theorem Nat.even_lor_iff {n m : } :
            Even (n ||| m) Even n Even m
            @[simp]
            theorem Nat.even_shiftLeft_succ {n k : } :
            Even (n <<< (k + 1))
            @[simp]
            theorem Nat.not_odd_shiftLeft_succ {n k : } :
            ¬Odd (n <<< (k + 1))
            @[simp]
            theorem Nat.forall_even_shiftRight_iff {n : } :
            (∀ (k : ), Even (n >>> k)) n = 0
            theorem Nat.shiftRight_add' {n m k : } :
            n >>> (m + k) = n >>> k >>> m
            @[simp]
            theorem Nat.mul_two_add_one_div_two {n : } :
            (n * 2 + 1) / 2 = n
            theorem Nat.div_two_eq_shiftRight {n : } :
            n / 2 = n >>> 1
            theorem Nat.eq_iff_odd_shiftRight {n m : } :
            n = m ∀ (k : ), Odd (n >>> k) Odd (m >>> k)
            @[simp]
            theorem Nat.shiftRight_add_left {n m : } :
            n >>> (m + n) = 0
            @[simp]
            theorem Nat.shiftRight_add_right {n m : } :
            n >>> (n + m) = 0
            theorem Nat.div_mul_eq_div_div {n m k : } :
            n / (m * k) = n / m / k
            @[simp]
            theorem Nat.mul_two_add_one_div_two_pow_succ {n m : } :
            (n * 2 + 1) / 2 ^ (m + 1) = n / 2 ^ m
            @[simp]
            theorem Nat.mul_two_add_one_shiftRight_succ {n m : } :
            (n * 2 + 1) >>> (m + 1) = n >>> m
            @[simp]
            theorem Nat.lor_one_shiftRight_succ {n m : } :
            (n ||| 1) >>> (m + 1) = n >>> (m + 1)
            @[simp]
            theorem Nat.mul_two_shiftRight_succ {n m : } :
            (n * 2) >>> (m + 1) = n >>> m
            theorem Nat.lor_one_eq_ite {n : } :
            n ||| 1 = if Odd n then n else n + 1
            @[simp]
            theorem Nat.mul_two_lor_one_eq {n : } :
            n * 2 ||| 1 = n * 2 + 1
            @[simp]
            theorem Nat.mul_two_add_one_lor_one_eq {n : } :
            n * 2 + 1 ||| 1 = n * 2 + 1
            theorem Nat.mod_self_pow_succ {n m : } (hn : n 1) (hm : m 0) :
            n % n ^ (m + 1) = n
            theorem Nat.beq_eq_eq {n m : } :
            (n == m) = decide (n = m)
            theorem Nat.testBit_eq_odd {n i : } :
            n.testBit i = decide (Odd (n >>> i))
            theorem Nat.ne_zero_of_odd {n : } (h : Odd n) :
            n 0
            theorem Nat.pos_of_odd {n : } (h : Odd n) :
            0 < n
            @[simp]
            theorem Nat.sum_min_left {n m : } :
            n - min n m = n - m
            @[simp]
            theorem Nat.sum_min_right {n m : } :
            n - min m n = n - m
            theorem Nat.eq_div_mod (n k : ) :
            n = n / k * k + n % k
            theorem Nat.eq_mod_div (n k : ) :
            n = n % k + n / k * k
            theorem Nat.eq_of_mod_eq_mod {n m : } (k : ) (hn : n < k) (hm : m < k) (h : n % k = m % k) :
            n = m
            theorem Nat.ind_step (k : ) {p : Prop} (h₁ : n < k, p n) (h₂ : ∀ (n : ), (∀ c < n + k, p c)p (n + k)) (n : ) :
            p n
            theorem Nat.not_le_mod {n k : } (hk : k 0) :
            ¬k n % k
            @[simp]
            theorem Nat.sub_succ_div_self_eq_zero {n m : } :
            (n - (m + 1)) / n = 0
            theorem Nat.exi_mul_add (n b : ) (h : b 0) :
            ∃ (m : ), r < b, n = m * b + r
            theorem Nat.lt_self_mul_add_iff {a b c : } :
            a < a * b + c (a 0 c 0) (a 0(b = 0a < c) (b 0c = 0b 1))
            @[simp]
            theorem Nat.lt_self_mul_iff' {b n : } :
            n < n * b 2 b n 0
            @[simp]
            theorem Nat.lt_mul_self_iff' {b n : } :
            n < b * n 2 b n 0
            theorem Nat.eq_of_le_and_dvd {n b : } (hb : b 0) (hn : n 0) (h₁ : n b) (h₂ : b n) :
            n = b
            theorem Nat.eq_of_le_and_mod_eq_zero {n b : } (hb : b 0) (hn : n 0) (h₁ : n b) (h₂ : n % b = 0) :
            n = b
            @[simp]
            @[simp]
            @[simp]
            theorem Nat.prime_2 :
            theorem Nat.prime_add_prime_iff {p : Prop} (hp : ∀ (a b c : ), p a b c p b a c) :
            (∀ (a b c : ), Prime aPrime bPrime ca + b = cp a b c) ∀ (a c : ), Prime aPrime cOdd aa + 2 = cp a 2 c
            theorem Nat.three_dvd_add_two_four {n : } :
            3 n 3 n + 2 3 n + 4
            theorem Nat.prime_iff' {n : } :
            Prime n 2 n ∀ (k : ), 2 kk < n¬k n
            theorem Nat.eq_of_prime_and_dvd {n p : } (hp : Prime p) (hn : Prime n) (h : p n) :
            n = p
            @[simp]
            theorem Nat.one_shiftLeft_eq_one_iff {n : } :
            1 <<< n = 1 n = 0
            theorem Nat.ind_bit {p : Prop} (h₁ : p 0) (h₂ : ∀ (n : ), p np (n * 2)) (h₃ : ∀ (n : ), p np (n * 2 + 1)) (n : ) :
            p n
            theorem Nat.or_mul_two_pow {n m k : } :
            (n ||| m) * 2 ^ k = n * 2 ^ k ||| m * 2 ^ k
            theorem Nat.or_two_pow_eq_add_of {n k : } (h : n < 2 ^ k) :
            n ||| 2 ^ k = n + 2 ^ k
            theorem Nat.two_pow_or_eq_add_of {n k : } (h : n < 2 ^ k) :
            2 ^ k ||| n = 2 ^ k + n
            theorem Nat.eq_div_add_mod (n b : ) :
            n = n / b * b + n % b
            theorem Nat.or_mul_two_pow_eq_add_of {n k c : } (h : n < 2 ^ k) :
            n ||| c * 2 ^ k = n + c * 2 ^ k
            theorem Nat.or_two_pow_mul_eq_add_of {n k c : } (h : n < 2 ^ k) :
            n ||| 2 ^ k * c = n + 2 ^ k * c
            @[simp]
            theorem Nat.le_two_pow_self {n : } :
            n 2 ^ n
            theorem Nat.mul_pow_mod_pow {b n k w : } :
            n * b ^ k % b ^ w = n % b ^ (w - k) * b ^ k
            @[simp]
            theorem Nat.ite_eq_ofProp {p : Prop} [Decidable p] :
            (if p then 1 else 0) = ofProp p
            @[simp]
            theorem Nat.ofProp_sub {p : Prop} {n : } :
            ofProp p - n = ofProp (n = 0 p)
            @[simp]
            theorem Nat.add_one_sub_ofProp {p : Prop} {n : } :
            n + 1 - ofProp p = n + ofProp ¬p