Documentation

Mathlib.Data.Int.Bitwise

Bitwise operations on integers #

Recursors #

bitwise ops #

@[simp]
@[simp]
@[simp]
theorem Int.bodd_coe (n : ℕ) :
@[simp]
@[simp]
theorem Int.bodd_neg (n : ℤ) :
@[simp]
theorem Int.bodd_add (m : ℤ) (n : ℤ) :
@[simp]
theorem Int.bodd_mul (m : ℤ) (n : ℤ) :
theorem Int.bodd_add_div2 (n : ℤ) :
(bif Int.bodd n then 1 else 0) + 2 * Int.div2 n = n
theorem Int.div2_val (n : ℤ) :
Int.div2 n = n / 2
@[deprecated]
theorem Int.bit0_val (n : ℤ) :
bit0 n = 2 * n
@[deprecated]
theorem Int.bit1_val (n : ℤ) :
bit1 n = 2 * n + 1
theorem Int.bit_val (b : Bool) (n : ℤ) :
Int.bit b n = 2 * n + bif b then 1 else 0
def Int.bitCasesOn {C : ℤ → Sort u} (n : ℤ) (h : (b : Bool) → (n : ℤ) → C (Int.bit b n)) :
C n

Defines a function from ℤ conditionally, if it is defined for odd and even integers separately using bit.

Equations
Instances For
    @[simp]
    @[simp]
    theorem Int.bit_coe_nat (b : Bool) (n : ℕ) :
    Int.bit b ↑n = ↑(Nat.bit b n)
    @[simp]
    theorem Int.bit_negSucc (b : Bool) (n : ℕ) :
    @[simp]
    theorem Int.bodd_bit (b : Bool) (n : ℤ) :
    @[simp, deprecated]
    theorem Int.bodd_bit0 (n : ℤ) :
    @[simp, deprecated]
    theorem Int.bodd_bit1 (n : ℤ) :
    @[deprecated]
    theorem Int.bit0_ne_bit1 (m : ℤ) (n : ℤ) :
    @[deprecated]
    theorem Int.bit1_ne_bit0 (m : ℤ) (n : ℤ) :
    @[deprecated]
    theorem Int.bit1_ne_zero (m : ℤ) :
    bit1 m ≠ 0
    @[simp]
    theorem Int.testBit_zero (b : Bool) (n : ℤ) :
    @[simp]
    theorem Int.testBit_succ (m : ℕ) (b : Bool) (n : ℤ) :
    theorem Int.bitwise_diff :
    (Int.bitwise fun (a b : Bool) => a && !b) = Int.ldiff
    @[simp]
    theorem Int.bitwise_bit (f : Bool → Bool → Bool) (a : Bool) (m : ℤ) (b : Bool) (n : ℤ) :
    Int.bitwise f (Int.bit a m) (Int.bit b n) = Int.bit (f a b) (Int.bitwise f m n)
    @[simp]
    theorem Int.lor_bit (a : Bool) (m : ℤ) (b : Bool) (n : ℤ) :
    Int.lor (Int.bit a m) (Int.bit b n) = Int.bit (a || b) (Int.lor m n)
    @[simp]
    theorem Int.land_bit (a : Bool) (m : ℤ) (b : Bool) (n : ℤ) :
    Int.land (Int.bit a m) (Int.bit b n) = Int.bit (a && b) (Int.land m n)
    @[simp]
    theorem Int.ldiff_bit (a : Bool) (m : ℤ) (b : Bool) (n : ℤ) :
    Int.ldiff (Int.bit a m) (Int.bit b n) = Int.bit (a && !b) (Int.ldiff m n)
    @[simp]
    theorem Int.lxor_bit (a : Bool) (m : ℤ) (b : Bool) (n : ℤ) :
    Int.xor (Int.bit a m) (Int.bit b n) = Int.bit (xor a b) (Int.xor m n)
    @[simp]
    theorem Int.lnot_bit (b : Bool) (n : ℤ) :
    @[simp]
    theorem Int.testBit_bitwise (f : Bool → Bool → Bool) (m : ℤ) (n : ℤ) (k : ℕ) :
    @[simp]
    theorem Int.testBit_lor (m : ℤ) (n : ℤ) (k : ℕ) :
    @[simp]
    theorem Int.testBit_land (m : ℤ) (n : ℤ) (k : ℕ) :
    @[simp]
    theorem Int.testBit_ldiff (m : ℤ) (n : ℤ) (k : ℕ) :
    @[simp]
    theorem Int.testBit_lxor (m : ℤ) (n : ℤ) (k : ℕ) :
    @[simp]
    theorem Int.testBit_lnot (n : ℤ) (k : ℕ) :
    @[simp]
    theorem Int.shiftLeft_neg (m : ℤ) (n : ℤ) :
    m <<< (-n) = m >>> n
    @[simp]
    theorem Int.shiftRight_neg (m : ℤ) (n : ℤ) :
    m >>> (-n) = m <<< n
    @[simp]
    theorem Int.shiftLeft_coe_nat (m : ℕ) (n : ℕ) :
    ↑m <<< ↑n = ↑(m <<< n)
    @[simp]
    theorem Int.shiftRight_coe_nat (m : ℕ) (n : ℕ) :
    ↑m >>> ↑n = ↑(m >>> n)
    @[simp]
    theorem Int.shiftRight_negSucc (m : ℕ) (n : ℕ) :
    theorem Int.shiftRight_add (m : ℤ) (n : ℕ) (k : ℕ) :
    m >>> (↑n + ↑k) = m >>> ↑n >>> ↑k

    bitwise ops #

    theorem Int.shiftLeft_add (m : ℤ) (n : ℕ) (k : ℤ) :
    m <<< (↑n + k) = m <<< ↑n <<< k
    theorem Int.shiftLeft_sub (m : ℤ) (n : ℕ) (k : ℤ) :
    m <<< (↑n - k) = m <<< ↑n >>> k
    theorem Int.shiftLeft_eq_mul_pow (m : ℤ) (n : ℕ) :
    m <<< ↑n = m * ↑(2 ^ n)
    theorem Int.shiftRight_eq_div_pow (m : ℤ) (n : ℕ) :
    m >>> ↑n = m / ↑(2 ^ n)
    theorem Int.one_shiftLeft (n : ℕ) :
    1 <<< ↑n = ↑(2 ^ n)
    @[simp]
    theorem Int.zero_shiftLeft (n : ℤ) :
    0 <<< n = 0
    @[simp]
    theorem Int.zero_shiftRight (n : ℤ) :
    0 >>> n = 0