Module docstring
{}
{}
UInt8.ofFin
definition
(a : Fin UInt8.size) : UInt8
/-- Converts a `Fin UInt8.size` into the corresponding `UInt8`. -/
@[inline] def UInt8.ofFin (a : Fin UInt8.size) : UInt8 := ⟨⟨a⟩⟩
UInt8.mk
definition
(bitVec : BitVec 8) : UInt8
@[deprecated UInt8.ofBitVec (since := "2025-02-12"), inherit_doc UInt8.ofBitVec]
def UInt8.mk (bitVec : BitVec 8) : UInt8 :=
UInt8.ofBitVec bitVec
UInt8.ofNatCore
definition
(n : Nat) (h : n < UInt8.size) : UInt8
@[inline, deprecated UInt8.ofNatLT (since := "2025-02-13"), inherit_doc UInt8.ofNatLT]
def UInt8.ofNatCore (n : Nat) (h : n < UInt8.size) : UInt8 :=
UInt8.ofNatLT n h
UInt8.add
definition
(a b : UInt8) : UInt8
/--
Adds two 8-bit unsigned integers, wrapping around on overflow. Usually accessed via the `+`
operator.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint8_add"]
protected def UInt8.add (a b : UInt8) : UInt8 := ⟨a.toBitVec + b.toBitVec⟩
UInt8.sub
definition
(a b : UInt8) : UInt8
/--
Subtracts one 8-bit unsigned integer from another, wrapping around on underflow. Usually accessed
via the `-` operator.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint8_sub"]
protected def UInt8.sub (a b : UInt8) : UInt8 := ⟨a.toBitVec - b.toBitVec⟩
UInt8.mul
definition
(a b : UInt8) : UInt8
/--
Multiplies two 8-bit unsigned integers, wrapping around on overflow. Usually accessed via the `*`
operator.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint8_mul"]
protected def UInt8.mul (a b : UInt8) : UInt8 := ⟨a.toBitVec * b.toBitVec⟩
UInt8.div
definition
(a b : UInt8) : UInt8
/--
Unsigned division for 8-bit unsigned integers, discarding the remainder. Usually accessed
via the `/` operator.
This operation is sometimes called “floor division.” Division by zero is defined to be zero.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint8_div"]
protected def UInt8.div (a b : UInt8) : UInt8 := ⟨BitVec.udiv a.toBitVec b.toBitVec⟩
UInt8.mod
definition
(a b : UInt8) : UInt8
/--
The modulo operator for 8-bit unsigned integers, which computes the remainder when dividing one
integer by another. Usually accessed via the `%` operator.
When the divisor is `0`, the result is the dividend rather than an error.
This function is overridden at runtime with an efficient implementation.
Examples:
* `UInt8.mod 5 2 = 1`
* `UInt8.mod 4 2 = 0`
* `UInt8.mod 4 0 = 4`
-/
@[extern "lean_uint8_mod"]
protected def UInt8.mod (a b : UInt8) : UInt8 := ⟨BitVec.umod a.toBitVec b.toBitVec⟩
UInt8.modn
definition
(a : UInt8) (n : Nat) : UInt8
@[deprecated UInt8.mod (since := "2024-09-23")]
protected def UInt8.modn (a : UInt8) (n : Nat) : UInt8 := ⟨Fin.modn a.toFin n⟩
UInt8.land
definition
(a b : UInt8) : UInt8
/--
Bitwise and for 8-bit unsigned integers. Usually accessed via the `&&&` operator.
Each bit of the resulting integer is set if the corresponding bits of both input integers are set.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint8_land"]
protected def UInt8.land (a b : UInt8) : UInt8 := ⟨a.toBitVec &&& b.toBitVec⟩
UInt8.lor
definition
(a b : UInt8) : UInt8
/--
Bitwise or for 8-bit unsigned integers. Usually accessed via the `|||` operator.
Each bit of the resulting integer is set if at least one of the corresponding bits of both input
integers are set.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint8_lor"]
protected def UInt8.lor (a b : UInt8) : UInt8 := ⟨a.toBitVec ||| b.toBitVec⟩
UInt8.xor
definition
(a b : UInt8) : UInt8
/--
Bitwise exclusive or for 8-bit unsigned integers. Usually accessed via the `^^^` operator.
Each bit of the resulting integer is set if exactly one of the corresponding bits of both input
integers are set.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint8_xor"]
protected def UInt8.xor (a b : UInt8) : UInt8 := ⟨a.toBitVec ^^^ b.toBitVec⟩
UInt8.shiftLeft
definition
(a b : UInt8) : UInt8
/--
Bitwise left shift for 8-bit unsigned integers. Usually accessed via the `<<<` operator.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint8_shift_left"]
protected def UInt8.shiftLeft (a b : UInt8) : UInt8 := ⟨a.toBitVec <<< (UInt8.mod b 8).toBitVec⟩
UInt8.shiftRight
definition
(a b : UInt8) : UInt8
/--
Bitwise right shift for 8-bit unsigned integers. Usually accessed via the `>>>` operator.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint8_shift_right"]
protected def UInt8.shiftRight (a b : UInt8) : UInt8 := ⟨a.toBitVec >>> (UInt8.mod b 8).toBitVec⟩
UInt8.lt
definition
(a b : UInt8) : Prop
UInt8.le
definition
(a b : UInt8) : Prop
instAddUInt8
instance
: Add UInt8
instance : Add UInt8 := ⟨UInt8.add⟩
instSubUInt8
instance
: Sub UInt8
instance : Sub UInt8 := ⟨UInt8.sub⟩
instMulUInt8
instance
: Mul UInt8
instance : Mul UInt8 := ⟨UInt8.mul⟩
instModUInt8
instance
: Mod UInt8
instance : Mod UInt8 := ⟨UInt8.mod⟩
instHModUInt8Nat
instance
: HMod UInt8 Nat UInt8
instDivUInt8
instance
: Div UInt8
instance : Div UInt8 := ⟨UInt8.div⟩
instLTUInt8
instance
: LT UInt8
instance : LT UInt8 := ⟨UInt8.lt⟩
instLEUInt8
instance
: LE UInt8
instance : LE UInt8 := ⟨UInt8.le⟩
UInt8.complement
definition
(a : UInt8) : UInt8
/--
Bitwise complement, also known as bitwise negation, for 8-bit unsigned integers. Usually accessed
via the `~~~` prefix operator.
Each bit of the resulting integer is the opposite of the corresponding bit of the input integer.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint8_complement"]
protected def UInt8.complement (a : UInt8) : UInt8 := ⟨~~~a.toBitVec⟩
UInt8.neg
definition
(a : UInt8) : UInt8
/--
Negation of 8-bit unsigned integers, computed modulo `UInt8.size`.
`UInt8.neg a` is equivalent to `255 - a + 1`.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint8_neg"]
protected def UInt8.neg (a : UInt8) : UInt8 := ⟨-a.toBitVec⟩
instComplementUInt8
instance
: Complement UInt8
instance : Complement UInt8 := ⟨UInt8.complement⟩
instNegUInt8
instance
: Neg UInt8
instance : Neg UInt8 := ⟨UInt8.neg⟩
instAndOpUInt8
instance
: AndOp UInt8
instance : AndOp UInt8 := ⟨UInt8.land⟩
instOrOpUInt8
instance
: OrOp UInt8
instance : OrOp UInt8 := ⟨UInt8.lor⟩
instXorUInt8
instance
: Xor UInt8
instance : Xor UInt8 := ⟨UInt8.xor⟩
instShiftLeftUInt8
instance
: ShiftLeft UInt8
instance : ShiftLeft UInt8 := ⟨UInt8.shiftLeft⟩
instShiftRightUInt8
instance
: ShiftRight UInt8
instance : ShiftRight UInt8 := ⟨UInt8.shiftRight⟩
Bool.toUInt8
definition
(b : Bool) : UInt8
/--
Converts `true` to `1` and `false` to `0`.
-/
@[extern "lean_bool_to_uint8"]
def Bool.toUInt8 (b : Bool) : UInt8 := if b then 1 else 0
UInt8.decLt
definition
(a b : UInt8) : Decidable (a < b)
/--
Decides whether one 8-bit unsigned integer is strictly less than another. Usually accessed via the
`DecidableLT UInt8` instance.
This function is overridden at runtime with an efficient implementation.
Examples:
* `(if (6 : UInt8) < 7 then "yes" else "no") = "yes"`
* `(if (5 : UInt8) < 5 then "yes" else "no") = "no"`
* `show ¬((7 : UInt8) < 7) by decide`
-/
@[extern "lean_uint8_dec_lt"]
def UInt8.decLt (a b : UInt8) : Decidable (a < b) :=
inferInstanceAs (Decidable (a.toBitVec < b.toBitVec))
UInt8.decLe
definition
(a b : UInt8) : Decidable (a ≤ b)
/--
Decides whether one 8-bit unsigned integer is less than or equal to another. Usually accessed via the
`DecidableLE UInt8` instance.
This function is overridden at runtime with an efficient implementation.
Examples:
* `(if (15 : UInt8) ≤ 15 then "yes" else "no") = "yes"`
* `(if (15 : UInt8) ≤ 5 then "yes" else "no") = "no"`
* `(if (5 : UInt8) ≤ 15 then "yes" else "no") = "yes"`
* `show (7 : UInt8) ≤ 7 by decide`
-/
@[extern "lean_uint8_dec_le"]
def UInt8.decLe (a b : UInt8) : Decidable (a ≤ b) :=
inferInstanceAs (Decidable (a.toBitVec ≤ b.toBitVec))
instDecidableLtUInt8
instance
(a b : UInt8) : Decidable (a < b)
instance (a b : UInt8) : Decidable (a < b) := UInt8.decLt a b
instDecidableLeUInt8
instance
(a b : UInt8) : Decidable (a ≤ b)
instance (a b : UInt8) : Decidable (a ≤ b) := UInt8.decLe a b
instMaxUInt8
instance
: Max UInt8
instMinUInt8
instance
: Min UInt8
UInt16.ofFin
definition
(a : Fin UInt16.size) : UInt16
/-- Converts a `Fin UInt16.size` into the corresponding `UInt16`. -/
@[inline] def UInt16.ofFin (a : Fin UInt16.size) : UInt16 := ⟨⟨a⟩⟩
UInt16.mk
definition
(bitVec : BitVec 16) : UInt16
@[deprecated UInt16.ofBitVec (since := "2025-02-12"), inherit_doc UInt16.ofBitVec]
def UInt16.mk (bitVec : BitVec 16) : UInt16 :=
UInt16.ofBitVec bitVec
UInt16.ofNatCore
definition
(n : Nat) (h : n < UInt16.size) : UInt16
@[inline, deprecated UInt16.ofNatLT (since := "2025-02-13"), inherit_doc UInt16.ofNatLT]
def UInt16.ofNatCore (n : Nat) (h : n < UInt16.size) : UInt16 :=
UInt16.ofNatLT n h
UInt16.add
definition
(a b : UInt16) : UInt16
/--
Adds two 16-bit unsigned integers, wrapping around on overflow. Usually accessed via the `+`
operator.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint16_add"]
protected def UInt16.add (a b : UInt16) : UInt16 := ⟨a.toBitVec + b.toBitVec⟩
UInt16.sub
definition
(a b : UInt16) : UInt16
/--
Subtracts one 16-bit unsigned integer from another, wrapping around on underflow. Usually accessed
via the `-` operator.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint16_sub"]
protected def UInt16.sub (a b : UInt16) : UInt16 := ⟨a.toBitVec - b.toBitVec⟩
UInt16.mul
definition
(a b : UInt16) : UInt16
/--
Multiplies two 16-bit unsigned integers, wrapping around on overflow. Usually accessed via the `*`
operator.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint16_mul"]
protected def UInt16.mul (a b : UInt16) : UInt16 := ⟨a.toBitVec * b.toBitVec⟩
UInt16.div
definition
(a b : UInt16) : UInt16
/--
Unsigned division for 16-bit unsigned integers, discarding the remainder. Usually accessed
via the `/` operator.
This operation is sometimes called “floor division.” Division by zero is defined to be zero.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint16_div"]
protected def UInt16.div (a b : UInt16) : UInt16 := ⟨BitVec.udiv a.toBitVec b.toBitVec⟩
UInt16.mod
definition
(a b : UInt16) : UInt16
/--
The modulo operator for 16-bit unsigned integers, which computes the remainder when dividing one
integer by another. Usually accessed via the `%` operator.
When the divisor is `0`, the result is the dividend rather than an error.
This function is overridden at runtime with an efficient implementation.
Examples:
* `UInt16.mod 5 2 = 1`
* `UInt16.mod 4 2 = 0`
* `UInt16.mod 4 0 = 4`
-/
@[extern "lean_uint16_mod"]
protected def UInt16.mod (a b : UInt16) : UInt16 := ⟨BitVec.umod a.toBitVec b.toBitVec⟩
UInt16.modn
definition
(a : UInt16) (n : Nat) : UInt16
@[deprecated UInt16.mod (since := "2024-09-23")]
protected def UInt16.modn (a : UInt16) (n : Nat) : UInt16 := ⟨Fin.modn a.toFin n⟩
UInt16.land
definition
(a b : UInt16) : UInt16
/--
Bitwise and for 16-bit unsigned integers. Usually accessed via the `&&&` operator.
Each bit of the resulting integer is set if the corresponding bits of both input integers are set.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint16_land"]
protected def UInt16.land (a b : UInt16) : UInt16 := ⟨a.toBitVec &&& b.toBitVec⟩
UInt16.lor
definition
(a b : UInt16) : UInt16
/--
Bitwise or for 16-bit unsigned integers. Usually accessed via the `|||` operator.
Each bit of the resulting integer is set if at least one of the corresponding bits of both input
integers are set.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint16_lor"]
protected def UInt16.lor (a b : UInt16) : UInt16 := ⟨a.toBitVec ||| b.toBitVec⟩
UInt16.xor
definition
(a b : UInt16) : UInt16
/--
Bitwise exclusive or for 8-bit unsigned integers. Usually accessed via the `^^^` operator.
Each bit of the resulting integer is set if exactly one of the corresponding bits of both input
integers are set.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint16_xor"]
protected def UInt16.xor (a b : UInt16) : UInt16 := ⟨a.toBitVec ^^^ b.toBitVec⟩
UInt16.shiftLeft
definition
(a b : UInt16) : UInt16
/--
Bitwise left shift for 16-bit unsigned integers. Usually accessed via the `<<<` operator.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint16_shift_left"]
protected def UInt16.shiftLeft (a b : UInt16) : UInt16 := ⟨a.toBitVec <<< (UInt16.mod b 16).toBitVec⟩
UInt16.shiftRight
definition
(a b : UInt16) : UInt16
/--
Bitwise right shift for 16-bit unsigned integers. Usually accessed via the `>>>` operator.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint16_shift_right"]
protected def UInt16.shiftRight (a b : UInt16) : UInt16 := ⟨a.toBitVec >>> (UInt16.mod b 16).toBitVec⟩
UInt16.lt
definition
(a b : UInt16) : Prop
UInt16.le
definition
(a b : UInt16) : Prop
instAddUInt16
instance
: Add UInt16
instance : Add UInt16 := ⟨UInt16.add⟩
instSubUInt16
instance
: Sub UInt16
instance : Sub UInt16 := ⟨UInt16.sub⟩
instMulUInt16
instance
: Mul UInt16
instance : Mul UInt16 := ⟨UInt16.mul⟩
instModUInt16
instance
: Mod UInt16
instance : Mod UInt16 := ⟨UInt16.mod⟩
instHModUInt16Nat
instance
: HMod UInt16 Nat UInt16
instDivUInt16
instance
: Div UInt16
instance : Div UInt16 := ⟨UInt16.div⟩
instLTUInt16
instance
: LT UInt16
instance : LT UInt16 := ⟨UInt16.lt⟩
instLEUInt16
instance
: LE UInt16
instance : LE UInt16 := ⟨UInt16.le⟩
UInt16.complement
definition
(a : UInt16) : UInt16
/--
Bitwise complement, also known as bitwise negation, for 16-bit unsigned integers. Usually accessed
via the `~~~` prefix operator.
Each bit of the resulting integer is the opposite of the corresponding bit of the input integer.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint16_complement"]
protected def UInt16.complement (a : UInt16) : UInt16 := ⟨~~~a.toBitVec⟩
UInt16.neg
definition
(a : UInt16) : UInt16
/--
Negation of 16-bit unsigned integers, computed modulo `UInt16.size`.
`UInt16.neg a` is equivalent to `65_535 - a + 1`.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint16_neg"]
protected def UInt16.neg (a : UInt16) : UInt16 := ⟨-a.toBitVec⟩
instComplementUInt16
instance
: Complement UInt16
instance : Complement UInt16 := ⟨UInt16.complement⟩
instNegUInt16
instance
: Neg UInt16
instance : Neg UInt16 := ⟨UInt16.neg⟩
instAndOpUInt16
instance
: AndOp UInt16
instance : AndOp UInt16 := ⟨UInt16.land⟩
instOrOpUInt16
instance
: OrOp UInt16
instance : OrOp UInt16 := ⟨UInt16.lor⟩
instXorUInt16
instance
: Xor UInt16
instance : Xor UInt16 := ⟨UInt16.xor⟩
instShiftLeftUInt16
instance
: ShiftLeft UInt16
instance : ShiftLeft UInt16 := ⟨UInt16.shiftLeft⟩
instShiftRightUInt16
instance
: ShiftRight UInt16
instance : ShiftRight UInt16 := ⟨UInt16.shiftRight⟩
Bool.toUInt16
definition
(b : Bool) : UInt16
/--
Converts `true` to `1` and `false` to `0`.
-/
@[extern "lean_bool_to_uint16"]
def Bool.toUInt16 (b : Bool) : UInt16 := if b then 1 else 0
UInt16.decLt
definition
(a b : UInt16) : Decidable (a < b)
/--
Decides whether one 16-bit unsigned integer is strictly less than another. Usually accessed via the
`DecidableLT UInt16` instance.
This function is overridden at runtime with an efficient implementation.
Examples:
* `(if (6 : UInt16) < 7 then "yes" else "no") = "yes"`
* `(if (5 : UInt16) < 5 then "yes" else "no") = "no"`
* `show ¬((7 : UInt16) < 7) by decide`
-/
@[extern "lean_uint16_dec_lt"]
def UInt16.decLt (a b : UInt16) : Decidable (a < b) :=
inferInstanceAs (Decidable (a.toBitVec < b.toBitVec))
UInt16.decLe
definition
(a b : UInt16) : Decidable (a ≤ b)
/--
Decides whether one 16-bit unsigned integer is less than or equal to another. Usually accessed via the
`DecidableLE UInt16` instance.
This function is overridden at runtime with an efficient implementation.
Examples:
* `(if (15 : UInt16) ≤ 15 then "yes" else "no") = "yes"`
* `(if (15 : UInt16) ≤ 5 then "yes" else "no") = "no"`
* `(if (5 : UInt16) ≤ 15 then "yes" else "no") = "yes"`
* `show (7 : UInt16) ≤ 7 by decide`
-/
@[extern "lean_uint16_dec_le"]
def UInt16.decLe (a b : UInt16) : Decidable (a ≤ b) :=
inferInstanceAs (Decidable (a.toBitVec ≤ b.toBitVec))
instDecidableLtUInt16
instance
(a b : UInt16) : Decidable (a < b)
instance (a b : UInt16) : Decidable (a < b) := UInt16.decLt a b
instDecidableLeUInt16
instance
(a b : UInt16) : Decidable (a ≤ b)
instance (a b : UInt16) : Decidable (a ≤ b) := UInt16.decLe a b
instMaxUInt16
instance
: Max UInt16
instMinUInt16
instance
: Min UInt16
UInt32.ofFin
definition
(a : Fin UInt32.size) : UInt32
/-- Converts a `Fin UInt32.size` into the corresponding `UInt32`. -/
@[inline] def UInt32.ofFin (a : Fin UInt32.size) : UInt32 := ⟨⟨a⟩⟩
UInt32.mk
definition
(bitVec : BitVec 32) : UInt32
@[deprecated UInt32.ofBitVec (since := "2025-02-12"), inherit_doc UInt32.ofBitVec]
def UInt32.mk (bitVec : BitVec 32) : UInt32 :=
UInt32.ofBitVec bitVec
UInt32.ofNatCore
definition
(n : Nat) (h : n < UInt32.size) : UInt32
@[inline, deprecated UInt32.ofNatLT (since := "2025-02-13"), inherit_doc UInt32.ofNatLT]
def UInt32.ofNatCore (n : Nat) (h : n < UInt32.size) : UInt32 :=
UInt32.ofNatLT n h
UInt32.add
definition
(a b : UInt32) : UInt32
/--
Adds two 32-bit unsigned integers, wrapping around on overflow. Usually accessed via the `+`
operator.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint32_add"]
protected def UInt32.add (a b : UInt32) : UInt32 := ⟨a.toBitVec + b.toBitVec⟩
UInt32.sub
definition
(a b : UInt32) : UInt32
/--
Subtracts one 32-bit unsigned integer from another, wrapping around on underflow. Usually accessed
via the `-` operator.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint32_sub"]
protected def UInt32.sub (a b : UInt32) : UInt32 := ⟨a.toBitVec - b.toBitVec⟩
UInt32.mul
definition
(a b : UInt32) : UInt32
/--
Multiplies two 32-bit unsigned integers, wrapping around on overflow. Usually accessed via the `*`
operator.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint32_mul"]
protected def UInt32.mul (a b : UInt32) : UInt32 := ⟨a.toBitVec * b.toBitVec⟩
UInt32.div
definition
(a b : UInt32) : UInt32
/--
Unsigned division for 32-bit unsigned integers, discarding the remainder. Usually accessed
via the `/` operator.
This operation is sometimes called “floor division.” Division by zero is defined to be zero.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint32_div"]
protected def UInt32.div (a b : UInt32) : UInt32 := ⟨BitVec.udiv a.toBitVec b.toBitVec⟩
UInt32.mod
definition
(a b : UInt32) : UInt32
/--
The modulo operator for 32-bit unsigned integers, which computes the remainder when dividing one
integer by another. Usually accessed via the `%` operator.
When the divisor is `0`, the result is the dividend rather than an error.
This function is overridden at runtime with an efficient implementation.
Examples:
* `UInt32.mod 5 2 = 1`
* `UInt32.mod 4 2 = 0`
* `UInt32.mod 4 0 = 4`
-/
@[extern "lean_uint32_mod"]
protected def UInt32.mod (a b : UInt32) : UInt32 := ⟨BitVec.umod a.toBitVec b.toBitVec⟩
UInt32.modn
definition
(a : UInt32) (n : Nat) : UInt32
@[deprecated UInt32.mod (since := "2024-09-23")]
protected def UInt32.modn (a : UInt32) (n : Nat) : UInt32 := ⟨Fin.modn a.toFin n⟩
UInt32.land
definition
(a b : UInt32) : UInt32
/--
Bitwise and for 32-bit unsigned integers. Usually accessed via the `&&&` operator.
Each bit of the resulting integer is set if the corresponding bits of both input integers are set.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint32_land"]
protected def UInt32.land (a b : UInt32) : UInt32 := ⟨a.toBitVec &&& b.toBitVec⟩
UInt32.lor
definition
(a b : UInt32) : UInt32
/--
Bitwise or for 32-bit unsigned integers. Usually accessed via the `|||` operator.
Each bit of the resulting integer is set if at least one of the corresponding bits of both input
integers are set.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint32_lor"]
protected def UInt32.lor (a b : UInt32) : UInt32 := ⟨a.toBitVec ||| b.toBitVec⟩
UInt32.xor
definition
(a b : UInt32) : UInt32
/--
Bitwise exclusive or for 32-bit unsigned integers. Usually accessed via the `^^^` operator.
Each bit of the resulting integer is set if exactly one of the corresponding bits of both input
integers are set.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint32_xor"]
protected def UInt32.xor (a b : UInt32) : UInt32 := ⟨a.toBitVec ^^^ b.toBitVec⟩
UInt32.shiftLeft
definition
(a b : UInt32) : UInt32
/--
Bitwise left shift for 32-bit unsigned integers. Usually accessed via the `<<<` operator.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint32_shift_left"]
protected def UInt32.shiftLeft (a b : UInt32) : UInt32 := ⟨a.toBitVec <<< (UInt32.mod b 32).toBitVec⟩
UInt32.shiftRight
definition
(a b : UInt32) : UInt32
/--
Bitwise right shift for 32-bit unsigned integers. Usually accessed via the `>>>` operator.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint32_shift_right"]
protected def UInt32.shiftRight (a b : UInt32) : UInt32 := ⟨a.toBitVec >>> (UInt32.mod b 32).toBitVec⟩
UInt32.lt
definition
(a b : UInt32) : Prop
UInt32.le
definition
(a b : UInt32) : Prop
instAddUInt32
instance
: Add UInt32
instance : Add UInt32 := ⟨UInt32.add⟩
instSubUInt32
instance
: Sub UInt32
instance : Sub UInt32 := ⟨UInt32.sub⟩
instMulUInt32
instance
: Mul UInt32
instance : Mul UInt32 := ⟨UInt32.mul⟩
instModUInt32
instance
: Mod UInt32
instance : Mod UInt32 := ⟨UInt32.mod⟩
instHModUInt32Nat
instance
: HMod UInt32 Nat UInt32
instDivUInt32
instance
: Div UInt32
instance : Div UInt32 := ⟨UInt32.div⟩
instLTUInt32_1
instance
: LT UInt32
instance : LT UInt32 := ⟨UInt32.lt⟩
instLEUInt32_1
instance
: LE UInt32
instance : LE UInt32 := ⟨UInt32.le⟩
UInt32.complement
definition
(a : UInt32) : UInt32
/--
Bitwise complement, also known as bitwise negation, for 32-bit unsigned integers. Usually accessed
via the `~~~` prefix operator.
Each bit of the resulting integer is the opposite of the corresponding bit of the input integer.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint32_complement"]
protected def UInt32.complement (a : UInt32) : UInt32 := ⟨~~~a.toBitVec⟩
UInt32.neg
definition
(a : UInt32) : UInt32
/--
Negation of 32-bit unsigned integers, computed modulo `UInt32.size`.
`UInt32.neg a` is equivalent to `429_4967_295 - a + 1`.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint32_neg"]
protected def UInt32.neg (a : UInt32) : UInt32 := ⟨-a.toBitVec⟩
instComplementUInt32
instance
: Complement UInt32
instance : Complement UInt32 := ⟨UInt32.complement⟩
instNegUInt32
instance
: Neg UInt32
instance : Neg UInt32 := ⟨UInt32.neg⟩
instAndOpUInt32
instance
: AndOp UInt32
instance : AndOp UInt32 := ⟨UInt32.land⟩
instOrOpUInt32
instance
: OrOp UInt32
instance : OrOp UInt32 := ⟨UInt32.lor⟩
instXorUInt32
instance
: Xor UInt32
instance : Xor UInt32 := ⟨UInt32.xor⟩
instShiftLeftUInt32
instance
: ShiftLeft UInt32
instance : ShiftLeft UInt32 := ⟨UInt32.shiftLeft⟩
instShiftRightUInt32
instance
: ShiftRight UInt32
instance : ShiftRight UInt32 := ⟨UInt32.shiftRight⟩
Bool.toUInt32
definition
(b : Bool) : UInt32
/--
Converts `true` to `1` and `false` to `0`.
-/
@[extern "lean_bool_to_uint32"]
def Bool.toUInt32 (b : Bool) : UInt32 := if b then 1 else 0
UInt64.ofFin
definition
(a : Fin UInt64.size) : UInt64
/-- Converts a `Fin UInt64.size` into the corresponding `UInt64`. -/
@[inline] def UInt64.ofFin (a : Fin UInt64.size) : UInt64 := ⟨⟨a⟩⟩
UInt64.mk
definition
(bitVec : BitVec 64) : UInt64
@[deprecated UInt64.ofBitVec (since := "2025-02-12"), inherit_doc UInt64.ofBitVec]
def UInt64.mk (bitVec : BitVec 64) : UInt64 :=
UInt64.ofBitVec bitVec
UInt64.ofNatCore
definition
(n : Nat) (h : n < UInt64.size) : UInt64
@[inline, deprecated UInt64.ofNatLT (since := "2025-02-13"), inherit_doc UInt64.ofNatLT]
def UInt64.ofNatCore (n : Nat) (h : n < UInt64.size) : UInt64 :=
UInt64.ofNatLT n h
UInt64.add
definition
(a b : UInt64) : UInt64
/--
Adds two 64-bit unsigned integers, wrapping around on overflow. Usually accessed via the `+`
operator.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint64_add"]
protected def UInt64.add (a b : UInt64) : UInt64 := ⟨a.toBitVec + b.toBitVec⟩
UInt64.sub
definition
(a b : UInt64) : UInt64
/--
Subtracts one 64-bit unsigned integer from another, wrapping around on underflow. Usually accessed
via the `-` operator.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint64_sub"]
protected def UInt64.sub (a b : UInt64) : UInt64 := ⟨a.toBitVec - b.toBitVec⟩
UInt64.mul
definition
(a b : UInt64) : UInt64
/--
Multiplies two 64-bit unsigned integers, wrapping around on overflow. Usually accessed via the `*`
operator.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint64_mul"]
protected def UInt64.mul (a b : UInt64) : UInt64 := ⟨a.toBitVec * b.toBitVec⟩
UInt64.div
definition
(a b : UInt64) : UInt64
/--
Unsigned division for 64-bit unsigned integers, discarding the remainder. Usually accessed
via the `/` operator.
This operation is sometimes called “floor division.” Division by zero is defined to be zero.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint64_div"]
protected def UInt64.div (a b : UInt64) : UInt64 := ⟨BitVec.udiv a.toBitVec b.toBitVec⟩
UInt64.mod
definition
(a b : UInt64) : UInt64
/--
The modulo operator for 64-bit unsigned integers, which computes the remainder when dividing one
integer by another. Usually accessed via the `%` operator.
When the divisor is `0`, the result is the dividend rather than an error.
This function is overridden at runtime with an efficient implementation.
Examples:
* `UInt64.mod 5 2 = 1`
* `UInt64.mod 4 2 = 0`
* `UInt64.mod 4 0 = 4`
-/
@[extern "lean_uint64_mod"]
protected def UInt64.mod (a b : UInt64) : UInt64 := ⟨BitVec.umod a.toBitVec b.toBitVec⟩
UInt64.modn
definition
(a : UInt64) (n : Nat) : UInt64
@[deprecated UInt64.mod (since := "2024-09-23")]
protected def UInt64.modn (a : UInt64) (n : Nat) : UInt64 := ⟨Fin.modn a.toFin n⟩
UInt64.land
definition
(a b : UInt64) : UInt64
/--
Bitwise and for 64-bit unsigned integers. Usually accessed via the `&&&` operator.
Each bit of the resulting integer is set if the corresponding bits of both input integers are set.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint64_land"]
protected def UInt64.land (a b : UInt64) : UInt64 := ⟨a.toBitVec &&& b.toBitVec⟩
UInt64.lor
definition
(a b : UInt64) : UInt64
/--
Bitwise or for 64-bit unsigned integers. Usually accessed via the `|||` operator.
Each bit of the resulting integer is set if at least one of the corresponding bits of both input
integers are set.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint64_lor"]
protected def UInt64.lor (a b : UInt64) : UInt64 := ⟨a.toBitVec ||| b.toBitVec⟩
UInt64.xor
definition
(a b : UInt64) : UInt64
/--
Bitwise exclusive or for 64-bit unsigned integers. Usually accessed via the `^^^` operator.
Each bit of the resulting integer is set if exactly one of the corresponding bits of both input
integers are set.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint64_xor"]
protected def UInt64.xor (a b : UInt64) : UInt64 := ⟨a.toBitVec ^^^ b.toBitVec⟩
UInt64.shiftLeft
definition
(a b : UInt64) : UInt64
/--
Bitwise left shift for 64-bit unsigned integers. Usually accessed via the `<<<` operator.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint64_shift_left"]
protected def UInt64.shiftLeft (a b : UInt64) : UInt64 := ⟨a.toBitVec <<< (UInt64.mod b 64).toBitVec⟩
UInt64.shiftRight
definition
(a b : UInt64) : UInt64
/--
Bitwise right shift for 64-bit unsigned integers. Usually accessed via the `>>>` operator.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint64_shift_right"]
protected def UInt64.shiftRight (a b : UInt64) : UInt64 := ⟨a.toBitVec >>> (UInt64.mod b 64).toBitVec⟩
UInt64.lt
definition
(a b : UInt64) : Prop
UInt64.le
definition
(a b : UInt64) : Prop
instAddUInt64
instance
: Add UInt64
instance : Add UInt64 := ⟨UInt64.add⟩
instSubUInt64
instance
: Sub UInt64
instance : Sub UInt64 := ⟨UInt64.sub⟩
instMulUInt64
instance
: Mul UInt64
instance : Mul UInt64 := ⟨UInt64.mul⟩
instModUInt64
instance
: Mod UInt64
instance : Mod UInt64 := ⟨UInt64.mod⟩
instHModUInt64Nat
instance
: HMod UInt64 Nat UInt64
instDivUInt64
instance
: Div UInt64
instance : Div UInt64 := ⟨UInt64.div⟩
instLTUInt64
instance
: LT UInt64
instance : LT UInt64 := ⟨UInt64.lt⟩
instLEUInt64
instance
: LE UInt64
instance : LE UInt64 := ⟨UInt64.le⟩
UInt64.complement
definition
(a : UInt64) : UInt64
/--
Bitwise complement, also known as bitwise negation, for 64-bit unsigned integers. Usually accessed
via the `~~~` prefix operator.
Each bit of the resulting integer is the opposite of the corresponding bit of the input integer.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint64_complement"]
protected def UInt64.complement (a : UInt64) : UInt64 := ⟨~~~a.toBitVec⟩
UInt64.neg
definition
(a : UInt64) : UInt64
/--
Negation of 32-bit unsigned integers, computed modulo `UInt64.size`.
`UInt64.neg a` is equivalent to `18_446_744_073_709_551_615 - a + 1`.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint64_neg"]
protected def UInt64.neg (a : UInt64) : UInt64 := ⟨-a.toBitVec⟩
instComplementUInt64
instance
: Complement UInt64
instance : Complement UInt64 := ⟨UInt64.complement⟩
instNegUInt64
instance
: Neg UInt64
instance : Neg UInt64 := ⟨UInt64.neg⟩
instAndOpUInt64
instance
: AndOp UInt64
instance : AndOp UInt64 := ⟨UInt64.land⟩
instOrOpUInt64
instance
: OrOp UInt64
instance : OrOp UInt64 := ⟨UInt64.lor⟩
instXorUInt64
instance
: Xor UInt64
instance : Xor UInt64 := ⟨UInt64.xor⟩
instShiftLeftUInt64
instance
: ShiftLeft UInt64
instance : ShiftLeft UInt64 := ⟨UInt64.shiftLeft⟩
instShiftRightUInt64
instance
: ShiftRight UInt64
instance : ShiftRight UInt64 := ⟨UInt64.shiftRight⟩
Bool.toUInt64
definition
(b : Bool) : UInt64
/--
Converts `true` to `1` and `false` to `0`.
-/
@[extern "lean_bool_to_uint64"]
def Bool.toUInt64 (b : Bool) : UInt64 := if b then 1 else 0
UInt64.decLt
definition
(a b : UInt64) : Decidable (a < b)
/--
Decides whether one 64-bit unsigned integer is strictly less than another. Usually accessed via the
`DecidableLT UInt64` instance.
This function is overridden at runtime with an efficient implementation.
Examples:
* `(if (6 : UInt64) < 7 then "yes" else "no") = "yes"`
* `(if (5 : UInt64) < 5 then "yes" else "no") = "no"`
* `show ¬((7 : UInt64) < 7) by decide`
-/
@[extern "lean_uint64_dec_lt"]
def UInt64.decLt (a b : UInt64) : Decidable (a < b) :=
inferInstanceAs (Decidable (a.toBitVec < b.toBitVec))
UInt64.decLe
definition
(a b : UInt64) : Decidable (a ≤ b)
/--
Decides whether one 64-bit unsigned integer is less than or equal to another. Usually accessed via the
`DecidableLE UInt64` instance.
This function is overridden at runtime with an efficient implementation.
Examples:
* `(if (15 : UInt64) ≤ 15 then "yes" else "no") = "yes"`
* `(if (15 : UInt64) ≤ 5 then "yes" else "no") = "no"`
* `(if (5 : UInt64) ≤ 15 then "yes" else "no") = "yes"`
* `show (7 : UInt64) ≤ 7 by decide`
-/
@[extern "lean_uint64_dec_le"]
def UInt64.decLe (a b : UInt64) : Decidable (a ≤ b) :=
inferInstanceAs (Decidable (a.toBitVec ≤ b.toBitVec))
instDecidableLtUInt64
instance
(a b : UInt64) : Decidable (a < b)
instance (a b : UInt64) : Decidable (a < b) := UInt64.decLt a b
instDecidableLeUInt64
instance
(a b : UInt64) : Decidable (a ≤ b)
instance (a b : UInt64) : Decidable (a ≤ b) := UInt64.decLe a b
instMaxUInt64
instance
: Max UInt64
instMinUInt64
instance
: Min UInt64
USize.ofFin
definition
(a : Fin USize.size) : USize
/-- Converts a `Fin USize.size` into the corresponding `USize`. -/
@[inline] def USize.ofFin (a : Fin USize.size) : USize := ⟨⟨a⟩⟩
USize.mk
definition
(bitVec : BitVec System.Platform.numBits) : USize
@[deprecated USize.ofBitVec (since := "2025-02-12"), inherit_doc USize.ofBitVec]
def USize.mk (bitVec : BitVec System.Platform.numBits) : USize :=
USize.ofBitVec bitVec
USize.ofNatCore
definition
(n : Nat) (h : n < USize.size) : USize
@[inline, deprecated USize.ofNatLT (since := "2025-02-13"), inherit_doc USize.ofNatLT]
def USize.ofNatCore (n : Nat) (h : n < USize.size) : USize :=
USize.ofNatLT n h
USize.le_size
theorem
: 2 ^ 32 ≤ USize.size
@[simp] theorem USize.le_size : 2 ^ 32 ≤ USize.size := by cases USize.size_eq <;> simp_all
USize.size_le
theorem
: USize.size ≤ 2 ^ 64
@[simp] theorem USize.size_le : USize.size ≤ 2 ^ 64 := by cases USize.size_eq <;> simp_all
usize_size_le
theorem
: USize.size ≤ 18446744073709551616
@[deprecated USize.size_le (since := "2025-02-24")]
theorem usize_size_le : USize.size ≤ 18446744073709551616 :=
USize.size_le
le_usize_size
theorem
: 4294967296 ≤ USize.size
@[deprecated USize.le_size (since := "2025-02-24")]
theorem le_usize_size : 4294967296 ≤ USize.size :=
USize.le_size
USize.mul
definition
(a b : USize) : USize
/--
Multiplies two word-sized unsigned integers, wrapping around on overflow. Usually accessed via the
`*` operator.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_usize_mul"]
protected def USize.mul (a b : USize) : USize := ⟨a.toBitVec * b.toBitVec⟩
USize.div
definition
(a b : USize) : USize
/--
Unsigned division for word-sized unsigned integers, discarding the remainder. Usually accessed
via the `/` operator.
This operation is sometimes called “floor division.” Division by zero is defined to be zero.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_usize_div"]
protected def USize.div (a b : USize) : USize := ⟨a.toBitVec / b.toBitVec⟩
USize.mod
definition
(a b : USize) : USize
/--
The modulo operator for word-sized unsigned integers, which computes the remainder when dividing one
integer by another. Usually accessed via the `%` operator.
When the divisor is `0`, the result is the dividend rather than an error.
This function is overridden at runtime with an efficient implementation.
Examples:
* `USize.mod 5 2 = 1`
* `USize.mod 4 2 = 0`
* `USize.mod 4 0 = 4`
-/
@[extern "lean_usize_mod"]
protected def USize.mod (a b : USize) : USize := ⟨a.toBitVec % b.toBitVec⟩
USize.modn
definition
(a : USize) (n : Nat) : USize
@[deprecated USize.mod (since := "2024-09-23")]
protected def USize.modn (a : USize) (n : Nat) : USize := ⟨Fin.modn a.toFin n⟩
USize.land
definition
(a b : USize) : USize
/--
Bitwise and for word-sized unsigned integers. Usually accessed via the `&&&` operator.
Each bit of the resulting integer is set if the corresponding bits of both input integers are set.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_usize_land"]
protected def USize.land (a b : USize) : USize := ⟨a.toBitVec &&& b.toBitVec⟩
USize.lor
definition
(a b : USize) : USize
/--
Bitwise or for word-sized unsigned integers. Usually accessed via the `|||` operator.
Each bit of the resulting integer is set if at least one of the corresponding bits of both input
integers are set.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_usize_lor"]
protected def USize.lor (a b : USize) : USize := ⟨a.toBitVec ||| b.toBitVec⟩
USize.xor
definition
(a b : USize) : USize
/--
Bitwise exclusive or for word-sized unsigned integers. Usually accessed via the `^^^` operator.
Each bit of the resulting integer is set if exactly one of the corresponding bits of both input
integers are set.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_usize_xor"]
protected def USize.xor (a b : USize) : USize := ⟨a.toBitVec ^^^ b.toBitVec⟩
USize.shiftLeft
definition
(a b : USize) : USize
/--
Bitwise left shift for word-sized unsigned integers. Usually accessed via the `<<<` operator.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_usize_shift_left"]
protected def USize.shiftLeft (a b : USize) : USize := ⟨a.toBitVec <<< (USize.mod b (USize.ofNat System.Platform.numBits)).toBitVec⟩
USize.shiftRight
definition
(a b : USize) : USize
/--
Bitwise right shift for word-sized unsigned integers. Usually accessed via the `>>>` operator.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_usize_shift_right"]
protected def USize.shiftRight (a b : USize) : USize := ⟨a.toBitVec >>> (USize.mod b (USize.ofNat System.Platform.numBits)).toBitVec⟩
USize.ofNat32
definition
(n : @& Nat) (h : n < 4294967296) : USize
/--
Converts a natural number to a `USize`. Overflow is impossible on any supported platform because
`USize.size` is either `2^32` or `2^64`.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_usize_of_nat"]
def USize.ofNat32 (n : @& Nat) (h : n < 4294967296) : USize :=
USize.ofNatLT n (Nat.lt_of_lt_of_le h USize.le_size)
UInt8.toUSize
definition
(a : UInt8) : USize
/--
Converts 8-bit unsigned integers to word-sized unsigned integers.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint8_to_usize"]
def UInt8.toUSize (a : UInt8) : USize :=
USize.ofNat32 a.toBitVec.toNat (Nat.lt_trans a.toBitVec.isLt (by decide))
USize.toUInt8
definition
(a : USize) : UInt8
/--
Converts word-sized unsigned integers to 8-bit unsigned integers. Wraps around on overflow.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_usize_to_uint8"]
def USize.toUInt8 (a : USize) : UInt8 := a.toNat.toUInt8
UInt16.toUSize
definition
(a : UInt16) : USize
/--
Converts 16-bit unsigned integers to word-sized unsigned integers.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint16_to_usize"]
def UInt16.toUSize (a : UInt16) : USize :=
USize.ofNat32 a.toBitVec.toNat (Nat.lt_trans a.toBitVec.isLt (by decide))
USize.toUInt16
definition
(a : USize) : UInt16
/--
Converts word-sized unsigned integers to 16-bit unsigned integers. Wraps around on overflow.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_usize_to_uint16"]
def USize.toUInt16 (a : USize) : UInt16 := a.toNat.toUInt16
UInt32.toUSize
definition
(a : UInt32) : USize
/--
Converts 32-bit unsigned integers to word-sized unsigned integers.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint32_to_usize"]
def UInt32.toUSize (a : UInt32) : USize := USize.ofNat32 a.toBitVec.toNat a.toBitVec.isLt
USize.toUInt32
definition
(a : USize) : UInt32
/--
Converts word-sized unsigned integers to 32-bit unsigned integers. Wraps around on overflow, which
might occur on 64-bit architectures.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_usize_to_uint32"]
def USize.toUInt32 (a : USize) : UInt32 := a.toNat.toUInt32
UInt64.toUSize
definition
(a : UInt64) : USize
/--
Converts 64-bit unsigned integers to word-sized unsigned integers. On 32-bit machines, this may
overflow, which results in the value wrapping around (that is, it is reduced modulo `USize.size`).
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_uint64_to_usize"]
def UInt64.toUSize (a : UInt64) : USize := a.toNat.toUSize
USize.toUInt64
definition
(a : USize) : UInt64
/--
Converts word-sized unsigned integers to 32-bit unsigned integers. This cannot overflow because
`USize.size` is either `2^32` or `2^64`.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_usize_to_uint64"]
def USize.toUInt64 (a : USize) : UInt64 :=
UInt64.ofNatLT a.toBitVec.toNat (Nat.lt_of_lt_of_le a.toBitVec.isLt USize.size_le)
instMulUSize
instance
: Mul USize
instance : Mul USize := ⟨USize.mul⟩
instModUSize
instance
: Mod USize
instance : Mod USize := ⟨USize.mod⟩
instHModUSizeNat
instance
: HMod USize Nat USize
instDivUSize
instance
: Div USize
instance : Div USize := ⟨USize.div⟩
USize.complement
definition
(a : USize) : USize
/--
Bitwise complement, also known as bitwise negation, for word-sized unsigned integers. Usually
accessed via the `~~~` prefix operator.
Each bit of the resulting integer is the opposite of the corresponding bit of the input integer.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_usize_complement"]
protected def USize.complement (a : USize) : USize := ⟨~~~a.toBitVec⟩
USize.neg
definition
(a : USize) : USize
/--
Negation of word-sized unsigned integers, computed modulo `USize.size`.
This function is overridden at runtime with an efficient implementation.
-/
@[extern "lean_usize_neg"]
protected def USize.neg (a : USize) : USize := ⟨-a.toBitVec⟩
instComplementUSize
instance
: Complement USize
instance : Complement USize := ⟨USize.complement⟩
instNegUSize
instance
: Neg USize
instance : Neg USize := ⟨USize.neg⟩
instAndOpUSize
instance
: AndOp USize
instance : AndOp USize := ⟨USize.land⟩
instOrOpUSize
instance
: OrOp USize
instance : OrOp USize := ⟨USize.lor⟩
instXorUSize
instance
: Xor USize
instance : Xor USize := ⟨USize.xor⟩
instShiftLeftUSize
instance
: ShiftLeft USize
instance : ShiftLeft USize := ⟨USize.shiftLeft⟩
instShiftRightUSize
instance
: ShiftRight USize
instance : ShiftRight USize := ⟨USize.shiftRight⟩
Bool.toUSize
definition
(b : Bool) : USize
/--
Converts `true` to `1` and `false` to `0`.
-/
@[extern "lean_bool_to_usize"]
def Bool.toUSize (b : Bool) : USize := if b then 1 else 0
instMaxUSize
instance
: Max USize
instMinUSize
instance
: Min USize