TorchLean API

FloatLib.Floats.ExecFloat.Backends.Generic.ScaleAdd.Proof

Correctness of unsigned-scale exact addition #

For conventional IEEE descriptors, roundSum_eq identifies unsigned-scale alignment and rounding with exact dyadic addition followed by roundDyadic. The proof includes zero operands and the signed-zero result of cancellation. The roundOffset parameter accommodates both addition scales and the product scales used by FMA.

theorem FloatLib.Floats.Formats.BinaryInterchange.Model.FiniteScaleAdd.roundMagnitude_eq (fmt : FloatFormat) (hfmt : fmt.isIEEE = true) (roundOffset : ) (sign : Bool) (mantissa scale : ) :
roundMagnitude fmt roundOffset sign mantissa scale = roundDyadic fmt { negative := sign, significand := mantissa, exponent := exponent fmt scale roundOffset }

Unsigned-scale rounding is the corresponding exact dyadic rounding.

theorem FloatLib.Floats.Formats.BinaryInterchange.Model.FiniteScaleAdd.roundMagnitudes_eq (fmt : FloatFormat) (hfmt : fmt.isIEEE = true) (roundOffset : ) (leftSign rightSign : Bool) (left right scale : ) :
roundMagnitudes fmt roundOffset leftSign rightSign left right scale = roundDyadic fmt (addDyadicMagnitudes leftSign rightSign left right (exponent fmt scale roundOffset))

The signed-magnitude helper rounds the exact dyadic magnitude sum.

theorem FloatLib.Floats.Formats.BinaryInterchange.Model.FiniteScaleAdd.roundSum_eq (fmt : FloatFormat) (hfmt : fmt.isIEEE = true) (roundOffset : ) (leftSign rightSign : Bool) (leftMantissa leftScale rightMantissa rightScale : ) :
roundSum fmt roundOffset leftSign rightSign leftMantissa leftScale rightMantissa rightScale = roundDyadic fmt (addDyadic { negative := leftSign, significand := leftMantissa, exponent := exponent fmt leftScale roundOffset } { negative := rightSign, significand := rightMantissa, exponent := exponent fmt rightScale roundOffset })

roundSum is exactly dyadic addition followed by one IEEE rounding step.