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_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 }
@[extern lean_int8_shift_right]
Equations
- a.shiftRight b = { toUInt8 := { toBitVec := a.toBitVec.sshiftRight' (b.toBitVec.smod 8) } }
Instances For
Equations
- instShiftLeftInt8 = { shiftLeft := Int8.shiftLeft }
@[extern lean_int8_dec_lt]
Equations
- a.decLt b = inferInstanceAs (Decidable (a.toBitVec.slt b.toBitVec = true))
Instances For
Equations
- instDecidableLtInt8 a b = a.decLt b
@[reducible, inline]
The size of type Int16
, that is, 2^16 = 65536
.
Equations
- Int16.size = 65536
Instances For
@[reducible, inline]
Equations
Instances For
@[reducible, inline]
Equations
Instances For
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
- instShiftLeftInt16 = { shiftLeft := Int16.shiftLeft }
@[extern lean_int16_dec_le]
Equations
- a.decLe b = inferInstanceAs (Decidable (a.toBitVec.sle b.toBitVec = true))
Instances For
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
@[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
- 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 }
@[extern lean_int32_dec_lt]
Equations
- a.decLt b = inferInstanceAs (Decidable (a.toBitVec.slt b.toBitVec = true))
Instances For
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
@[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
Equations
- instToStringInt64 = { toString := fun (i : Int64) => toString i.toInt }
Equations
- instDecidableLtInt64 a b = a.decLt b
@[reducible, inline]
The size of type ISize
, that is, 2^System.Platform.numBits
.
Equations
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
@[extern lean_isize_to_int32]
Equations
- a.toInt32 = { toUInt32 := { toBitVec := BitVec.signExtend 32 a.toBitVec } }
Instances For
@[extern lean_int64_to_isize]
Equations
- a.toISize = { toUSize := { toBitVec := BitVec.signExtend System.Platform.numBits a.toBitVec } }
Instances For
Equations
- instOfNatISize = { ofNat := ISize.ofNat n }
@[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 }
@[extern lean_isize_dec_lt]
Equations
- a.decLt b = inferInstanceAs (Decidable (a.toBitVec.slt b.toBitVec = true))