This module exists to provide the very basic UInt8 etc. definitions required for
Init.Data.Char.Basic and Init.Data.Array.Basic. These are very important as they are used in
meta code that is then (transitively) used in Init.Data.UInt.Basic and Init.Data.BitVec.Basic.
This file thus breaks the import cycle that would be created by this dependency.
Converts a natural number to an 8-bit unsigned integer, returning the largest representable value if the number is too large.
Returns 2^8 - 1 for natural numbers greater than or equal to 2^8.
Equations
- UInt8.ofNatTruncate n = if h : n < UInt8.size then UInt8.ofNatLT n h else UInt8.ofNatLT (UInt8.size - 1) UInt8.ofNatTruncate._proof_1
Instances For
Converts a natural number to an 8-bit unsigned integer, wrapping on overflow.
This function is overridden at runtime with an efficient implementation.
Examples:
Nat.toUInt8 5 = 5Nat.toUInt8 255 = 255Nat.toUInt8 256 = 0Nat.toUInt8 259 = 3Nat.toUInt8 32770 = 2
Equations
Instances For
Equations
- UInt8.instOfNat = { ofNat := UInt8.ofNat n }
Converts a natural number to a 16-bit unsigned integer, wrapping on overflow.
This function is overridden at runtime with an efficient implementation.
Examples:
UInt16.ofNat 5 = 5UInt16.ofNat 255 = 255UInt16.ofNat 32770 = 32770UInt16.ofNat 65537 = 1
Equations
- UInt16.ofNat n = { toBitVec := BitVec.ofNat 16 n }
Instances For
Converts a natural number to a 16-bit unsigned integer, returning the largest representable value if the number is too large.
Returns 2^16 - 1 for natural numbers greater than or equal to 2^16.
Equations
- UInt16.ofNatTruncate n = if h : n < UInt16.size then UInt16.ofNatLT n h else UInt16.ofNatLT (UInt16.size - 1) UInt16.ofNatTruncate._proof_1
Instances For
Converts a natural number to a 16-bit unsigned integer, wrapping on overflow.
This function is overridden at runtime with an efficient implementation.
Examples:
Nat.toUInt16 5 = 5Nat.toUInt16 255 = 255Nat.toUInt16 32770 = 32770Nat.toUInt16 65537 = 1
Equations
Instances For
Equations
- UInt16.instOfNat = { ofNat := UInt16.ofNat n }
Converts a natural number to a 32-bit unsigned integer, wrapping on overflow.
This function is overridden at runtime with an efficient implementation.
Examples:
UInt32.ofNat 5 = 5UInt32.ofNat 65539 = 65539UInt32.ofNat 4_294_967_299 = 3
Equations
- UInt32.ofNat n = { toBitVec := BitVec.ofNat 32 n }
Instances For
Converts a natural number to a 32-bit unsigned integer, returning the largest representable value if the number is too large.
Returns 2^32 - 1 for natural numbers greater than or equal to 2^32.
Equations
- UInt32.ofNatTruncate n = if h : n < UInt32.size then UInt32.ofNatLT n h else UInt32.ofNatLT (UInt32.size - 1) UInt32.ofNatTruncate._proof_1
Instances For
Converts a natural number to a 32-bit unsigned integer, wrapping on overflow.
This function is overridden at runtime with an efficient implementation.
Examples:
Nat.toUInt32 5 = 5Nat.toUInt32 65_539 = 65_539Nat.toUInt32 4_294_967_299 = 3
Equations
Instances For
Equations
- UInt32.instOfNat = { ofNat := UInt32.ofNat n }
Converts a natural number to a 64-bit unsigned integer, wrapping on overflow.
This function is overridden at runtime with an efficient implementation.
Examples:
UInt64.ofNat 5 = 5UInt64.ofNat 65539 = 65539UInt64.ofNat 4_294_967_299 = 4_294_967_299UInt64.ofNat 18_446_744_073_709_551_620 = 4
Equations
- UInt64.ofNat n = { toBitVec := BitVec.ofNat 64 n }
Instances For
Converts a natural number to a 64-bit unsigned integer, returning the largest representable value if the number is too large.
Returns 2^64 - 1 for natural numbers greater than or equal to 2^64.
Equations
- UInt64.ofNatTruncate n = if h : n < UInt64.size then UInt64.ofNatLT n h else UInt64.ofNatLT (UInt64.size - 1) UInt64.ofNatTruncate._proof_1
Instances For
Converts a natural number to a 64-bit unsigned integer, wrapping on overflow.
This function is overridden at runtime with an efficient implementation.
Examples:
Nat.toUInt64 5 = 5Nat.toUInt64 65539 = 65539Nat.toUInt64 4_294_967_299 = 4_294_967_299Nat.toUInt64 18_446_744_073_709_551_620 = 4
Equations
Instances For
Converts 16-bit unsigned integers to 64-bit unsigned integers. Wraps around on overflow.
This function is overridden at runtime with an efficient implementation.
Instances For
Converts 32-bit unsigned integers to 64-bit unsigned integers. Wraps around on overflow.
This function is overridden at runtime with an efficient implementation.
Instances For
Equations
- UInt64.instOfNat = { ofNat := UInt64.ofNat n }
Converts an arbitrary-precision natural number to an unsigned word-sized integer, wrapping around on overflow.
This function is overridden at runtime with an efficient implementation.
Equations
- USize.ofNat n = { toBitVec := BitVec.ofNat System.Platform.numBits n }
Instances For
Converts a natural number to USize, returning the largest representable value if the number is too
large.
Returns USize.size - 1, which is 2^64 - 1 or 2^32 - 1 depending on the platform, for natural
numbers greater than or equal to USize.size.
Equations
- USize.ofNatTruncate n = if h : n < USize.size then USize.ofNatLT n h else USize.ofNatLT (USize.size - 1) USize.ofNatTruncate._proof_1
Instances For
Converts an arbitrary-precision natural number to an unsigned word-sized integer, wrapping around on overflow.
This function is overridden at runtime with an efficient implementation.
Equations
Instances For
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.
Instances For
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.
Instances For
Equations
- USize.instOfNat = { ofNat := USize.ofNat n }
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:
(if (6 : USize) < 7 then "yes" else "no") = "yes"(if (5 : USize) < 5 then "yes" else "no") = "no"show ¬((7 : USize) < 7) by decide
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:
(if (15 : USize) ≤ 15 then "yes" else "no") = "yes"(if (15 : USize) ≤ 5 then "yes" else "no") = "no"(if (5 : USize) ≤ 15 then "yes" else "no") = "yes"show (7 : USize) ≤ 7 by decide