TorchLean API

FloatLib.Floats.ExecFloat.Backends.Word.Narrow.Agreement

Agreement between native binary32 words and the generic model #

The narrow-word core implements finite binary32 arithmetic with UInt32 and UInt64. This module contains the proof-side bridge back to the generic Model FloatFormat.binary32 representation: field packing, decoding, rounding, and the shared finite-operation specifications.

The operation-specific Addition, Multiplication, and Fma proof modules connect their native implementations to the finite specifications used here. Together, these results connect native arithmetic to the generic binary32 model. Runtime clients can import the corresponding Runtime modules without this proof development.

theorem FloatLib.Floats.Formats.BinaryInterchange.Model.NativeBinary32.toUInt32_ofFields (sign : Bool) (exponent fraction : ) :
toUInt32 (ofFields FloatFormat.binary32 sign exponent fraction) = mkBits sign exponent fraction

Native and generic binary32 field packing produce the same storage word.

theorem FloatLib.Floats.Formats.BinaryInterchange.Model.NativeBinary32.ofUInt32_mkBits (sign : Bool) (exponent fraction : ) :
ofUInt32 (mkBits sign exponent fraction) = ofFields FloatFormat.binary32 sign exponent fraction

Rewrapping native field packing equals generic Model.ofFields.

Native and generic binary32 exponent extraction have the same natural-number value.

Native and generic binary32 fraction extraction have the same natural-number value.

Native and generic binary32 sign extraction agree.

Native and generic binary32 exponent zero tests agree.

Native and generic binary32 exceptional-exponent tests agree.

Native and generic binary32 fraction zero tests agree.

Native field extraction decodes the same exact dyadic as generic binary32.

Native rational rounding agrees with generic binary32 rational rounding.

The native finite add result is exactly the generic finite add result.

The native finite multiply result is exactly the generic finite multiply result.

theorem FloatLib.Floats.Formats.BinaryInterchange.Model.NativeBinary32.fmaFinite_eq (x y z : Value) :
fmaFinite? x y z = match Model.toDyadic? x, Model.toDyadic? y, Model.toDyadic? z with | some dx, some dy, some dz => have product := { negative := dx.negative ^^ dy.negative, significand := dx.significand * dy.significand, exponent := dx.exponent + dy.exponent }; some (Model.roundDyadic FloatFormat.binary32 (addDyadic product dz)) | x, x_1, x_2 => none

The native finite fused multiply-add result is exactly the generic finite result.