TorchLean API

FloatLib.Kernels.FixedWord.Difference.Proof

Verified fixed-limb differences #

These helpers compare, subtract, normalize, and shift two-word unsigned values without converting the executable path to Nat. Their theorems expose the corresponding mathematical values for format-specific subtraction proofs.

@[simp]

Native two-word comparison agrees with comparison of mathematical values.

@[simp]

Native three-way comparison agrees with comparison of mathematical values.

Ordered two-word subtraction agrees with natural-number subtraction.

@[simp]

Native two-word leading-bit selection agrees with Nat.log2.

@[simp]
theorem FloatLib.Numerics.FixedWord.UInt128.shiftRight_toNat (value : UInt128) (shift : ) :
(value.shiftRight shift).toNat = value.toNat / 2 ^ shift

The total native two-word right shift is exact division by a power of two.

theorem FloatLib.Numerics.FixedWord.UInt128.singleBit_toNat_of_lt (index : ) (hindex : index < 128) :
(singleBit index).toNat = 2 ^ index

A bounded native one-hot value represents the corresponding power of two.

theorem FloatLib.Numerics.FixedWord.UInt128.shiftLeft_toNat (value : UInt128) (shift : ) (hshift : shift < 128) (hfit : value.toNat <<< shift < 2 ^ 128) :
(value.shiftLeft shift).toNat = value.toNat <<< shift

A bounded native two-word left shift has its exact mathematical value.

theorem FloatLib.Numerics.FixedWord.UInt128.shiftLeft_of_ge (value : UInt128) (shift : ) (hshift : 128 shift) :
value.shiftLeft shift = { hi := 0, lo := 0 }

Shifting a two-word value left by at least the carrier width returns zero.