TorchLean API

FloatLib.Numerics.Exact.DecimalText.NotationProof

Preservation laws for fixed and scientific decimal notation #

Point insertion preserves the positional coefficient. Leading fractional padding does not change that coefficient, and the scanner counts the padding when recovering the decimal scale.

theorem FloatLib.Numerics.DecimalText.parseMagnitude_pointCharacters (whole fraction tail : List Char) (exponent : ) (hwhole : whole []) (hdigits : cwhole ++ fraction, ∃ (digit : ), digitValue? c = some digit) (htail : ctail.head?, digitValue? c = none) (hexponent : parseExponent tail = some exponent) :
RadixText.parseMagnitude (pointCharacters whole fraction ++ tail) 10 digitValue? parseExponent 1 = some ((RadixText.scanDigits (whole ++ fraction) 0 10 digitValue?).1, exponent - fraction.length)

Inserting a point preserves the coefficient and subtracts the fractional digit count. The suffix may be empty or an exponent accepted by the existing decimal scanner.

theorem FloatLib.Numerics.DecimalText.parseMagnitude_fractionalCharacters (coefficient places : ) (tail : List Char) (exponent : ) (htail : ctail.head?, digitValue? c = none) (hexponent : parseExponent tail = some exponent) :
RadixText.parseMagnitude (fractionalCharacters coefficient places ++ tail) 10 digitValue? parseExponent 1 = some (coefficient, exponent - places)

Fixed fractional digits recover the exact coefficient and the requested decimal scale.

theorem FloatLib.Numerics.DecimalText.parseCharacters_fractionalCharacters (negative : Bool) (coefficient places : ) (tail : List Char) (exponent : ) (htail : ctail.head?, digitValue? c = none) (hexponent : parseExponent tail = some exponent) :
parseCharacters ((if negative = true then ['-'] else []) ++ (fractionalCharacters coefficient places ++ tail)) = some { negative := negative, significand := coefficient, exponent := exponent - places }

Signed fixed fractional text, optionally followed by an exponent, preserves its coefficient.

@[simp]

Fixed notation recovers the coefficient after absorbing any positive exponent.

Fixed notation retains the complete record when its exponent specifies fractional places.

In particular, printing a decimal rounded to exponent -places preserves the exact record.

@[simp]

Absorbing a positive exponent into the coefficient preserves the exact rational value.

@[simp]

Fixed presentation preserves the sign, including the sign of zero.

@[simp]

Fixed formatting followed by parsing preserves the exact rational denoted by the input.

@[simp]

Scientific notation recovers the entire decimal record, including zero sign and precision.

@[simp]

Scientific formatting followed by parsing preserves the exact rational denoted by the input.