Documentation

Init.Data.UInt.BasicAux

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.

def UInt8.val (x : UInt8) :
Equations
  • x.val = x.toBitVec.toFin
@[extern lean_uint8_of_nat]
def UInt8.ofNat (n : Nat) :
Equations
@[reducible, inline]
abbrev Nat.toUInt8 (n : Nat) :
Equations
@[extern lean_uint8_to_nat]
def UInt8.toNat (n : UInt8) :
Equations
  • n.toNat = n.toBitVec.toNat
instance UInt8.instOfNat {n : Nat} :
Equations
Equations
  • x.val = x.toBitVec.toFin
@[extern lean_uint16_of_nat]
Equations
@[reducible, inline]
abbrev Nat.toUInt16 (n : Nat) :
Equations
@[extern lean_uint16_to_nat]
Equations
  • n.toNat = n.toBitVec.toNat
@[extern lean_uint16_to_uint8]
Equations
  • a.toUInt8 = a.toNat.toUInt8
@[extern lean_uint8_to_uint16]
Equations
  • a.toUInt16 = { toBitVec := { toFin := a.toNat, } }
instance UInt16.instOfNat {n : Nat} :
Equations
Equations
  • x.val = x.toBitVec.toFin
@[extern lean_uint32_of_nat]
Equations
@[extern lean_uint32_of_nat]
def UInt32.ofNat' (n : Nat) (h : n < size) :
Equations

Converts the given natural number to UInt32, but returns 2^32 - 1 for natural numbers >= 2^32.

Equations
@[reducible, inline]
abbrev Nat.toUInt32 (n : Nat) :
Equations
@[extern lean_uint32_to_uint8]
Equations
  • a.toUInt8 = a.toNat.toUInt8
@[extern lean_uint32_to_uint16]
Equations
  • a.toUInt16 = a.toNat.toUInt16
@[extern lean_uint8_to_uint32]
Equations
  • a.toUInt32 = { toBitVec := { toFin := a.toNat, } }
@[extern lean_uint16_to_uint32]
Equations
  • a.toUInt32 = { toBitVec := { toFin := a.toNat, } }
instance UInt32.instOfNat {n : Nat} :
Equations
theorem UInt32.ofNat'_lt_of_lt {n m : Nat} (h1 : n < size) (h2 : m < size) :
n < mofNat' n h1 < ofNat m
theorem UInt32.lt_ofNat'_of_lt {n m : Nat} (h1 : n < size) (h2 : m < size) :
m < nofNat m < ofNat' n h1
Equations
  • x.val = x.toBitVec.toFin
@[extern lean_uint64_of_nat]
Equations
@[reducible, inline]
abbrev Nat.toUInt64 (n : Nat) :
Equations
@[extern lean_uint64_to_nat]
Equations
  • n.toNat = n.toBitVec.toNat
@[extern lean_uint64_to_uint8]
Equations
  • a.toUInt8 = a.toNat.toUInt8
@[extern lean_uint64_to_uint16]
Equations
  • a.toUInt16 = a.toNat.toUInt16
@[extern lean_uint64_to_uint32]
Equations
  • a.toUInt32 = a.toNat.toUInt32
@[extern lean_uint8_to_uint64]
Equations
  • a.toUInt64 = { toBitVec := { toFin := a.toNat, } }
@[extern lean_uint16_to_uint64]
Equations
  • a.toUInt64 = { toBitVec := { toFin := a.toNat, } }
@[extern lean_uint32_to_uint64]
Equations
  • a.toUInt64 = { toBitVec := { toFin := a.toNat, } }
instance UInt64.instOfNat {n : Nat} :
Equations
@[deprecated usize_size_pos (since := "2024-11-24")]
def USize.val (x : USize) :
Equations
  • x.val = x.toBitVec.toFin
@[extern lean_usize_of_nat]
def USize.ofNat (n : Nat) :
Equations
@[reducible, inline]
abbrev Nat.toUSize (n : Nat) :
Equations
@[extern lean_usize_to_nat]
def USize.toNat (n : USize) :
Equations
  • n.toNat = n.toBitVec.toNat
@[extern lean_usize_add]
def USize.add (a b : USize) :
Equations
  • a.add b = { toBitVec := a.toBitVec + b.toBitVec }
@[extern lean_usize_sub]
def USize.sub (a b : USize) :
Equations
  • a.sub b = { toBitVec := a.toBitVec - b.toBitVec }
def USize.lt (a b : USize) :
Equations
  • a.lt b = (a.toBitVec < b.toBitVec)
def USize.le (a b : USize) :
Equations
  • a.le b = (a.toBitVec b.toBitVec)
instance USize.instOfNat {n : Nat} :
Equations
Equations
Equations
instance instLTUSize :
Equations
instance instLEUSize :
Equations
@[extern lean_usize_dec_lt]
def USize.decLt (a b : USize) :
Decidable (a < b)
Equations
@[extern lean_usize_dec_le]
def USize.decLe (a b : USize) :
Equations
instance instDecidableLtUSize (a b : USize) :
Decidable (a < b)
Equations
instance instDecidableLeUSize (a b : USize) :
Equations