Documentation

Projects.Util.Int

@[instance_reducible]
Equations
@[instance_reducible]
Equations
@[instance_reducible]
Equations
theorem Int.even_iff_exi {n : ℤ} :
Even n ↔ ∃ (k : ℤ), n = k * 2
theorem Int.odd_iff_exi {n : ℤ} :
Odd n ↔ ∃ (k : ℤ), n = k * 2 + 1
theorem Int.mod_2_ind {P : ℤ → Prop} (h₁ : ∀ (n : ℤ), P (n * 2)) (h₂ : ∀ (n : ℤ), P (n * 2 + 1)) (n : ℤ) :
P n
theorem Int.not_even_mul_2_succ {n : ℤ} :
¬Even (n * 2 + 1)
@[simp]
theorem Int.not_odd_mul_2 {n : ℤ} :
¬Odd (n * 2)
theorem Int.le_one_iff {n : ℤ} (h : 0 ≤ n) :
n ≤ 1 ↔ n = 0 ∨ n = 1
theorem Int.of_between_succ {a b : ℤ} (h₁ : a ≤ b) (h₂ : b ≤ a + 1) :
b = a ∨ b = a + 1
theorem Int.add_div_eq {a b : ℤ} (h : 0 < b) :
(a + b) / b = a / b + 1
theorem Int.negSucc_succ {n : ℕ} :
negSucc (n + 1) = negSucc n - 1
@[simp]
theorem Int.even_succ_iff {n : ℤ} :
Even (n + 1) ↔ Odd n
@[simp]
theorem Int.odd_succ_iff {n : ℤ} :
Odd (n + 1) ↔ Even n
theorem Int.succ_div_2_eq_div_iff {n : ℤ} (hp : 0 ≤ n) :
(n + 1) / 2 = n / 2 ↔ Even n
theorem Int.succ_div_2_eq_div_succ_iff {n : ℤ} (hp : 0 ≤ n) :
(n + 1) / 2 = n / 2 + 1 ↔ Odd n
theorem Int.succ_div_2_eq_or_eq {n : ℤ} (hp : 0 ≤ n) :
(n + 1) / 2 = n / 2 ∨ (n + 1) / 2 = n / 2 + 1
theorem Int.succ_div_2_eq_div_iff' {n : ℤ} (hp : 0 ≤ n) :
n / 2 = (n + 1) / 2 ↔ Even n
@[simp]
theorem Int.succ_div_2_eq_div_succ_iff' {n : ℤ} (hp : 0 ≤ n) :
n / 2 + 1 = (n + 1) / 2 ↔ Odd n
theorem Int.mul_2_succ_div_2_eq {n : ℤ} (hp : 0 ≤ n) :
(n * 2 + 1) / 2 = n
@[simp]
theorem Int.max_abs_eq_zero_iff {n m : ℤ} :
max |n| |m| = 0 ↔ n = 0 ∧ m = 0
@[simp]
theorem Int.eq_self_sub_iff {a b : ℤ} :
a = a - b ↔ b = 0
theorem Int.toNat_eq_self_of {z : ℤ} (h₁ : 0 ≤ z) :
↑z.toNat = z
@[simp]
theorem Int.zero_land {n : ℤ} :
0 &&& n = 0
@[simp]
theorem Int.lit_neg_land_lit_pos {n m : ℕ} :
-OfNat.ofNat (n + 1) &&& OfNat.ofNat m = ↑(m.ldiff n)
@[simp]
theorem Int.testBit_ofNat {n i : ℕ} :
@[simp]
theorem Int.testBit_natCast {n i : ℕ} :
(↑n).testBit i = n.testBit i
@[simp]
theorem Int.testBit_negSucc {n i : ℕ} :
theorem Int.ext_testBit {n m : ℤ} (h : ∀ (i : ℕ), n.testBit i = m.testBit i) :
n = m
theorem Int.ext_testBit_iff {n m : ℤ} :
n = m ↔ ∀ (i : ℕ), n.testBit i = m.testBit i
@[simp]
theorem Int.testBit_lor' {n m : ℤ} {i : ℕ} :
(n ||| m).testBit i = (n.testBit i || m.testBit i)
@[simp]
theorem Int.testBit_land' {n m : ℤ} {i : ℕ} :
(n &&& m).testBit i = (n.testBit i && m.testBit i)
@[simp]
theorem Int.testBit_lxor' {n m : ℤ} {i : ℕ} :
(n ^^^ m).testBit i = (n.testBit i ^^ m.testBit i)
theorem Int.lxor_land {n m k : ℤ} :
(n ^^^ m) &&& k = n &&& k ^^^ m &&& k
@[simp]
theorem Int.lxor_eq_left_iff {n m : ℤ} :
n ^^^ m = n ↔ m = 0
@[simp]
theorem Int.lxor_eq_right_iff {n m : ℤ} :
n ^^^ m = m ↔ n = 0
@[simp]
@[simp]
theorem Int.testBit_succ_zero {n : ℤ} :
(n + 1).testBit 0 = !n.testBit 0
theorem Int.cases_pos_neg {p : ℤ → Prop} (h₁ : ∀ (n : ℕ), p ↑n) (h₂ : ∀ (n : ℕ), p (-↑n)) (n : ℤ) :
p n
theorem Int.testBit_neg_natCast_succ {n i : ℕ} :
(-↑(n + 1)).testBit i = !n.testBit i
theorem Int.succ_eq_lor {n : ℤ} (h : n.testBit 0 = false) :
n + 1 = n ||| 1
theorem Int.lor_eq_succ {n : ℤ} (h : n.testBit 0 = false) :
n ||| 1 = n + 1
@[simp]
theorem Int.land_lnot_succ_eq_zero_iff {n : ℤ} :
n &&& (n + 1).lnot = 0 ↔ n &&& 1 = 0
theorem Int.lor_comm {n m : ℤ} :
n ||| m = m ||| n
theorem Int.land_comm {n m : ℤ} :
n &&& m = m &&& n
theorem Int.xor_comm {n m : ℤ} :
n ^^^ m = m ^^^ n
theorem Int.lor_lor_self {n m : ℤ} :
n ||| m ||| n = n ||| m
@[simp]
theorem Int.land_one_ne_zero_iff {n : ℤ} :
n &&& 1 ≠ 0 ↔ n &&& 1 = 1
@[simp]
theorem Int.land_one_ne_one_iff {n : ℤ} :
n &&& 1 ≠ 1 ↔ n &&& 1 = 0
theorem Int.xor_land {n m k : ℤ} :
(n ^^^ m) &&& k = n &&& k ^^^ m &&& k
@[simp]
theorem Int.land_lnot_succ_land_one_eq_one_iff {n : ℤ} :
n &&& (n + 1).lnot &&& 1 = 1 ↔ n &&& 1 = 1
@[simp]
theorem Int.testBit_shiftRight_natCast {n : ℤ} {m i : ℕ} :
(n >>> m).testBit i = n.testBit (m + i)
@[simp]
theorem Int.testBit_shiftRight_nat_lit {n : ℤ} {m i : ℕ} :
(n >>> OfNat.ofNat m).testBit i = n.testBit (m + i)
@[simp]
theorem Int.testBit_natCast_succ {n : ℕ} :
(↑n + 1).testBit = (n + 1).testBit
@[simp]
theorem Int.negSucc_succ_add_one {n : ℕ} :
negSucc (n + 1) + 1 = negSucc n
@[simp]
theorem Int.testBit_succ_one {n : ℤ} :
(n + 1).testBit 1 = (n.testBit 0 ^^ n.testBit 1)
@[simp]
theorem Int.lnot_zero :
lnot 0 = -1
@[simp]
theorem Int.lor_self {n : ℤ} :
n ||| n = n
@[simp]
theorem Int.land_self {n : ℤ} :
n &&& n = n
@[simp]
theorem Int.xor_self {n : ℤ} :
n ^^^ n = 0
@[simp]
theorem Int.neg_one_lor {n : ℤ} :
-1 ||| n = -1
@[simp]
theorem Int.lor_neg_one {n : ℤ} :
n ||| -1 = -1
@[simp]
theorem Int.neg_one_land {n : ℤ} :
-1 &&& n = n
@[simp]
theorem Int.land_neg_one {n : ℤ} :
n &&& -1 = n
theorem Int.shiftRight_natCast_left {n m : ℕ} :
↑n >>> m = ↑(n >>> m)
@[simp]
theorem Int.shiftRight_nat_lit {n : ℤ} {m : ℕ} :
@[simp]
theorem Int.neg_one_shiftRight_nat {n : ℕ} :
(-1) >>> n = -1
@[simp]
theorem Int.natCast_shiftRight_self {n : ℕ} :
↑n >>> n = 0
@[simp]
theorem Int.testBit_mul_two_succ {n : ℤ} {i : ℕ} :
(n * 2).testBit (i + 1) = n.testBit i
@[simp]
theorem Int.testBit_neg_natCast_mul_two_succ {n i : ℕ} :
(-(↑n * 2)).testBit (i + 1) = (-↑n).testBit i
@[simp]
theorem Int.mul_two_shiftRight_nat_succ {n : ℤ} {i : ℕ} :
(n * 2) >>> (i + 1) = n >>> i
theorem Int.testBit_shiftRight_nat_add_one {n : ℤ} {i : ℕ} :
(n >>> 1 + 1).testBit i = (n + 2).testBit (i + 1)
@[simp]
theorem Int.testBit_natCast_add_natCast_lit {n m : ℕ} :
(↑n + ↑m).testBit = (n + m).testBit
@[simp]
@[simp]
theorem Int.testBit_neg_one_sub_natCast {n i : ℕ} :
(-1 + -↑n).testBit i = !n.testBit i
@[simp]
theorem Int.lor_one_add_one_succ {n : ℤ} {i : ℕ} :
((n ||| 1) + 1).testBit (i + 1) = (n + 2).testBit (i + 1)
@[simp]
@[simp]
theorem Int.odd_negSucc_iff {n : ℕ} :