TorchLean API

FloatLib.Floats.Formats.DecimalInterchange.Cohort.Proof

Cohort preservation and preferred-exponent bounds #

Removing trailing zeros preserves the exact rational value and sign. The algorithm stops either at its exponent limit or at a coefficient with no trailing zero, so it never discards a significant decimal digit.

Exact integer decomposition, including zero.

The adjusted coefficient never exceeds the original one.

Stopping before the requested quantum means that no further exact decimal shift is possible.

Cohort adjustment preserves the exact coefficient-times-quantum value and sign.

theorem FloatLib.Floats.Formats.DecimalInterchange.preferredCohort_toRat? (f : Format) (s : Bool) (c : ) (q preferred : ) :
(preferredCohort f s c q preferred).toRat? = some ((if s = true then -1 else 1) * c * 10 ^ q)

The selected cohort has exactly the original signed rational value.

theorem FloatLib.Floats.Formats.DecimalInterchange.preferredCohort_valid (f : Format) (s : Bool) (c : ) (q preferred : ) (h : Datum.Valid f (Datum.finite s c q)) :
Datum.Valid f (preferredCohort f s c q preferred)

Cohort adjustment keeps a representable finite datum in the same format.