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 : ∀ c ∈ whole ++ fraction, ∃ (digit : ℕ), digitValue? c = some digit) (htail : ∀ c ∈ tail.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 decimal scanner.

theorem FloatLib.Numerics.DecimalText.parseMagnitude_fractionalCharacters (coefficient places : ℕ) (tail : List Char) (exponent : ℤ) (htail : ∀ c ∈ tail.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 : ∀ c ∈ tail.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 text parses back to fixedRepresentation, which absorbs a positive exponent.

fixedRepresentation is the record itself when the exponent is not positive.

Fixed text of a decimal with a nonpositive exponent parses back to the same 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.

Removing trailing zeros with any amount of fuel preserves the exact rational value.

@[simp]

Removing trailing zeros preserves the exact rational value.

Moving trailing zeros into the exponent with any amount of fuel preserves the value.

Moving trailing zeros into the exponent with any amount of fuel preserves the sign.

@[simp]

Moving trailing zeros into the exponent preserves the exact rational value.

@[simp]

Moving trailing zeros into the exponent preserves the sign, including the sign of zero.

@[simp]

Compact dyadic text parses back to the dyadic's rational value.