This module contains the definition of signed fixed width integer types as well as basic arithmetic and bitwise operations on top of it.
Equations
- Int8.ofInt i = { toUInt8 := { toBitVec := BitVec.ofInt 8 i } }
Instances For
Equations
- Int8.ofNat n = { toUInt8 := { toBitVec := BitVec.ofNat 8 n } }
Instances For
Equations
Instances For
Equations
Instances For
Obtains the Int8
whose 2's complement representation is the given BitVec 8
.
Equations
- Int8.ofBitVec b = { toUInt8 := { toBitVec := b } }
Instances For
Equations
- instToStringInt8 = { toString := fun (i : Int8) => toString i.toInt }
Equations
- instHashableInt8 = { hash := fun (i : Int8) => i.toUInt8.toUInt64 }
Equations
- Int8.instOfNat = { ofNat := Int8.ofNat n }
The maximum value an Int8
may attain, that is, 2^7 - 1 = 127
.
Equations
- Int8.maxValue = 127
Instances For
The minimum value an Int8
may attain, that is, -2^7 = -128
.
Equations
- Int8.minValue = -128
Instances For
Constructs an Int8
from an Int
which is known to be in bounds.
Equations
- Int8.ofIntLE i _hl _hr = Int8.ofInt i
Instances For
Constructs an Int8
from an Int
, clamping if the value is too small or too large.
Equations
- Int8.ofIntTruncate i = if hl : Int8.minValue.toInt ≤ i then if hr : i ≤ Int8.maxValue.toInt then Int8.ofIntLE i hl hr else Int8.minValue else Int8.minValue
Instances For
Equations
- a.shiftRight b = { toUInt8 := { toBitVec := a.toBitVec.sshiftRight' (b.toBitVec.smod 8) } }
Instances For
Equations
- a.complement = { toUInt8 := { toBitVec := ~~~a.toBitVec } }
Instances For
Computes the absolute value of the 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
.
Instances For
Equations
- instComplementInt8 = { complement := Int8.complement }
Equations
- instShiftLeftInt8 = { shiftLeft := Int8.shiftLeft }
Equations
- instShiftRightInt8 = { shiftRight := Int8.shiftRight }
Equations
- instDecidableLtInt8 a b = a.decLt b
Equations
- instDecidableLeInt8 a b = a.decLe b
The size of type Int16
, that is, 2^16 = 65536
.
Equations
- Int16.size = 65536
Instances For
Equations
- Int16.ofInt i = { toUInt16 := { toBitVec := BitVec.ofInt 16 i } }
Instances For
Equations
- Int16.ofNat n = { toUInt16 := { toBitVec := BitVec.ofNat 16 n } }
Instances For
Equations
Instances For
Equations
Instances For
Obtains the Int16
whose 2's complement representation is the given BitVec 16
.
Equations
- Int16.ofBitVec b = { toUInt16 := { toBitVec := b } }
Instances For
Equations
- a.toInt8 = { toUInt8 := { toBitVec := BitVec.signExtend 8 a.toBitVec } }
Instances For
Equations
- a.toInt16 = { toUInt16 := { toBitVec := BitVec.signExtend 16 a.toBitVec } }
Instances For
Equations
- instToStringInt16 = { toString := fun (i : Int16) => toString i.toInt }
Equations
- instHashableInt16 = { hash := fun (i : Int16) => i.toUInt16.toUInt64 }
Equations
- Int16.instOfNat = { ofNat := Int16.ofNat n }
The maximum value an Int16
may attain, that is, 2^15 - 1 = 32767
.
Equations
- Int16.maxValue = 32767
Instances For
The minimum value an Int16
may attain, that is, -2^15 = -32768
.
Equations
- Int16.minValue = -32768
Instances For
Constructs an Int16
from an Int
which is known to be in bounds.
Equations
- Int16.ofIntLE i _hl _hr = Int16.ofInt i
Instances For
Constructs an Int16
from an Int
, clamping if the value is too small or too large.
Equations
- Int16.ofIntTruncate i = if hl : Int16.minValue.toInt ≤ i then if hr : i ≤ Int16.maxValue.toInt then Int16.ofIntLE i hl hr else Int16.minValue else Int16.minValue
Instances For
Equations
- a.shiftRight b = { toUInt16 := { toBitVec := a.toBitVec.sshiftRight' (b.toBitVec.smod 16) } }
Instances For
Equations
- a.complement = { toUInt16 := { toBitVec := ~~~a.toBitVec } }
Instances For
Computes the absolute value of the 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
.
Instances For
Equations
- instComplementInt16 = { complement := Int16.complement }
Equations
- instShiftLeftInt16 = { shiftLeft := Int16.shiftLeft }
Equations
- instShiftRightInt16 = { shiftRight := Int16.shiftRight }
Equations
- instDecidableLtInt16 a b = a.decLt b
Equations
- instDecidableLeInt16 a b = a.decLe b
The size of type Int32
, that is, 2^32 = 4294967296
.
Equations
- Int32.size = 4294967296
Instances For
Equations
- Int32.ofInt i = { toUInt32 := { toBitVec := BitVec.ofInt 32 i } }
Instances For
Equations
- Int32.ofNat n = { toUInt32 := { toBitVec := BitVec.ofNat 32 n } }
Instances For
Equations
Instances For
Equations
Instances For
Obtains the Int32
whose 2's complement representation is the given BitVec 32
.
Equations
- Int32.ofBitVec b = { toUInt32 := { toBitVec := b } }
Instances For
Equations
- a.toInt8 = { toUInt8 := { toBitVec := BitVec.signExtend 8 a.toBitVec } }
Instances For
Equations
- a.toInt16 = { toUInt16 := { toBitVec := BitVec.signExtend 16 a.toBitVec } }
Instances For
Equations
- a.toInt32 = { toUInt32 := { toBitVec := BitVec.signExtend 32 a.toBitVec } }
Instances For
Equations
- a.toInt32 = { toUInt32 := { toBitVec := BitVec.signExtend 32 a.toBitVec } }
Instances For
Equations
- instToStringInt32 = { toString := fun (i : Int32) => toString i.toInt }
Equations
- instHashableInt32 = { hash := fun (i : Int32) => i.toUInt32.toUInt64 }
Equations
- Int32.instOfNat = { ofNat := Int32.ofNat n }
The maximum value an Int32
may attain, that is, 2^31 - 1 = 2147483647
.
Equations
- Int32.maxValue = 2147483647
Instances For
The minimum value an Int32
may attain, that is, -2^31 = -2147483648
.
Equations
- Int32.minValue = -2147483648
Instances For
Constructs an Int32
from an Int
which is known to be in bounds.
Equations
- Int32.ofIntLE i _hl _hr = Int32.ofInt i
Instances For
Constructs an Int32
from an Int
, clamping if the value is too small or too large.
Equations
- Int32.ofIntTruncate i = if hl : Int32.minValue.toInt ≤ i then if hr : i ≤ Int32.maxValue.toInt then Int32.ofIntLE i hl hr else Int32.minValue else Int32.minValue
Instances For
Equations
- a.shiftRight b = { toUInt32 := { toBitVec := a.toBitVec.sshiftRight' (b.toBitVec.smod 32) } }
Instances For
Equations
- a.complement = { toUInt32 := { toBitVec := ~~~a.toBitVec } }
Instances For
Computes the absolute value of the 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
.
Instances For
Equations
- instComplementInt32 = { complement := Int32.complement }
Equations
- instShiftLeftInt32 = { shiftLeft := Int32.shiftLeft }
Equations
- instShiftRightInt32 = { shiftRight := Int32.shiftRight }
Equations
- instDecidableLtInt32 a b = a.decLt b
Equations
- instDecidableLeInt32 a b = a.decLe b
The size of type Int64
, that is, 2^64 = 18446744073709551616
.
Equations
- Int64.size = 18446744073709551616
Instances For
Equations
- Int64.ofInt i = { toUInt64 := { toBitVec := BitVec.ofInt 64 i } }
Instances For
Equations
- Int64.ofNat n = { toUInt64 := { toBitVec := BitVec.ofNat 64 n } }
Instances For
Equations
Instances For
Equations
Instances For
Obtains the Int64
whose 2's complement representation is the given BitVec 64
.
Equations
- Int64.ofBitVec b = { toUInt64 := { toBitVec := b } }
Instances For
Equations
- a.toInt8 = { toUInt8 := { toBitVec := BitVec.signExtend 8 a.toBitVec } }
Instances For
Equations
- a.toInt16 = { toUInt16 := { toBitVec := BitVec.signExtend 16 a.toBitVec } }
Instances For
Equations
- a.toInt32 = { toUInt32 := { toBitVec := BitVec.signExtend 32 a.toBitVec } }
Instances For
Equations
- a.toInt64 = { toUInt64 := { toBitVec := BitVec.signExtend 64 a.toBitVec } }
Instances For
Equations
- a.toInt64 = { toUInt64 := { toBitVec := BitVec.signExtend 64 a.toBitVec } }
Instances For
Equations
- a.toInt64 = { toUInt64 := { toBitVec := BitVec.signExtend 64 a.toBitVec } }
Instances For
Equations
- instToStringInt64 = { toString := fun (i : Int64) => toString i.toInt }
Equations
- instHashableInt64 = { hash := fun (i : Int64) => i.toUInt64 }
Equations
- Int64.instOfNat = { ofNat := Int64.ofNat n }
The maximum value an Int64
may attain, that is, 2^63 - 1 = 9223372036854775807
.
Equations
- Int64.maxValue = 9223372036854775807
Instances For
The minimum value an Int64
may attain, that is, -2^63 = -9223372036854775808
.
Equations
- Int64.minValue = -9223372036854775808
Instances For
Constructs an Int64
from an Int
which is known to be in bounds.
Equations
- Int64.ofIntLE i _hl _hr = Int64.ofInt i
Instances For
Constructs an Int64
from an Int
, clamping if the value is too small or too large.
Equations
- Int64.ofIntTruncate i = if hl : Int64.minValue.toInt ≤ i then if hr : i ≤ Int64.maxValue.toInt then Int64.ofIntLE i hl hr else Int64.minValue else Int64.minValue
Instances For
Equations
- a.shiftRight b = { toUInt64 := { toBitVec := a.toBitVec.sshiftRight' (b.toBitVec.smod 64) } }
Instances For
Equations
- a.complement = { toUInt64 := { toBitVec := ~~~a.toBitVec } }
Instances For
Computes the absolute value of the 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
.
Instances For
Equations
- instComplementInt64 = { complement := Int64.complement }
Equations
- instShiftLeftInt64 = { shiftLeft := Int64.shiftLeft }
Equations
- instShiftRightInt64 = { shiftRight := Int64.shiftRight }
Equations
- instDecidableLtInt64 a b = a.decLt b
Equations
- instDecidableLeInt64 a b = a.decLe b
The size of type ISize
, that is, 2^System.Platform.numBits
.
Equations
Instances For
Equations
- ISize.ofInt i = { toUSize := { toBitVec := BitVec.ofInt System.Platform.numBits i } }
Instances For
Equations
- ISize.ofNat n = { toUSize := { toBitVec := BitVec.ofNat System.Platform.numBits n } }
Instances For
Equations
Instances For
Equations
Instances For
Obtains the ISize
whose 2's complement representation is the given BitVec
.
Equations
- ISize.ofBitVec b = { toUSize := { toBitVec := b } }
Instances For
Equations
- a.toInt8 = { toUInt8 := { toBitVec := BitVec.signExtend 8 a.toBitVec } }
Instances For
Equations
- a.toInt16 = { toUInt16 := { toBitVec := BitVec.signExtend 16 a.toBitVec } }
Instances For
Equations
- a.toInt32 = { toUInt32 := { toBitVec := BitVec.signExtend 32 a.toBitVec } }
Instances For
Equations
- a.toISize = { toUSize := { toBitVec := BitVec.signExtend System.Platform.numBits a.toBitVec } }
Instances For
Equations
- a.toISize = { toUSize := { toBitVec := BitVec.signExtend System.Platform.numBits a.toBitVec } }
Instances For
Upcasts Int32
to ISize
. This function is lossless as ISize
is either Int32
or Int64
.
Equations
- a.toISize = { toUSize := { toBitVec := BitVec.signExtend System.Platform.numBits a.toBitVec } }
Instances For
Equations
- a.toISize = { toUSize := { toBitVec := BitVec.signExtend System.Platform.numBits a.toBitVec } }
Instances For
Equations
- instToStringISize = { toString := fun (i : ISize) => toString i.toInt }
Equations
- instHashableISize = { hash := fun (i : ISize) => i.toUSize.toUInt64 }
Equations
- ISize.instOfNat = { ofNat := ISize.ofNat n }
The maximum value an ISize
may attain, that is, 2^(System.Platform.numBits - 1) - 1
.
Equations
- ISize.maxValue = ISize.ofInt (2 ^ (System.Platform.numBits - 1) - 1)
Instances For
The minimum value an ISize
may attain, that is, -2^(System.Platform.numBits - 1)
.
Equations
- ISize.minValue = ISize.ofInt (-2 ^ (System.Platform.numBits - 1))
Instances For
Constructs an ISize
from an Int
which is known to be in bounds.
Equations
- ISize.ofIntLE i _hl _hr = ISize.ofInt i
Instances For
Constructs an ISize
from an Int
, clamping if the value is too small or too large.
Equations
- ISize.ofIntTruncate i = if hl : ISize.minValue.toInt ≤ i then if hr : i ≤ ISize.maxValue.toInt then ISize.ofIntLE i hl hr else ISize.minValue else ISize.minValue
Instances For
Equations
- a.shiftRight b = { toUSize := { toBitVec := a.toBitVec.sshiftRight' (b.toBitVec.smod ↑System.Platform.numBits) } }
Instances For
Equations
- a.complement = { toUSize := { toBitVec := ~~~a.toBitVec } }
Instances For
Computes the absolute value of the 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
.
Instances For
Equations
- instComplementISize = { complement := ISize.complement }
Equations
- instShiftLeftISize = { shiftLeft := ISize.shiftLeft }
Equations
- instShiftRightISize = { shiftRight := ISize.shiftRight }
Equations
- instDecidableLtISize a b = a.decLt b
Equations
- instDecidableLeISize a b = a.decLe b