TorchLean API

FloatLib.Floats.Formats.IEEE754.Native.AddSub

Native addition and subtraction #

These bridges are checked against the logical floating-point model shipped with Lean 4.34. Finite inputs include both signed zeros. The result is unrestricted: cancellation, subnormal rounding, and overflow to infinity all preserve the complete packed word through the existing native adapters.

The finite-input hypotheses exclude NaNs and infinities. FloatLib preserves NaN details that Lean canonicalizes; subtraction also negates the right operand's NaN sign. These model equalities do not verify the external machine instructions used by compiled native code.

For finite operands, including signed zeros, dispatched addition produces precisely the word obtained by adding and packing in Lean's unpacked model. The result may overflow to infinity.

Negation preserves the complete finite unpacked value, including the sign of zero.

For finite operands, including signed zeros, dispatched subtraction agrees with Lean's unpacked subtraction and packing. There is no restriction on the rounded result.

Native binary32 addition commutes with the existing import adapter for all finite inputs.

Native binary32 subtraction commutes with the import adapter, including signed-zero inputs.

Native binary64 addition commutes with the existing import adapter for all finite inputs.

Native binary64 subtraction commutes with the import adapter, including signed-zero inputs.

Importing the native sum equals adding the imported binary32 operands with the installed certified software operation. Finite inputs may produce zero, a subnormal, or infinity.

Importing a native binary32 difference equals certified software subtraction of the imports.

Importing the native sum equals adding the imported binary64 operands with the installed certified software operation, including cancellation and overflow.

Importing a native binary64 difference equals certified software subtraction of the imports.