TorchLean API

FloatLib.Floats.Formats.DecimalInterchange.Conversion.Posit.Proof

Posit and decimal conversion semantics #

Decimal destinations inherit the shared projection's validity, error and directed enclosure guarantees. Posit destinations equal the standard signed real-rounding specification for every finite decimal input, including saturation and nonzero underflow. No intermediate binary format is involved.

A finite posit is converted by decimal projection of its exact rational value.

Every posit conversion produces a valid destination datum.

Posit zero becomes positive decimal zero, with preferred quantum zero clamped to the destination quantum range.

@[simp]

When quantum zero is available, posit zero converts to positive decimal zero there.

@[simp]

NaR becomes a quiet, zero-payload decimal NaN, with no IEEE exception raised.

A nonoverflowing nearest decimal conversion has at most half a grid unit of error.

theorem FloatLib.Floats.Formats.DecimalInterchange.Conversion.fromPosit_error_lt_one {fmt : Posit.Format} (f : Format) (mode : RoundingMode) (x : Posit.Model fmt) {a : } (hx : x.toRat? = some a) (hfinite : (fromPosit f mode x).status.overflow = false) :
∃ (value : ), (fromPosit f mode x).value.toRat? = some value |value - a| < 10 ^ roundingQuantum f |a|

In any rounding direction a nonoverflowing conversion changes the value by less than one decimal grid unit.

Upward posit-to-decimal conversion encloses the exact posit value.

Downward posit-to-decimal conversion encloses the exact posit value.

theorem FloatLib.Floats.Formats.DecimalInterchange.Conversion.fromPosit_inexact_iff {fmt : Posit.Format} (f : Format) (mode : RoundingMode) (x : Posit.Model fmt) {a value : } (hx : x.toRat? = some a) (hfinite : (fromPosit f mode x).status.overflow = false) (hout : (fromPosit f mode x).value.toRat? = some value) :
(fromPosit f mode x).status.inexact = true value a

Without overflow, inexact is exactly a changed rational value.

Decimal underflow is precisely an inexact tiny input when overflow is absent.

@[simp]

Decimal NaNs, whether signaling or quiet, convert to NaR.

@[simp]

Either signed decimal infinity converts to NaR.

@[simp]

Both decimal zero signs and every zero cohort convert to the unique posit zero.

Every finite decimal datum has exact single-rounding posit semantics. This includes range saturation and the standard nonzero-underflow rule without additional hypotheses.

Changing a decimal cohort does not change its posit conversion.