18.4.4.4. Comparisons🔗
The operators in this section are rarely invoked by name.
Typically, comparisons operations on fixed-width integers should use the decidability of the corresponding relations, which consist of the equality type Eq
and those implemented in instances of LE
and LT
.
🔗defUSize.le (a b : USize) : Prop
Non-strict inequality of word-sized unsigned integers, defined as inequality of the corresponding
natural numbers. Usually accessed via the ≤
operator.
🔗defISize.le (a b : ISize) : Prop
Non-strict inequality of word-sized signed integers, defined as inequality of the corresponding
integers. Usually accessed via the ≤
operator.
🔗defUInt8.le (a b : UInt8) : Prop
Non-strict inequality of 8-bit unsigned integers, defined as inequality of the corresponding
natural numbers. Usually accessed via the ≤
operator.
🔗defInt8.le (a b : Int8) : Prop
Non-strict inequality of 8-bit signed integers, defined as inequality of the corresponding integers.
Usually accessed via the ≤
operator.
🔗defUInt16.le (a b : UInt16) : Prop
Non-strict inequality of 16-bit unsigned integers, defined as inequality of the corresponding
natural numbers. Usually accessed via the ≤
operator.
🔗defInt16.le (a b : Int16) : Prop
Non-strict inequality of 16-bit signed integers, defined as inequality of the corresponding
integers. Usually accessed via the ≤
operator.
🔗defUInt32.le (a b : UInt32) : Prop
Non-strict inequality of 32-bit unsigned integers, defined as inequality of the corresponding
natural numbers. Usually accessed via the ≤
operator.
🔗defInt32.le (a b : Int32) : Prop
Non-strict inequality of 32-bit signed integers, defined as inequality of the corresponding integers.
Usually accessed via the ≤
operator.
🔗defUInt64.le (a b : UInt64) : Prop
Non-strict inequality of 64-bit unsigned integers, defined as inequality of the corresponding
natural numbers. Usually accessed via the ≤
operator.
🔗defInt64.le (a b : Int64) : Prop
Non-strict inequality of 64-bit signed integers, defined as inequality of the corresponding integers.
Usually accessed via the ≤
operator.
🔗defUSize.lt (a b : USize) : Prop
Strict inequality of word-sized unsigned integers, defined as inequality of the corresponding
natural numbers. Usually accessed via the <
operator.
🔗defISize.lt (a b : ISize) : Prop
Strict inequality of word-sized signed integers, defined as inequality of the corresponding
integers. Usually accessed via the <
operator.
🔗defUInt8.lt (a b : UInt8) : Prop
Strict inequality of 8-bit unsigned integers, defined as inequality of the corresponding
natural numbers. Usually accessed via the <
operator.
🔗defInt8.lt (a b : Int8) : Prop
Strict inequality of 8-bit signed integers, defined as inequality of the corresponding integers.
Usually accessed via the <
operator.
🔗defUInt16.lt (a b : UInt16) : Prop
Strict inequality of 16-bit unsigned integers, defined as inequality of the corresponding
natural numbers. Usually accessed via the <
operator.
🔗defInt16.lt (a b : Int16) : Prop
Strict inequality of 16-bit signed integers, defined as inequality of the corresponding integers.
Usually accessed via the <
operator.
🔗defUInt32.lt (a b : UInt32) : Prop
Strict inequality of 32-bit unsigned integers, defined as inequality of the corresponding
natural numbers. Usually accessed via the <
operator.
🔗defInt32.lt (a b : Int32) : Prop
Strict inequality of 32-bit signed integers, defined as inequality of the corresponding integers.
Usually accessed via the <
operator.
🔗defUInt64.lt (a b : UInt64) : Prop
Strict inequality of 64-bit unsigned integers, defined as inequality of the corresponding
natural numbers. Usually accessed via the <
operator.
🔗defInt64.lt (a b : Int64) : Prop
Strict inequality of 64-bit signed integers, defined as inequality of the corresponding integers.
Usually accessed via the <
operator.
🔗defUSize.decEq (a b : USize) : Decidable (a = b)
Decides whether two word-sized unsigned integers are equal. Usually accessed via the
DecidableEq USize
instance.
This function is overridden at runtime with an efficient implementation.
Examples:
🔗defISize.decEq (a b : ISize) : Decidable (a = b)
Decides whether two word-sized signed integers are equal. Usually accessed via the
DecidableEq ISize
instance.
This function is overridden at runtime with an efficient implementation.
Examples:
🔗defUInt8.decEq (a b : UInt8) : Decidable (a = b)
Decides whether two 8-bit unsigned integers are equal. Usually accessed via the DecidableEq UInt8
instance.
This function is overridden at runtime with an efficient implementation.
Examples:
🔗defInt8.decEq (a b : Int8) : Decidable (a = b)
Decides whether two 8-bit signed integers are equal. Usually accessed via the DecidableEq Int8
instance.
This function is overridden at runtime with an efficient implementation.
Examples:
🔗defUInt16.decEq (a b : UInt16) : Decidable (a = b)
Decides whether two 16-bit unsigned integers are equal. Usually accessed via the
DecidableEq UInt16
instance.
This function is overridden at runtime with an efficient implementation.
Examples:
🔗defInt16.decEq (a b : Int16) : Decidable (a = b)
Decides whether two 16-bit signed integers are equal. Usually accessed via the DecidableEq Int16
instance.
This function is overridden at runtime with an efficient implementation.
Examples:
🔗defUInt32.decEq (a b : UInt32) : Decidable (a = b)
Decides whether two 32-bit unsigned integers are equal. Usually accessed via the
DecidableEq UInt32
instance.
This function is overridden at runtime with an efficient implementation.
Examples:
🔗defInt32.decEq (a b : Int32) : Decidable (a = b)
Decides whether two 32-bit signed integers are equal. Usually accessed via the DecidableEq Int32
instance.
This function is overridden at runtime with an efficient implementation.
Examples:
🔗defUInt64.decEq (a b : UInt64) : Decidable (a = b)
Decides whether two 64-bit unsigned integers are equal. Usually accessed via the
DecidableEq UInt64
instance.
This function is overridden at runtime with an efficient implementation.
Examples:
🔗defInt64.decEq (a b : Int64) : Decidable (a = b)
Decides whether two 64-bit signed integers are equal. Usually accessed via the DecidableEq Int64
instance.
This function is overridden at runtime with an efficient implementation.
Examples:
🔗defUSize.decLe (a b : USize) : Decidable (a ≤ b)
Decides whether one word-sized unsigned integer is less than or equal to another. Usually accessed
via the DecidableLE USize
instance.
This function is overridden at runtime with an efficient implementation.
Examples:
🔗defISize.decLe (a b : ISize) : Decidable (a ≤ b)
Decides whether one word-sized signed integer is less than or equal to another. Usually accessed via
the DecidableLE ISize
instance.
This function is overridden at runtime with an efficient implementation.
Examples:
🔗defUInt8.decLe (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:
🔗defInt8.decLe (a b : Int8) : Decidable (a ≤ b)
Decides whether one 8-bit signed integer is less than or equal to another. Usually accessed via the
DecidableLE Int8
instance.
This function is overridden at runtime with an efficient implementation.
Examples:
🔗defUInt16.decLe (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:
🔗defInt16.decLe (a b : Int16) : Decidable (a ≤ b)
Decides whether one 16-bit signed integer is less than or equal to another. Usually accessed via the
DecidableLE Int16
instance.
This function is overridden at runtime with an efficient implementation.
Examples:
🔗defUInt32.decLe (a b : UInt32) : Decidable (a ≤ b)
Decides whether one 32-bit signed integer is less than or equal to another. Usually accessed via the
DecidableLE UInt32
instance.
This function is overridden at runtime with an efficient implementation.
Examples:
🔗defInt32.decLe (a b : Int32) : Decidable (a ≤ b)
Decides whether one 32-bit signed integer is less than or equal to another. Usually accessed via the
DecidableLE Int32
instance.
This function is overridden at runtime with an efficient implementation.
Examples:
🔗defUInt64.decLe (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:
🔗defInt64.decLe (a b : Int64) : Decidable (a ≤ b)
Decides whether one 8-bit signed integer is less than or equal to another. Usually accessed via the
DecidableLE Int64
instance.
This function is overridden at runtime with an efficient implementation.
Examples:
🔗defUSize.decLt (a b : USize) : Decidable (a < b)
Decides whether one word-sized unsigned integer is strictly less than another. Usually accessed via
the DecidableLT USize
instance.
This function is overridden at runtime with an efficient implementation.
Examples:
🔗defISize.decLt (a b : ISize) : Decidable (a < b)
Decides whether one word-sized signed integer is strictly less than another. Usually accessed via the
DecidableLT ISize
instance.
This function is overridden at runtime with an efficient implementation.
Examples:
🔗defUInt8.decLt (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:
🔗defInt8.decLt (a b : Int8) : Decidable (a < b)
Decides whether one 8-bit signed integer is strictly less than another. Usually accessed via the
DecidableLT Int8
instance.
This function is overridden at runtime with an efficient implementation.
Examples:
🔗defUInt16.decLt (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:
🔗defInt16.decLt (a b : Int16) : Decidable (a < b)
Decides whether one 16-bit signed integer is strictly less than another. Usually accessed via the
DecidableLT Int16
instance.
This function is overridden at runtime with an efficient implementation.
Examples:
🔗defUInt32.decLt (a b : UInt32) : Decidable (a < b)
Decides whether one 8-bit unsigned integer is strictly less than another. Usually accessed via the
DecidableLT UInt32
instance.
This function is overridden at runtime with an efficient implementation.
Examples:
🔗defInt32.decLt (a b : Int32) : Decidable (a < b)
Decides whether one 32-bit signed integer is strictly less than another. Usually accessed via the
DecidableLT Int32
instance.
This function is overridden at runtime with an efficient implementation.
Examples:
🔗defUInt64.decLt (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:
🔗defInt64.decLt (a b : Int64) : Decidable (a < b)
Decides whether one 8-bit signed integer is strictly less than another. Usually accessed via the
DecidableLT Int64
instance.
This function is overridden at runtime with an efficient implementation.
Examples:
18.4.4.5. Arithmetic🔗
Typically, arithmetic operations on fixed-width integers should be accessed using Lean's overloaded arithmetic notation, particularly their instances of Add
, Sub
, Mul
, Div
, and Mod
, as well as Neg
for signed types.
🔗defISize.neg (i : ISize) : ISize
Negates word-sized signed integers. Usually accessed via the -
prefix operator.
This function is overridden at runtime with an efficient implementation.
🔗defInt8.neg (i : Int8) : Int8
Negates 8-bit signed integers. Usually accessed via the -
prefix operator.
This function is overridden at runtime with an efficient implementation.
🔗defInt16.neg (i : Int16) : Int16
Negates 16-bit signed integers. Usually accessed via the -
prefix operator.
This function is overridden at runtime with an efficient implementation.
🔗defInt32.neg (i : Int32) : Int32
Negates 32-bit signed integers. Usually accessed via the -
prefix operator.
This function is overridden at runtime with an efficient implementation.
🔗defInt64.neg (i : Int64) : Int64
Negates 64-bit signed integers. Usually accessed via the -
prefix operator.
This function is overridden at runtime with an efficient implementation.
🔗defUSize.neg (a : USize) : USize
Negation of word-sized unsigned integers, computed modulo USize.size
.
This function is overridden at runtime with an efficient implementation.
🔗defUInt8.neg (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.
🔗defUInt16.neg (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.
🔗defUInt32.neg (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.
🔗defUInt64.neg (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.
🔗defUSize.add (a b : USize) : USize
Adds two word-sized unsigned integers, wrapping around on overflow. Usually accessed via the +
operator.
This function is overridden at runtime with an efficient implementation.
🔗defISize.add (a b : ISize) : ISize
Adds two word-sized signed integers, wrapping around on over- or underflow. Usually accessed via
the +
operator.
This function is overridden at runtime with an efficient implementation.
🔗defUInt8.add (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.
🔗defInt8.add (a b : Int8) : Int8
Adds two 8-bit signed integers, wrapping around on over- or underflow. Usually accessed via the +
operator.
This function is overridden at runtime with an efficient implementation.
🔗defUInt16.add (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.
🔗defInt16.add (a b : Int16) : Int16
Adds two 16-bit signed integers, wrapping around on over- or underflow. Usually accessed via the +
operator.
This function is overridden at runtime with an efficient implementation.
🔗defUInt32.add (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.
🔗defInt32.add (a b : Int32) : Int32
Adds two 32-bit signed integers, wrapping around on over- or underflow. Usually accessed via the
+
operator.
This function is overridden at runtime with an efficient implementation.
🔗defUInt64.add (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.
🔗defInt64.add (a b : Int64) : Int64
Adds two 64-bit signed integers, wrapping around on over- or underflow. Usually accessed via the
+
operator.
This function is overridden at runtime with an efficient implementation.
🔗defUSize.sub (a b : USize) : USize
Subtracts one word-sized-bit unsigned integer from another, wrapping around on underflow. Usually
accessed via the -
operator.
This function is overridden at runtime with an efficient implementation.
🔗defISize.sub (a b : ISize) : ISize
Subtracts one word-sized signed integer from another, wrapping around on over- or underflow. Usually
accessed via the -
operator.
This function is overridden at runtime with an efficient implementation.
🔗defUInt8.sub (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.
🔗defInt8.sub (a b : Int8) : Int8
Subtracts one 8-bit signed integer from another, wrapping around on over- or underflow. Usually
accessed via the -
operator.
This function is overridden at runtime with an efficient implementation.
🔗defUInt16.sub (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.
🔗defInt16.sub (a b : Int16) : Int16
Subtracts one 16-bit signed integer from another, wrapping around on over- or underflow. Usually
accessed via the -
operator.
This function is overridden at runtime with an efficient implementation.
🔗defUInt32.sub (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.
🔗defInt32.sub (a b : Int32) : Int32
Subtracts one 32-bit signed integer from another, wrapping around on over- or underflow. Usually
accessed via the -
operator.
This function is overridden at runtime with an efficient implementation.
🔗defUInt64.sub (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.
🔗defInt64.sub (a b : Int64) : Int64
Subtracts one 64-bit signed integer from another, wrapping around on over- or underflow. Usually
accessed via the -
operator.
This function is overridden at runtime with an efficient implementation.
🔗defUSize.mul (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.
🔗defISize.mul (a b : ISize) : ISize
Multiplies two word-sized signed integers, wrapping around on over- or underflow. Usually accessed
via the *
operator.
This function is overridden at runtime with an efficient implementation.
🔗defUInt8.mul (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.
🔗defInt8.mul (a b : Int8) : Int8
Multiplies two 8-bit signed integers, wrapping around on over- or underflow. Usually accessed via
the *
operator.
This function is overridden at runtime with an efficient implementation.
🔗defUInt16.mul (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.
🔗defInt16.mul (a b : Int16) : Int16
Multiplies two 16-bit signed integers, wrapping around on over- or underflow. Usually accessed via
the *
operator.
This function is overridden at runtime with an efficient implementation.
🔗defUInt32.mul (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.
🔗defInt32.mul (a b : Int32) : Int32
Multiplies two 32-bit signed integers, wrapping around on over- or underflow. Usually accessed via
the *
operator.
This function is overridden at runtime with an efficient implementation.
🔗defUInt64.mul (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.
🔗defInt64.mul (a b : Int64) : Int64
Multiplies two 64-bit signed integers, wrapping around on over- or underflow. Usually accessed via
the *
operator.
This function is overridden at runtime with an efficient implementation.
🔗defUSize.div (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.
🔗defISize.div (a b : ISize) : ISize
Truncating division for word-sized signed integers, rounding towards zero. Usually accessed via the
/
operator.
Division by zero is defined to be zero.
This function is overridden at runtime with an efficient implementation.
Examples:
🔗defUInt8.div (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.
🔗defInt8.div (a b : Int8) : Int8
Truncating division for 8-bit signed integers, rounding towards zero. Usually accessed via the /
operator.
Division by zero is defined to be zero.
This function is overridden at runtime with an efficient implementation.
Examples:
🔗defUInt16.div (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.
🔗defInt16.div (a b : Int16) : Int16
Truncating division for 16-bit signed integers, rounding towards zero. Usually accessed via the /
operator.
Division by zero is defined to be zero.
This function is overridden at runtime with an efficient implementation.
Examples:
🔗defUInt32.div (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.
🔗defInt32.div (a b : Int32) : Int32
Truncating division for 32-bit signed integers, rounding towards zero. Usually accessed via the /
operator.
Division by zero is defined to be zero.
This function is overridden at runtime with an efficient implementation.
Examples:
🔗defUInt64.div (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.
🔗defInt64.div (a b : Int64) : Int64
Truncating division for 64-bit signed integers, rounding towards zero. Usually accessed via the /
operator.
Division by zero is defined to be zero.
This function is overridden at runtime with an efficient implementation.
Examples:
🔗defUSize.mod (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:
🔗defISize.mod (a b : ISize) : ISize
The modulo operator for word-sized signed integers, which computes the remainder when dividing one
integer by another with the T-rounding convention used by ISize.div
. 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:
🔗defUInt8.mod (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:
🔗defInt8.mod (a b : Int8) : Int8
The modulo operator for 8-bit signed integers, which computes the remainder when dividing one
integer by another with the T-rounding convention used by Int8.div
. 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:
🔗defUInt16.mod (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:
🔗defInt16.mod (a b : Int16) : Int16
The modulo operator for 16-bit signed integers, which computes the remainder when dividing one
integer by another with the T-rounding convention used by Int16.div
. 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:
🔗defUInt32.mod (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:
🔗defInt32.mod (a b : Int32) : Int32
The modulo operator for 32-bit signed integers, which computes the remainder when dividing one
integer by another with the T-rounding convention used by Int32.div
. 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:
🔗defUInt64.mod (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:
🔗defInt64.mod (a b : Int64) : Int64
The modulo operator for 64-bit signed integers, which computes the remainder when dividing one
integer by another with the T-rounding convention used by Int64.div
. 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:
🔗defUSize.log2 (a : USize) : USize
Base-two logarithm of word-sized unsigned integers. Returns ⌊max 0 (log₂ a)⌋
.
This function is overridden at runtime with an efficient implementation. This definition is
the logical model.
Examples:
🔗defUInt8.log2 (a : UInt8) : UInt8
Base-two logarithm of 8-bit unsigned integers. Returns ⌊max 0 (log₂ a)⌋
.
This function is overridden at runtime with an efficient implementation. This definition is
the logical model.
Examples:
🔗defUInt16.log2 (a : UInt16) : UInt16
Base-two logarithm of 16-bit unsigned integers. Returns ⌊max 0 (log₂ a)⌋
.
This function is overridden at runtime with an efficient implementation. This definition is
the logical model.
Examples:
🔗defUInt32.log2 (a : UInt32) : UInt32
Base-two logarithm of 32-bit unsigned integers. Returns ⌊max 0 (log₂ a)⌋
.
This function is overridden at runtime with an efficient implementation. This definition is
the logical model.
Examples:
🔗defUInt64.log2 (a : UInt64) : UInt64
Base-two logarithm of 64-bit unsigned integers. Returns ⌊max 0 (log₂ a)⌋
.
This function is overridden at runtime with an efficient implementation. This definition is
the logical model.
Examples:
🔗defISize.abs (a : ISize) : ISize
Computes the absolute value of a word-sized signed integer.
This function is equivalent to if a < 0 then -a else a
, so in particular ISize.minValue
will be
mapped to ISize.minValue
.
This function is overridden at runtime with an efficient implementation.
🔗defInt8.abs (a : Int8) : Int8
Computes the absolute value of an 8-bit signed integer.
This function is equivalent to if a < 0 then -a else a
, so in particular Int8.minValue
will be
mapped to Int8.minValue
.
This function is overridden at runtime with an efficient implementation.
🔗defInt16.abs (a : Int16) : Int16
Computes the absolute value of a 16-bit signed integer.
This function is equivalent to if a < 0 then -a else a
, so in particular Int16.minValue
will be
mapped to Int16.minValue
.
This function is overridden at runtime with an efficient implementation.
🔗defInt32.abs (a : Int32) : Int32
Computes the absolute value of a 32-bit signed integer.
This function is equivalent to if a < 0 then -a else a
, so in particular Int32.minValue
will be
mapped to Int32.minValue
.
This function is overridden at runtime with an efficient implementation.
🔗defInt64.abs (a : Int64) : Int64
Computes the absolute value of a 64-bit signed integer.
This function is equivalent to if a < 0 then -a else a
, so in particular Int64.minValue
will be
mapped to Int64.minValue
.
This function is overridden at runtime with an efficient implementation.
18.4.4.6. Bitwise Operations
Typically, bitwise operations on fixed-width integers should be accessed using Lean's overloaded operators, particularly their instances of ShiftLeft
, ShiftRight
, AndOp
, OrOp
, and Xor
.
🔗defUSize.land (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.
🔗defISize.land (a b : ISize) : ISize
Bitwise and for word-sized signed integers. Usually accessed via the &&&
operator.
Each bit of the resulting integer is set if the corresponding bits of both input integers are set,
according to the two's complement representation.
This function is overridden at runtime with an efficient implementation.
🔗defUInt8.land (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.
🔗defInt8.land (a b : Int8) : Int8
Bitwise and for 8-bit signed integers. Usually accessed via the &&&
operator.
Each bit of the resulting integer is set if the corresponding bits of both input integers are set,
according to the two's complement representation.
This function is overridden at runtime with an efficient implementation.
🔗defUInt16.land (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.
🔗defInt16.land (a b : Int16) : Int16
Bitwise and for 16-bit signed integers. Usually accessed via the &&&
operator.
Each bit of the resulting integer is set if the corresponding bits of both input integers are set,
according to the two's complement representation.
This function is overridden at runtime with an efficient implementation.
🔗defUInt32.land (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.
🔗defInt32.land (a b : Int32) : Int32
Bitwise and for 32-bit signed integers. Usually accessed via the &&&
operator.
Each bit of the resulting integer is set if the corresponding bits of both input integers are set,
according to the two's complement representation.
This function is overridden at runtime with an efficient implementation.
🔗defUInt64.land (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.
🔗defInt64.land (a b : Int64) : Int64
Bitwise and for 64-bit signed integers. Usually accessed via the &&&
operator.
Each bit of the resulting integer is set if the corresponding bits of both input integers are set,
according to the two's complement representation.
This function is overridden at runtime with an efficient implementation.
🔗defUSize.lor (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.
🔗defISize.lor (a b : ISize) : ISize
Bitwise or for word-sized signed integers. Usually accessed via the |||
operator.
Each bit of the resulting integer is set if at least one of the corresponding bits of the input
integers is set, according to the two's complement representation.
This function is overridden at runtime with an efficient implementation.
🔗defUInt8.lor (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.
🔗defInt8.lor (a b : Int8) : Int8
Bitwise or for 8-bit signed integers. Usually accessed via the |||
operator.
Each bit of the resulting integer is set if at least one of the corresponding bits of the input
integers is set, according to the two's complement representation.
This function is overridden at runtime with an efficient implementation.
🔗defUInt16.lor (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.
🔗defInt16.lor (a b : Int16) : Int16
Bitwise or for 16-bit signed integers. Usually accessed via the |||
operator.
Each bit of the resulting integer is set if at least one of the corresponding bits of the input
integers is set, according to the two's complement representation.
This function is overridden at runtime with an efficient implementation.
🔗defUInt32.lor (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.
🔗defInt32.lor (a b : Int32) : Int32
Bitwise or for 32-bit signed integers. Usually accessed via the |||
operator.
Each bit of the resulting integer is set if at least one of the corresponding bits of the input
integers is set, according to the two's complement representation.
This function is overridden at runtime with an efficient implementation.
🔗defUInt64.lor (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.
🔗defInt64.lor (a b : Int64) : Int64
Bitwise or for 64-bit signed integers. Usually accessed via the |||
operator.
Each bit of the resulting integer is set if at least one of the corresponding bits of the input
integers is set, according to the two's complement representation.
This function is overridden at runtime with an efficient implementation.
🔗defUSize.xor (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.
🔗defISize.xor (a b : ISize) : ISize
Bitwise exclusive or for word-sized signed integers. Usually accessed via the ^^^
operator.
Each bit of the resulting integer is set if exactly one of the corresponding bits of the input
integers is set, according to the two's complement representation.
This function is overridden at runtime with an efficient implementation.
🔗defUInt8.xor (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.
🔗defInt8.xor (a b : Int8) : Int8
Bitwise exclusive or for 8-bit signed integers. Usually accessed via the ^^^
operator.
Each bit of the resulting integer is set if exactly one of the corresponding bits of the input
integers is set, according to the two's complement representation.
This function is overridden at runtime with an efficient implementation.
🔗defUInt16.xor (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.
🔗defInt16.xor (a b : Int16) : Int16
Bitwise exclusive or for 16-bit signed integers. Usually accessed via the ^^^
operator.
Each bit of the resulting integer is set if exactly one of the corresponding bits of the input
integers is set, according to the two's complement representation.
This function is overridden at runtime with an efficient implementation.
🔗defUInt32.xor (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.
🔗defInt32.xor (a b : Int32) : Int32
Bitwise exclusive or for 32-bit signed integers. Usually accessed via the ^^^
operator.
Each bit of the resulting integer is set if exactly one of the corresponding bits of the input
integers is set, according to the two's complement representation.
This function is overridden at runtime with an efficient implementation.
🔗defUInt64.xor (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.
🔗defInt64.xor (a b : Int64) : Int64
Bitwise exclusive or for 64-bit signed integers. Usually accessed via the ^^^
operator.
Each bit of the resulting integer is set if exactly one of the corresponding bits of the input
integers is set, according to the two's complement representation.
This function is overridden at runtime with an efficient implementation.
🔗defUSize.complement (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.
🔗defISize.complement (a : ISize) : ISize
Bitwise complement, also known as bitwise negation, for word-sized signed integers. Usually accessed
via the ~~~
prefix operator.
Each bit of the resulting integer is the opposite of the corresponding bit of the input integer.
Integers use the two's complement representation, so ISize.complement a = -(a + 1)
.
This function is overridden at runtime with an efficient implementation.
🔗defUInt8.complement (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.
🔗defInt8.complement (a : Int8) : Int8
Bitwise complement, also known as bitwise negation, for 8-bit signed integers. Usually accessed via
the ~~~
prefix operator.
Each bit of the resulting integer is the opposite of the corresponding bit of the input integer.
Integers use the two's complement representation, so Int8.complement a = -(a + 1)
.
This function is overridden at runtime with an efficient implementation.
🔗defUInt16.complement (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.
🔗defInt16.complement (a : Int16) : Int16
Bitwise complement, also known as bitwise negation, for 16-bit signed integers. Usually accessed via
the ~~~
prefix operator.
Each bit of the resulting integer is the opposite of the corresponding bit of the input integer.
Integers use the two's complement representation, so Int16.complement a = -(a + 1)
.
This function is overridden at runtime with an efficient implementation.
🔗defUInt32.complement (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.
🔗defInt32.complement (a : Int32) : Int32
Bitwise complement, also known as bitwise negation, for 32-bit signed integers. Usually accessed via
the ~~~
prefix operator.
Each bit of the resulting integer is the opposite of the corresponding bit of the input integer.
Integers use the two's complement representation, so Int32.complement a = -(a + 1)
.
This function is overridden at runtime with an efficient implementation.
🔗defUInt64.complement (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.
🔗defInt64.complement (a : Int64) : Int64
Bitwise complement, also known as bitwise negation, for 64-bit signed integers. Usually accessed via
the ~~~
prefix operator.
Each bit of the resulting integer is the opposite of the corresponding bit of the input integer.
Integers use the two's complement representation, so Int64.complement a = -(a + 1)
.
This function is overridden at runtime with an efficient implementation.
🔗defUSize.shiftLeft (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.
🔗defISize.shiftLeft (a b : ISize) : ISize
Bitwise left shift for word-sized signed integers. Usually accessed via the <<<
operator.
Signed integers are interpreted as bitvectors according to the two's complement representation.
This function is overridden at runtime with an efficient implementation.
🔗defUInt8.shiftLeft (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.
🔗defInt8.shiftLeft (a b : Int8) : Int8
Bitwise left shift for 8-bit signed integers. Usually accessed via the <<<
operator.
Signed integers are interpreted as bitvectors according to the two's complement representation.
This function is overridden at runtime with an efficient implementation.
🔗defUInt16.shiftLeft (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.
🔗defInt16.shiftLeft (a b : Int16) : Int16
Bitwise left shift for 16-bit signed integers. Usually accessed via the <<<
operator.
Signed integers are interpreted as bitvectors according to the two's complement representation.
This function is overridden at runtime with an efficient implementation.
🔗defUInt32.shiftLeft (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.
🔗defInt32.shiftLeft (a b : Int32) : Int32
Bitwise left shift for 32-bit signed integers. Usually accessed via the <<<
operator.
Signed integers are interpreted as bitvectors according to the two's complement representation.
This function is overridden at runtime with an efficient implementation.
🔗defUInt64.shiftLeft (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.
🔗defInt64.shiftLeft (a b : Int64) : Int64
Bitwise left shift for 64-bit signed integers. Usually accessed via the <<<
operator.
Signed integers are interpreted as bitvectors according to the two's complement representation.
This function is overridden at runtime with an efficient implementation.
🔗defUSize.shiftRight (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.
🔗defISize.shiftRight (a b : ISize) : ISize
Arithmetic right shift for word-sized signed integers. Usually accessed via the <<<
operator.
The high bits are filled with the value of
the most significant bit.
This function is overridden at runtime with an efficient implementation.
🔗defUInt8.shiftRight (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.
🔗defInt8.shiftRight (a b : Int8) : Int8
Arithmetic right shift for 8-bit signed integers. Usually accessed via the <<<
operator.
The high bits are filled with the value of the most significant bit.
This function is overridden at runtime with an efficient implementation.
🔗defUInt16.shiftRight (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.
🔗defInt16.shiftRight (a b : Int16) : Int16
Arithmetic right shift for 16-bit signed integers. Usually accessed via the <<<
operator.
The high bits are filled with the value of the most significant bit.
This function is overridden at runtime with an efficient implementation.
🔗defUInt32.shiftRight (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.
🔗defInt32.shiftRight (a b : Int32) : Int32
Arithmetic right shift for 32-bit signed integers. Usually accessed via the <<<
operator.
The high bits are filled with the value of the most significant bit.
This function is overridden at runtime with an efficient implementation.
🔗defUInt64.shiftRight (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.
🔗defInt64.shiftRight (a b : Int64) : Int64
Arithmetic right shift for 64-bit signed integers. Usually accessed via the <<<
operator.
The high bits are filled with the value of the most significant bit.
This function is overridden at runtime with an efficient implementation.