Documentation

Mathlib.Data.Int.Bitwise

Bitwise operations on integers #

Possibly only of archaeological significance.

Recursors #

def Int.div2 :

div2 n = n/2

Equations
Instances For
    def Int.bodd :
    Bool

    bodd n returns true if n is odd

    Equations
    Instances For
      def Int.bit (b : Bool) :

      bit b appends the digit b to the binary representation of its integer input.

      Equations
      Instances For
        def Int.testBit :
        Bool

        testBit m n returns whether the (n+1)ˢᵗ least significant bit is 1 or 0

        Equations
        Instances For
          def Int.natBitwise (f : BoolBoolBool) (m : ) (n : ) :

          Int.natBitwise is an auxiliary definition for Int.bitwise.

          Equations
          Instances For
            def Int.bitwise (f : BoolBoolBool) :

            Int.bitwise applies the function f to pairs of bits in the same position in the binary representations of its inputs.

            Equations
            • One or more equations did not get rendered due to their size.
            Instances For
              def Int.lnot :

              lnot flips all the bits in the binary representation of its input

              Equations
              Instances For
                def Int.lor :

                lor takes two integers and returns their bitwise or

                Equations
                • One or more equations did not get rendered due to their size.
                Instances For
                  def Int.land :

                  land takes two integers and returns their bitwise and

                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For
                    def Int.ldiff :

                    ldiff a b performs bitwise set difference. For each corresponding pair of bits taken as booleans, say aᵢ and bᵢ, it applies the boolean operation aᵢ ∧ bᵢ to obtain the iᵗʰ bit of the result.

                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For
                      def Int.xor :

                      xor computes the bitwise xor of two natural numbers

                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For

                        m <<< n produces an integer whose binary representation is obtained by left-shifting the binary representation of m by n places

                        Equations
                        • One or more equations did not get rendered due to their size.

                        m >>> n produces an integer whose binary representation is obtained by right-shifting the binary representation of m by n places

                        Equations

                        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_bit_zero (b : Bool) (n : ) :
                          @[simp]
                          theorem Int.testBit_bit_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 : BoolBoolBool) (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 : BoolBoolBool) (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