TorchLean API

FloatLib.Numerics.Exact.DecimalText.Proof

Decimal character preservation #

The digit scanner recovers the base-ten positional value of every digit list. This connects actual character strings to exact rationals, rather than assuming an abstract parser/formatter inverse. The dyadic conversion then preserves value by the identity 10^k = 2^k * 5^k.

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

Printing any decimal digit and reading it recovers that digit.

theorem FloatLib.Numerics.DecimalText.digitValue?_mem_naturalDigits {value : } {character : Char} (hcharacter : character RadixText.naturalDigits value 10) :
digit < 10, digitValue? character = some digit

Every character printed for a natural is an ASCII decimal digit.

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

Decimal printing followed by scanning recovers any natural, without a width bound.

@[simp]

A printed natural is consumed completely.

A printed natural cannot be mistaken for a leading sign.

@[simp]

A printed natural alone has no leading sign.

@[simp]

Integral exponent printing preserves every integer, including negative exponents.

theorem FloatLib.Numerics.DecimalText.parseMagnitude_decimal (significand : ) (exponent : ) :
RadixText.parseMagnitude (RadixText.naturalDigits significand 10 ++ if exponent = 0 then [] else 'e' :: integerDigits exponent) 10 digitValue? parseExponent 1 = some (significand, exponent)

Parsing the printed magnitude recovers its significand and decimal exponent.

@[simp]

Parsing an actual printed decimal character list recovers the complete decimal record.

@[simp]

Printing and parsing preserves the exact rational denoted by every decimal record.

@[simp]

Conversion to decimal preserves the exact rational meaning of every dyadic.

@[simp]

The complete dyadic-to-decimal string conversion has exact rational value preservation.