This module contains the definition of signed fixed width integer types as well as basic arithmetic and bitwise operations on top of it.
@[extern lean_int8_of_int]
Equations
- Int8.ofInt i = { toUInt8 := { toBitVec := BitVec.ofInt 8 i } }
Instances For
@[extern lean_int8_of_nat]
Equations
- Int8.ofNat n = { toUInt8 := { toBitVec := BitVec.ofNat 8 n } }
Instances For
@[reducible, inline]
Equations
Instances For
@[reducible, inline]
Equations
Instances For
Equations
- instToStringInt8 = { toString := fun (i : Int8) => toString i.toInt }
Equations
- instOfNatInt8 = { ofNat := Int8.ofNat n }
@[extern lean_int8_shift_right]
Equations
- a.shiftRight b = { toUInt8 := { toBitVec := a.toBitVec.sshiftRight' (b.toBitVec.smod 8) } }
Instances For
Equations
- instComplementInt8 = { complement := Int8.complement }
Equations
- instShiftLeftInt8 = { shiftLeft := Int8.shiftLeft }
Equations
- instShiftRightInt8 = { shiftRight := Int8.shiftRight }
@[extern lean_int8_dec_lt]
Equations
- a.decLt b = inferInstanceAs (Decidable (a.toBitVec.slt b.toBitVec = true))
Instances For
@[extern lean_int8_dec_le]
Equations
- a.decLe b = inferInstanceAs (Decidable (a.toBitVec.sle b.toBitVec = true))
Instances For
Equations
- instDecidableLtInt8 a b = a.decLt b
Equations
- instDecidableLeInt8 a b = a.decLe b
@[reducible, inline]
The size of type Int16
, that is, 2^16 = 65536
.
Equations
- Int16.size = 65536
Instances For
@[extern lean_int16_of_int]
Equations
- Int16.ofInt i = { toUInt16 := { toBitVec := BitVec.ofInt 16 i } }
Instances For
@[extern lean_int16_of_nat]
Equations
- Int16.ofNat n = { toUInt16 := { toBitVec := BitVec.ofNat 16 n } }
Instances For
@[reducible, inline]
Equations
Instances For
@[reducible, inline]
Equations
Instances For
@[extern lean_int16_to_int8]
Equations
- a.toInt8 = { toUInt8 := { toBitVec := BitVec.signExtend 8 a.toBitVec } }
Instances For
@[extern lean_int8_to_int16]
Equations
- a.toInt16 = { toUInt16 := { toBitVec := BitVec.signExtend 16 a.toBitVec } }
Instances For
Equations
- instToStringInt16 = { toString := fun (i : Int16) => toString i.toInt }
Equations
- instOfNatInt16 = { ofNat := Int16.ofNat n }
@[extern lean_int16_shift_right]
Equations
- a.shiftRight b = { toUInt16 := { toBitVec := a.toBitVec.sshiftRight' (b.toBitVec.smod 16) } }
Instances For
Equations
- instComplementInt16 = { complement := Int16.complement }
Equations
- instShiftLeftInt16 = { shiftLeft := Int16.shiftLeft }
Equations
- instShiftRightInt16 = { shiftRight := Int16.shiftRight }
@[extern lean_int16_dec_lt]
Equations
- a.decLt b = inferInstanceAs (Decidable (a.toBitVec.slt b.toBitVec = true))
Instances For
@[extern lean_int16_dec_le]
Equations
- a.decLe b = inferInstanceAs (Decidable (a.toBitVec.sle b.toBitVec = true))
Instances For
Equations
- instDecidableLtInt16 a b = a.decLt b
Equations
- instDecidableLeInt16 a b = a.decLe b
@[reducible, inline]
The size of type Int32
, that is, 2^32 = 4294967296
.
Equations
- Int32.size = 4294967296
Instances For
@[extern lean_int32_of_int]
Equations
- Int32.ofInt i = { toUInt32 := { toBitVec := BitVec.ofInt 32 i } }
Instances For
@[extern lean_int32_of_nat]
Equations
- Int32.ofNat n = { toUInt32 := { toBitVec := BitVec.ofNat 32 n } }
Instances For
@[reducible, inline]
Equations
Instances For
@[reducible, inline]
Equations
Instances For
@[extern lean_int32_to_int8]
Equations
- a.toInt8 = { toUInt8 := { toBitVec := BitVec.signExtend 8 a.toBitVec } }
Instances For
@[extern lean_int32_to_int16]
Equations
- a.toInt16 = { toUInt16 := { toBitVec := BitVec.signExtend 16 a.toBitVec } }
Instances For
@[extern lean_int8_to_int32]
Equations
- a.toInt32 = { toUInt32 := { toBitVec := BitVec.signExtend 32 a.toBitVec } }
Instances For
@[extern lean_int16_to_int32]
Equations
- a.toInt32 = { toUInt32 := { toBitVec := BitVec.signExtend 32 a.toBitVec } }
Instances For
Equations
- instToStringInt32 = { toString := fun (i : Int32) => toString i.toInt }
Equations
- instOfNatInt32 = { ofNat := Int32.ofNat n }
@[extern lean_int32_shift_right]
Equations
- a.shiftRight b = { toUInt32 := { toBitVec := a.toBitVec.sshiftRight' (b.toBitVec.smod 32) } }
Instances For
Equations
- instComplementInt32 = { complement := Int32.complement }
Equations
- instShiftLeftInt32 = { shiftLeft := Int32.shiftLeft }
Equations
- instShiftRightInt32 = { shiftRight := Int32.shiftRight }
@[extern lean_int32_dec_lt]
Equations
- a.decLt b = inferInstanceAs (Decidable (a.toBitVec.slt b.toBitVec = true))
Instances For
@[extern lean_int32_dec_le]
Equations
- a.decLe b = inferInstanceAs (Decidable (a.toBitVec.sle b.toBitVec = true))
Instances For
Equations
- instDecidableLtInt32 a b = a.decLt b
Equations
- instDecidableLeInt32 a b = a.decLe b
@[reducible, inline]
The size of type Int64
, that is, 2^64 = 18446744073709551616
.
Equations
- Int64.size = 18446744073709551616
Instances For
@[extern lean_int64_of_int]
Equations
- Int64.ofInt i = { toUInt64 := { toBitVec := BitVec.ofInt 64 i } }
Instances For
@[extern lean_int64_of_nat]
Equations
- Int64.ofNat n = { toUInt64 := { toBitVec := BitVec.ofNat 64 n } }
Instances For
@[reducible, inline]
Equations
Instances For
@[reducible, inline]
Equations
Instances For
@[extern lean_int64_to_int8]
Equations
- a.toInt8 = { toUInt8 := { toBitVec := BitVec.signExtend 8 a.toBitVec } }
Instances For
@[extern lean_int64_to_int16]
Equations
- a.toInt16 = { toUInt16 := { toBitVec := BitVec.signExtend 16 a.toBitVec } }
Instances For
@[extern lean_int64_to_int32]
Equations
- a.toInt32 = { toUInt32 := { toBitVec := BitVec.signExtend 32 a.toBitVec } }
Instances For
@[extern lean_int8_to_int64]
Equations
- a.toInt64 = { toUInt64 := { toBitVec := BitVec.signExtend 64 a.toBitVec } }
Instances For
@[extern lean_int16_to_int64]
Equations
- a.toInt64 = { toUInt64 := { toBitVec := BitVec.signExtend 64 a.toBitVec } }
Instances For
@[extern lean_int32_to_int64]
Equations
- a.toInt64 = { toUInt64 := { toBitVec := BitVec.signExtend 64 a.toBitVec } }
Instances For
Equations
- instToStringInt64 = { toString := fun (i : Int64) => toString i.toInt }
Equations
- instOfNatInt64 = { ofNat := Int64.ofNat n }
@[extern lean_int64_shift_right]
Equations
- a.shiftRight b = { toUInt64 := { toBitVec := a.toBitVec.sshiftRight' (b.toBitVec.smod 64) } }
Instances For
Equations
- instComplementInt64 = { complement := Int64.complement }
Equations
- instShiftLeftInt64 = { shiftLeft := Int64.shiftLeft }
Equations
- instShiftRightInt64 = { shiftRight := Int64.shiftRight }
@[extern lean_int64_dec_lt]
Equations
- a.decLt b = inferInstanceAs (Decidable (a.toBitVec.slt b.toBitVec = true))
Instances For
@[extern lean_int64_dec_le]
Equations
- a.decLe b = inferInstanceAs (Decidable (a.toBitVec.sle b.toBitVec = true))
Instances For
Equations
- instDecidableLtInt64 a b = a.decLt b
Equations
- instDecidableLeInt64 a b = a.decLe b
@[reducible, inline]
The size of type ISize
, that is, 2^System.Platform.numBits
.
Equations
Instances For
@[extern lean_isize_of_int]
Equations
- ISize.ofInt i = { toUSize := { toBitVec := BitVec.ofInt System.Platform.numBits i } }
Instances For
@[extern lean_isize_of_nat]
Equations
- ISize.ofNat n = { toUSize := { toBitVec := BitVec.ofNat System.Platform.numBits n } }
Instances For
@[reducible, inline]
Equations
Instances For
@[reducible, inline]
Equations
Instances For
@[extern lean_isize_to_int32]
Equations
- a.toInt32 = { toUInt32 := { toBitVec := BitVec.signExtend 32 a.toBitVec } }
Instances For
@[extern lean_int32_to_isize]
Upcast Int32
to ISize
. This function is losless as ISize
is either Int32
or Int64
.
Equations
- a.toISize = { toUSize := { toBitVec := BitVec.signExtend System.Platform.numBits a.toBitVec } }
Instances For
@[extern lean_int64_to_isize]
Equations
- a.toISize = { toUSize := { toBitVec := BitVec.signExtend System.Platform.numBits a.toBitVec } }
Instances For
Equations
- instToStringISize = { toString := fun (i : ISize) => toString i.toInt }
Equations
- instOfNatISize = { ofNat := ISize.ofNat n }
@[extern lean_isize_shift_left]
Equations
- a.shiftLeft b = { toUSize := { toBitVec := a.toBitVec <<< b.toBitVec.smod ↑System.Platform.numBits } }
Instances For
@[extern lean_isize_shift_right]
Equations
- a.shiftRight b = { toUSize := { toBitVec := a.toBitVec.sshiftRight' (b.toBitVec.smod ↑System.Platform.numBits) } }
Instances For
Equations
- instComplementISize = { complement := ISize.complement }
Equations
- instShiftLeftISize = { shiftLeft := ISize.shiftLeft }
Equations
- instShiftRightISize = { shiftRight := ISize.shiftRight }
@[extern lean_isize_dec_lt]
Equations
- a.decLt b = inferInstanceAs (Decidable (a.toBitVec.slt b.toBitVec = true))
Instances For
@[extern lean_isize_dec_le]
Equations
- a.decLe b = inferInstanceAs (Decidable (a.toBitVec.sle b.toBitVec = true))
Instances For
Equations
- instDecidableLtISize a b = a.decLt b
Equations
- instDecidableLeISize a b = a.decLe b