Documentation

Init.Data.UInt.Basic

@[extern lean_uint8_add]
def UInt8.add (a b : UInt8) :
Equations
  • a.add b = { toBitVec := a.toBitVec + b.toBitVec }
Instances For
    @[extern lean_uint8_sub]
    def UInt8.sub (a b : UInt8) :
    Equations
    • a.sub b = { toBitVec := a.toBitVec - b.toBitVec }
    Instances For
      @[extern lean_uint8_mul]
      def UInt8.mul (a b : UInt8) :
      Equations
      • a.mul b = { toBitVec := a.toBitVec * b.toBitVec }
      Instances For
        @[extern lean_uint8_div]
        def UInt8.div (a b : UInt8) :
        Equations
        • a.div b = { toBitVec := a.toBitVec.udiv b.toBitVec }
        Instances For
          @[extern lean_uint8_mod]
          def UInt8.mod (a b : UInt8) :
          Equations
          • a.mod b = { toBitVec := a.toBitVec.umod b.toBitVec }
          Instances For
            @[deprecated UInt8.mod]
            def UInt8.modn (a : UInt8) (n : Nat) :
            Equations
            • a.modn n = { toBitVec := (a.val.modn n) }
            Instances For
              @[extern lean_uint8_land]
              def UInt8.land (a b : UInt8) :
              Equations
              • a.land b = { toBitVec := a.toBitVec &&& b.toBitVec }
              Instances For
                @[extern lean_uint8_lor]
                def UInt8.lor (a b : UInt8) :
                Equations
                • a.lor b = { toBitVec := a.toBitVec ||| b.toBitVec }
                Instances For
                  @[extern lean_uint8_xor]
                  def UInt8.xor (a b : UInt8) :
                  Equations
                  • a.xor b = { toBitVec := a.toBitVec ^^^ b.toBitVec }
                  Instances For
                    @[extern lean_uint8_shift_left]
                    Equations
                    • a.shiftLeft b = { toBitVec := a.toBitVec <<< (b.mod 8).toBitVec }
                    Instances For
                      @[extern lean_uint8_shift_right]
                      Equations
                      • a.shiftRight b = { toBitVec := a.toBitVec >>> (b.mod 8).toBitVec }
                      Instances For
                        def UInt8.lt (a b : UInt8) :
                        Equations
                        • a.lt b = (a.toBitVec < b.toBitVec)
                        Instances For
                          def UInt8.le (a b : UInt8) :
                          Equations
                          • a.le b = (a.toBitVec b.toBitVec)
                          Instances For
                            Equations
                            Equations
                            Equations
                            Equations
                            Equations
                            instance instLTUInt8 :
                            Equations
                            instance instLEUInt8 :
                            Equations
                            @[extern lean_uint8_complement]
                            Equations
                            • a.complement = { toBitVec := ~~~a.toBitVec }
                            Instances For
                              Equations
                              @[extern lean_bool_to_uint8]
                              Equations
                              • b.toUInt8 = if b = true then 1 else 0
                              Instances For
                                @[extern lean_uint8_dec_lt]
                                def UInt8.decLt (a b : UInt8) :
                                Decidable (a < b)
                                Equations
                                Instances For
                                  @[extern lean_uint8_dec_le]
                                  def UInt8.decLe (a b : UInt8) :
                                  Equations
                                  Instances For
                                    instance instDecidableLtUInt8 (a b : UInt8) :
                                    Decidable (a < b)
                                    Equations
                                    instance instDecidableLeUInt8 (a b : UInt8) :
                                    Equations
                                    Equations
                                    Equations
                                    @[extern lean_uint16_add]
                                    def UInt16.add (a b : UInt16) :
                                    Equations
                                    • a.add b = { toBitVec := a.toBitVec + b.toBitVec }
                                    Instances For
                                      @[extern lean_uint16_sub]
                                      def UInt16.sub (a b : UInt16) :
                                      Equations
                                      • a.sub b = { toBitVec := a.toBitVec - b.toBitVec }
                                      Instances For
                                        @[extern lean_uint16_mul]
                                        def UInt16.mul (a b : UInt16) :
                                        Equations
                                        • a.mul b = { toBitVec := a.toBitVec * b.toBitVec }
                                        Instances For
                                          @[extern lean_uint16_div]
                                          def UInt16.div (a b : UInt16) :
                                          Equations
                                          • a.div b = { toBitVec := a.toBitVec.udiv b.toBitVec }
                                          Instances For
                                            @[extern lean_uint16_mod]
                                            def UInt16.mod (a b : UInt16) :
                                            Equations
                                            • a.mod b = { toBitVec := a.toBitVec.umod b.toBitVec }
                                            Instances For
                                              @[deprecated UInt16.mod]
                                              def UInt16.modn (a : UInt16) (n : Nat) :
                                              Equations
                                              • a.modn n = { toBitVec := (a.val.modn n) }
                                              Instances For
                                                @[extern lean_uint16_land]
                                                Equations
                                                • a.land b = { toBitVec := a.toBitVec &&& b.toBitVec }
                                                Instances For
                                                  @[extern lean_uint16_lor]
                                                  def UInt16.lor (a b : UInt16) :
                                                  Equations
                                                  • a.lor b = { toBitVec := a.toBitVec ||| b.toBitVec }
                                                  Instances For
                                                    @[extern lean_uint16_xor]
                                                    def UInt16.xor (a b : UInt16) :
                                                    Equations
                                                    • a.xor b = { toBitVec := a.toBitVec ^^^ b.toBitVec }
                                                    Instances For
                                                      @[extern lean_uint16_shift_left]
                                                      Equations
                                                      • a.shiftLeft b = { toBitVec := a.toBitVec <<< (b.mod 16).toBitVec }
                                                      Instances For
                                                        @[extern lean_uint16_shift_right]
                                                        Equations
                                                        • a.shiftRight b = { toBitVec := a.toBitVec >>> (b.mod 16).toBitVec }
                                                        Instances For
                                                          def UInt16.lt (a b : UInt16) :
                                                          Equations
                                                          • a.lt b = (a.toBitVec < b.toBitVec)
                                                          Instances For
                                                            def UInt16.le (a b : UInt16) :
                                                            Equations
                                                            • a.le b = (a.toBitVec b.toBitVec)
                                                            Instances For
                                                              Equations
                                                              Equations
                                                              @[extern lean_uint16_complement]
                                                              Equations
                                                              • a.complement = { toBitVec := ~~~a.toBitVec }
                                                              Instances For
                                                                @[extern lean_bool_to_uint16]
                                                                Equations
                                                                • b.toUInt16 = if b = true then 1 else 0
                                                                Instances For
                                                                  @[extern lean_uint16_dec_lt]
                                                                  def UInt16.decLt (a b : UInt16) :
                                                                  Decidable (a < b)
                                                                  Equations
                                                                  Instances For
                                                                    @[extern lean_uint16_dec_le]
                                                                    def UInt16.decLe (a b : UInt16) :
                                                                    Equations
                                                                    Instances For
                                                                      instance instDecidableLtUInt16 (a b : UInt16) :
                                                                      Decidable (a < b)
                                                                      Equations
                                                                      instance instDecidableLeUInt16 (a b : UInt16) :
                                                                      Equations
                                                                      Equations
                                                                      Equations
                                                                      @[extern lean_uint32_add]
                                                                      def UInt32.add (a b : UInt32) :
                                                                      Equations
                                                                      • a.add b = { toBitVec := a.toBitVec + b.toBitVec }
                                                                      Instances For
                                                                        @[extern lean_uint32_sub]
                                                                        def UInt32.sub (a b : UInt32) :
                                                                        Equations
                                                                        • a.sub b = { toBitVec := a.toBitVec - b.toBitVec }
                                                                        Instances For
                                                                          @[extern lean_uint32_mul]
                                                                          def UInt32.mul (a b : UInt32) :
                                                                          Equations
                                                                          • a.mul b = { toBitVec := a.toBitVec * b.toBitVec }
                                                                          Instances For
                                                                            @[extern lean_uint32_div]
                                                                            def UInt32.div (a b : UInt32) :
                                                                            Equations
                                                                            • a.div b = { toBitVec := a.toBitVec.udiv b.toBitVec }
                                                                            Instances For
                                                                              @[extern lean_uint32_mod]
                                                                              def UInt32.mod (a b : UInt32) :
                                                                              Equations
                                                                              • a.mod b = { toBitVec := a.toBitVec.umod b.toBitVec }
                                                                              Instances For
                                                                                @[deprecated UInt32.mod]
                                                                                def UInt32.modn (a : UInt32) (n : Nat) :
                                                                                Equations
                                                                                • a.modn n = { toBitVec := (a.val.modn n) }
                                                                                Instances For
                                                                                  @[extern lean_uint32_land]
                                                                                  Equations
                                                                                  • a.land b = { toBitVec := a.toBitVec &&& b.toBitVec }
                                                                                  Instances For
                                                                                    @[extern lean_uint32_lor]
                                                                                    def UInt32.lor (a b : UInt32) :
                                                                                    Equations
                                                                                    • a.lor b = { toBitVec := a.toBitVec ||| b.toBitVec }
                                                                                    Instances For
                                                                                      @[extern lean_uint32_xor]
                                                                                      def UInt32.xor (a b : UInt32) :
                                                                                      Equations
                                                                                      • a.xor b = { toBitVec := a.toBitVec ^^^ b.toBitVec }
                                                                                      Instances For
                                                                                        @[extern lean_uint32_shift_left]
                                                                                        Equations
                                                                                        • a.shiftLeft b = { toBitVec := a.toBitVec <<< (b.mod 32).toBitVec }
                                                                                        Instances For
                                                                                          @[extern lean_uint32_shift_right]
                                                                                          Equations
                                                                                          • a.shiftRight b = { toBitVec := a.toBitVec >>> (b.mod 32).toBitVec }
                                                                                          Instances For
                                                                                            @[extern lean_uint32_complement]
                                                                                            Equations
                                                                                            • a.complement = { toBitVec := ~~~a.toBitVec }
                                                                                            Instances For
                                                                                              @[extern lean_bool_to_uint32]
                                                                                              Equations
                                                                                              • b.toUInt32 = if b = true then 1 else 0
                                                                                              Instances For
                                                                                                @[extern lean_uint64_add]
                                                                                                def UInt64.add (a b : UInt64) :
                                                                                                Equations
                                                                                                • a.add b = { toBitVec := a.toBitVec + b.toBitVec }
                                                                                                Instances For
                                                                                                  @[extern lean_uint64_sub]
                                                                                                  def UInt64.sub (a b : UInt64) :
                                                                                                  Equations
                                                                                                  • a.sub b = { toBitVec := a.toBitVec - b.toBitVec }
                                                                                                  Instances For
                                                                                                    @[extern lean_uint64_mul]
                                                                                                    def UInt64.mul (a b : UInt64) :
                                                                                                    Equations
                                                                                                    • a.mul b = { toBitVec := a.toBitVec * b.toBitVec }
                                                                                                    Instances For
                                                                                                      @[extern lean_uint64_div]
                                                                                                      def UInt64.div (a b : UInt64) :
                                                                                                      Equations
                                                                                                      • a.div b = { toBitVec := a.toBitVec.udiv b.toBitVec }
                                                                                                      Instances For
                                                                                                        @[extern lean_uint64_mod]
                                                                                                        def UInt64.mod (a b : UInt64) :
                                                                                                        Equations
                                                                                                        • a.mod b = { toBitVec := a.toBitVec.umod b.toBitVec }
                                                                                                        Instances For
                                                                                                          @[deprecated UInt64.mod]
                                                                                                          def UInt64.modn (a : UInt64) (n : Nat) :
                                                                                                          Equations
                                                                                                          • a.modn n = { toBitVec := (a.val.modn n) }
                                                                                                          Instances For
                                                                                                            @[extern lean_uint64_land]
                                                                                                            Equations
                                                                                                            • a.land b = { toBitVec := a.toBitVec &&& b.toBitVec }
                                                                                                            Instances For
                                                                                                              @[extern lean_uint64_lor]
                                                                                                              def UInt64.lor (a b : UInt64) :
                                                                                                              Equations
                                                                                                              • a.lor b = { toBitVec := a.toBitVec ||| b.toBitVec }
                                                                                                              Instances For
                                                                                                                @[extern lean_uint64_xor]
                                                                                                                def UInt64.xor (a b : UInt64) :
                                                                                                                Equations
                                                                                                                • a.xor b = { toBitVec := a.toBitVec ^^^ b.toBitVec }
                                                                                                                Instances For
                                                                                                                  @[extern lean_uint64_shift_left]
                                                                                                                  Equations
                                                                                                                  • a.shiftLeft b = { toBitVec := a.toBitVec <<< (b.mod 64).toBitVec }
                                                                                                                  Instances For
                                                                                                                    @[extern lean_uint64_shift_right]
                                                                                                                    Equations
                                                                                                                    • a.shiftRight b = { toBitVec := a.toBitVec >>> (b.mod 64).toBitVec }
                                                                                                                    Instances For
                                                                                                                      def UInt64.lt (a b : UInt64) :
                                                                                                                      Equations
                                                                                                                      • a.lt b = (a.toBitVec < b.toBitVec)
                                                                                                                      Instances For
                                                                                                                        def UInt64.le (a b : UInt64) :
                                                                                                                        Equations
                                                                                                                        • a.le b = (a.toBitVec b.toBitVec)
                                                                                                                        Instances For
                                                                                                                          Equations
                                                                                                                          Equations
                                                                                                                          @[extern lean_uint64_complement]
                                                                                                                          Equations
                                                                                                                          • a.complement = { toBitVec := ~~~a.toBitVec }
                                                                                                                          Instances For
                                                                                                                            @[extern lean_bool_to_uint64]
                                                                                                                            Equations
                                                                                                                            • b.toUInt64 = if b = true then 1 else 0
                                                                                                                            Instances For
                                                                                                                              @[extern lean_uint64_dec_lt]
                                                                                                                              def UInt64.decLt (a b : UInt64) :
                                                                                                                              Decidable (a < b)
                                                                                                                              Equations
                                                                                                                              Instances For
                                                                                                                                @[extern lean_uint64_dec_le]
                                                                                                                                def UInt64.decLe (a b : UInt64) :
                                                                                                                                Equations
                                                                                                                                Instances For
                                                                                                                                  instance instDecidableLtUInt64 (a b : UInt64) :
                                                                                                                                  Decidable (a < b)
                                                                                                                                  Equations
                                                                                                                                  instance instDecidableLeUInt64 (a b : UInt64) :
                                                                                                                                  Equations
                                                                                                                                  Equations
                                                                                                                                  Equations
                                                                                                                                  theorem usize_size_le :
                                                                                                                                  USize.size 18446744073709551616
                                                                                                                                  theorem le_usize_size :
                                                                                                                                  4294967296 USize.size
                                                                                                                                  @[extern lean_usize_mul]
                                                                                                                                  def USize.mul (a b : USize) :
                                                                                                                                  Equations
                                                                                                                                  • a.mul b = { toBitVec := a.toBitVec * b.toBitVec }
                                                                                                                                  Instances For
                                                                                                                                    @[extern lean_usize_div]
                                                                                                                                    def USize.div (a b : USize) :
                                                                                                                                    Equations
                                                                                                                                    • a.div b = { toBitVec := a.toBitVec / b.toBitVec }
                                                                                                                                    Instances For
                                                                                                                                      @[extern lean_usize_mod]
                                                                                                                                      def USize.mod (a b : USize) :
                                                                                                                                      Equations
                                                                                                                                      • a.mod b = { toBitVec := a.toBitVec % b.toBitVec }
                                                                                                                                      Instances For
                                                                                                                                        @[deprecated USize.mod]
                                                                                                                                        def USize.modn (a : USize) (n : Nat) :
                                                                                                                                        Equations
                                                                                                                                        • a.modn n = { toBitVec := (a.val.modn n) }
                                                                                                                                        Instances For
                                                                                                                                          @[extern lean_usize_land]
                                                                                                                                          def USize.land (a b : USize) :
                                                                                                                                          Equations
                                                                                                                                          • a.land b = { toBitVec := a.toBitVec &&& b.toBitVec }
                                                                                                                                          Instances For
                                                                                                                                            @[extern lean_usize_lor]
                                                                                                                                            def USize.lor (a b : USize) :
                                                                                                                                            Equations
                                                                                                                                            • a.lor b = { toBitVec := a.toBitVec ||| b.toBitVec }
                                                                                                                                            Instances For
                                                                                                                                              @[extern lean_usize_xor]
                                                                                                                                              def USize.xor (a b : USize) :
                                                                                                                                              Equations
                                                                                                                                              • a.xor b = { toBitVec := a.toBitVec ^^^ b.toBitVec }
                                                                                                                                              Instances For
                                                                                                                                                @[extern lean_usize_shift_left]
                                                                                                                                                Equations
                                                                                                                                                Instances For
                                                                                                                                                  @[extern lean_usize_shift_right]
                                                                                                                                                  Equations
                                                                                                                                                  Instances For
                                                                                                                                                    @[extern lean_usize_of_nat]
                                                                                                                                                    def USize.ofNat32 (n : Nat) (h : n < 4294967296) :

                                                                                                                                                    Upcast a Nat less than 2^32 to a USize. This is lossless because USize.size is either 2^32 or 2^64. This function is overridden with a native implementation.

                                                                                                                                                    Equations
                                                                                                                                                    Instances For
                                                                                                                                                      @[extern lean_uint8_to_usize]
                                                                                                                                                      Equations
                                                                                                                                                      Instances For
                                                                                                                                                        @[extern lean_usize_to_uint8]
                                                                                                                                                        Equations
                                                                                                                                                        • a.toUInt8 = a.toNat.toUInt8
                                                                                                                                                        Instances For
                                                                                                                                                          @[extern lean_uint16_to_usize]
                                                                                                                                                          Equations
                                                                                                                                                          Instances For
                                                                                                                                                            @[extern lean_usize_to_uint16]
                                                                                                                                                            Equations
                                                                                                                                                            • a.toUInt16 = a.toNat.toUInt16
                                                                                                                                                            Instances For
                                                                                                                                                              @[extern lean_uint32_to_usize]
                                                                                                                                                              Equations
                                                                                                                                                              Instances For
                                                                                                                                                                @[extern lean_usize_to_uint32]
                                                                                                                                                                Equations
                                                                                                                                                                • a.toUInt32 = a.toNat.toUInt32
                                                                                                                                                                Instances For
                                                                                                                                                                  @[extern lean_uint64_to_usize]

                                                                                                                                                                  Converts a UInt64 to a USize by reducing modulo USize.size.

                                                                                                                                                                  Equations
                                                                                                                                                                  • a.toUSize = a.toNat.toUSize
                                                                                                                                                                  Instances For
                                                                                                                                                                    @[extern lean_usize_to_uint64]

                                                                                                                                                                    Upcast a USize to a UInt64. This is lossless because USize.size is either 2^32 or 2^64. This function is overridden with a native implementation.

                                                                                                                                                                    Equations
                                                                                                                                                                    Instances For
                                                                                                                                                                      Equations
                                                                                                                                                                      Equations
                                                                                                                                                                      Equations
                                                                                                                                                                      @[extern lean_usize_complement]
                                                                                                                                                                      Equations
                                                                                                                                                                      • a.complement = { toBitVec := ~~~a.toBitVec }
                                                                                                                                                                      Instances For
                                                                                                                                                                        Equations
                                                                                                                                                                        @[extern lean_bool_to_usize]
                                                                                                                                                                        Equations
                                                                                                                                                                        • b.toUSize = if b = true then 1 else 0
                                                                                                                                                                        Instances For
                                                                                                                                                                          Equations
                                                                                                                                                                          Equations