TorchLean API

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

Exact fixed-point conversion proofs #

The conversion contract exposes nearest-even coefficient selection, its half-unit error bound, and the parity of a tie. The complete code and status remain uniquely determined.

@[simp]
theorem FloatLib.Floats.ExecFloat.FixedPoint.Conversion.run_finite {radix : Numerics.Radix} {fractionalDigits : } (exact : ) :
run () (Numerics.NumericalValue.finite exact) = have rounded := roundRat exact; ConversionOutcome.success rounded { inexact := rounded.toRat != exact }

Finite rationals are rounded once to the destination's fixed grid.

Integer rounding supplies the coefficient bound and tie rule in the conversion contract.

theorem FloatLib.Floats.ExecFloat.FixedPoint.Conversion.spec_iff_eq_run {radix : Numerics.Radix} {fractionalDigits : } (context : Unit) (input : Numerics.NumericalValue ) (outcome : ConversionOutcome (FixedPoint radix fractionalDigits)) :
spec context input outcome outcome = run context input

The coefficient and status clauses determine the original complete conversion outcome.

theorem FloatLib.Floats.ExecFloat.FixedPoint.Conversion.coefficient_nearest_of_spec {radix : Numerics.Radix} {fractionalDigits : } (exact : ) (rounded : FixedPoint radix fractionalDigits) (indicators : ConversionStatus) (h : spec () (Numerics.NumericalValue.finite exact) (ConversionOutcome.success rounded indicators)) (candidate : ) :
|rounded.coefficient - exact * (scale radix fractionalDigits)| |candidate - exact * (scale radix fractionalDigits)|

Every admitted finite result is at least as close as every competing grid coefficient.

@[simp]

The installed decoder exposes the exact stored rational.

@[simp]

Infinity is rejected because an exact fixed-point grid has no infinite code.

@[simp]

Exceptional observations are rejected because exact fixed point has no reserved code.