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: $\operatorname{toEReal}(\operatorname{roundDyadicDown}(d)) \leq\operatorname{dyadicToReal}(d)$.

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: $\operatorname{dyadicToReal}(d) \leq\operatorname{toEReal}(\operatorname{roundDyadicUp}(d))$.

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

Lower-endpoint soundness for addDown on finite inputs: $\operatorname{toEReal}(\operatorname{addDown}(x,y)) \leq\operatorname{toReal}(x)+\operatorname{toReal}(y)$, even when the result overflows to $-\infty$.

Upper-endpoint soundness for addUp on finite inputs: $\operatorname{toReal}(x)+\operatorname{toReal}(y) \leq\operatorname{toEReal}(\operatorname{addUp}(x,y))$, with overflow rounding to $+\infty$.

Lower-endpoint soundness for mulDown on finite inputs.

Upper-endpoint soundness for mulUp on finite inputs.

Fused multiply-add #

fmaDown is a lower bound for exact fused multiply-add on finite inputs.

fmaUp is an upper bound for exact fused multiply-add on finite inputs.

Square root #

The dyadic endpoints computed by sqrtDyadicBracket enclose the exact square root.

sqrtDown encloses the exact square root from below on finite nonnegative inputs.

sqrtUp encloses the exact square root from above on finite nonnegative inputs.