TorchLean API

NN.Floats.IEEEExec.DirectedRoundingSoundness.SignedOps

Signed directed-rounding soundness.

The lemmas in this file handle sign-sensitive arithmetic cases for lower and upper IEEE32 rounding, connecting executable operations to real-valued enclosure statements.

toEReal respects negation on the finite/dyadic branch.

We phrase this lemma using the dyadic decode witness toDyadic? x = some d, which guarantees:

  • x is finite (hence toEReal agrees with toReal), and
  • toReal (neg x) = -toReal x (via toReal_neg_eq_neg).

Negation / sign-bit flip helpers #

Negation preserves “not NaN” #

If x is not a NaN then neg x is not a NaN.

We only state the direction we actually need in the directed-rounding development: negative directed rounding is implemented as neg of a positive kernel, so we need to know this cannot introduce a NaN when starting from a non-NaN value.

toEReal commutes with neg as long as we are not in the NaN case.

This is a small but important glue lemma: it lets us lift the positive rounding kernels to the signed directed-rounding functions (roundDyadicDown / roundDyadicUp) without introducing new floating-point corner cases.

Soundness of roundDyadicDown: the result is ≤ the exact dyadic real value (in EReal).

This is the key lemma needed to justify addDown/mulDown as interval lower endpoints.

roundDyadicPosDown (directed rounding toward -∞ for positive dyadics) never produces a NaN/Inf value.

We package this as an existence statement: the output always has a dyadic decode. This is the bridge we use later to turn toEReal into toReal (as an EReal) without unfolding all bit-level definitions at call sites.

Soundness of roundDyadicDown: it produces an EReal lower bound for the exact dyadic value.

Informal: rounding down is monotone towards -∞, so the rounded result is always the exact real meaning.

Soundness of roundDyadicUp: the result is ≥ the exact dyadic real value (in EReal).

This is the key lemma needed to justify addUp/mulUp as interval upper endpoints.

Lower-endpoint soundness for addDown on finite inputs: the result is ≤ the exact real sum (in EReal), even in overflow-to--∞ scenarios.

Upper-endpoint soundness for addUp on finite inputs: the exact real sum is ≤ the result (in EReal), with overflow rounding to +∞.

Lower-endpoint soundness for mulDown on finite inputs.

Upper-endpoint soundness for mulUp on finite inputs.