TorchLean API

FloatLib.Floats.Formats.IEEE754.Native.AddSub

Native addition and subtraction #

These theorems relate FloatLib's addition and subtraction to the logical floating-point model shipped with Lean. Finite inputs include both signed zeros. The result is unrestricted, so cancellation, subnormal rounding and overflow to infinity are covered, and the equations hold on the complete packed word through the native adapters.

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

For finite operands, including signed zeros, dispatched addition gives the word that Lean's unpacked model gets by adding and packing. 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 import adapter on finite inputs.

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

Native binary64 addition commutes with the import adapter on 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.