TorchLean API

FloatLib.Floats.Formats.FixedPoint.Bounded.Configured.Conversion.Proof

Bounded fixed-point conversion proofs #

The fixed-integer codec theorems connect each conversion policy to its signed coefficient: checked conversion preserves an in-range coefficient, wrapping takes centered reduction, and saturation clamps to the signed range. These relations retain the complete outcome and status.

theorem FloatLib.Floats.ExecFloat.BoundedFixedPoint.Conversion.coefficient_ofRatWrapping {radix : Numerics.Radix} {fractionalDigits width : } (exact : ) :
(ofRatWrapping exact).coefficient = (Numerics.roundRatEven (exact * (Formats.FixedPoint.scale radix fractionalDigits))).bmod (2 ^ width)

Wrapping delivers the centered remainder of the nearest-even coefficient.

An in-range coefficient is preserved, including the sole zero-width coefficient.

Saturating conversion delivers the clamped nearest-even coefficient at every width.

@[simp]
theorem FloatLib.Floats.ExecFloat.BoundedFixedPoint.Conversion.run_finite {radix : Numerics.Radix} {fractionalDigits width : } (policy : OverflowPolicy) (exact : ) :

Finite observations are handled by the selected bounded-overflow policy.

@[simp]

Bounded fixed point has no infinity code.

@[simp]

Bounded fixed point has no exceptional code.

The fixed-integer codec laws establish the independent coefficient and range clauses.

The coefficient policy and full status determine a unique complete outcome.

theorem FloatLib.Floats.ExecFloat.BoundedFixedPoint.Conversion.spec_iff_eq_run {radix : Numerics.Radix} {fractionalDigits width : } (policy : OverflowPolicy) (input : Numerics.NumericalValue ) (outcome : ConversionOutcome (BoundedFixedPoint radix fractionalDigits width)) :
spec policy input outcome outcome = run policy input

The independent coefficient contract preserves the converter's complete word and status.

@[simp]

The installed decoder exposes the exact stored rational.

Checked conversion reports outOfRange exactly when the checked constructor fails.