TorchLean API

FloatLib.Numerics.Exact.HexText.Proof

Hexadecimal character preservation #

The shared positional scanner recovers the printed hexadecimal coefficient; the decimal integer scanner recovers the binary exponent. The result preserves the entire dyadic record, including the sign of zero.

@[simp]
theorem FloatLib.Numerics.HexText.digitValue?_digitChar {digit : } (hdigit : digit < 16) :

A printed hexadecimal digit decodes to its original value.

theorem FloatLib.Numerics.HexText.scanDigits_naturalDigits (value : ) (tail : List Char) (htail : charactertail.head?, digitValue? character = none) :

Scanning a printed hexadecimal coefficient recovers the coefficient and its suffix.

The complete hexadecimal magnitude, including its mandatory exponent, parses exactly.

@[simp]

Reading the printed characters preserves every dyadic field, with no width assumption.

@[simp]

Exact hexadecimal string output and input preserve the full dyadic representation.

theorem FloatLib.Numerics.HexText.sixteen_zpow (exponent : ) :
16 ^ exponent = 2 ^ (4 * exponent)

A hexadecimal power is a binary power at four times the exponent.

theorem FloatLib.Numerics.HexText.radixPair_value (value : Dyadic) :
(radixPair value).1 * 16 ^ (radixPair value).2 = value.significand * 2 ^ value.exponent

Moving a dyadic to a hexadecimal grid does not change its magnitude.

@[simp]
theorem FloatLib.Numerics.HexText.significant_negative (roundMagnitude : Bool) (value : Dyadic) (digits : ℕ+) :
(significant roundMagnitude value digits).negative = value.negative

Hexadecimal precision output preserves the sign, even if the coefficient is zero.

theorem FloatLib.Numerics.HexText.significant_value (roundMagnitude : Bool) (value : Dyadic) (digits : ℕ+) :
(significant roundMagnitude value digits).toRat = (if value.negative = true then -1 else 1) * (RadixText.roundCoefficient 16 roundMagnitude value.negative (radixPair value).1 (radixPair value).2 (RadixText.significantQuantum 16 (radixPair value).1 (radixPair value).2 digits)) * 16 ^ RadixText.significantQuantum 16 (radixPair value).1 (radixPair value).2 digits

The hexadecimal output value is one integer rounding on the requested hexadecimal grid.

theorem FloatLib.Numerics.HexText.significant_exact (roundMagnitude : Bool) (hexact : ∀ (sign : Bool) (n : ), roundMagnitude sign n = n) (value : Dyadic) (digits : ℕ+) (hc : (radixPair value).1 < 16 ^ digits) :
(significant roundMagnitude value digits).toRat = value.toRat

Enough requested hexadecimal digits preserve the exact value in every integer-exact rounder.