TorchLean API

FloatLib.Floats.Formats.BinaryInterchange.DirectedSemantics.Finite

Finite-operand helpers for directed arithmetic #

Finite-operand classification facts support the format-generic directed arithmetic proofs. Keeping these facts separate lets each arithmetic module focus on its exact intermediate and rounding argument.

Unary NaN selection is inactive for a finite operand.

NaN selection is inactive when both operands are finite.

A finite nonzero value decodes to a dyadic with nonzero significand.

Exact intermediates of finite operands #

The exact dyadic sum of two finite values denotes their real sum.

theorem FloatLib.Floats.Formats.BinaryInterchange.Model.toReal_mulDyadic_of_toDyadic?_some {fmt : FloatFormat} {x y : Model fmt} {dx dy : Numerics.Dyadic} (hdx : x.toDyadic? = some dx) (hdy : y.toDyadic? = some dy) :
{ negative := dx.negative ^^ dy.negative, significand := dx.significand * dy.significand, exponent := dx.exponent + dy.exponent }.toReal = x.toReal * y.toReal

The exact dyadic product of two finite values denotes their real product.

Signed zero of an exactly cancelling sum #

@[simp]
theorem FloatLib.Floats.Formats.BinaryInterchange.Model.toReal_zeroForExactSum (fmt : FloatFormat) (mode : IEEERoundingMode) (leftSign rightSign : Bool) :
(zeroForExactSum fmt mode leftSign rightSign).toReal = 0

The signed zero chosen for an exactly cancelling sum denotes zero.

@[simp]

The signed zero chosen for an exactly cancelling sum is not a NaN.

@[simp]
theorem FloatLib.Floats.Formats.BinaryInterchange.Model.toEReal_zeroForExactSum (fmt : FloatFormat) (mode : IEEERoundingMode) (leftSign rightSign : Bool) :
(zeroForExactSum fmt mode leftSign rightSign).toEReal = 0

The signed zero chosen for an exactly cancelling sum denotes zero in the extended reals.

Directed operations on finite operands #

For modes other than nearest-even, finite addition and multiplication reduce to rounding an exact dyadic intermediate; finite division with a nonzero divisor rounds an exact scaled rational. Exact cancellation has a separate signed-zero rule. Square root instead rounds the appropriate endpoint of a dyadic bracket around the exact root. These characterisations are shared by the enclosure, non-NaN, and finite-format proofs.

For finite operands, a directed addition is the directed rounding of the exact dyadic sum, or the rounding direction's signed zero when the sum cancels exactly.

For finite operands, a directed multiplication rounds the exact dyadic product.

For a finite dividend and a finite nonzero divisor, a directed division rounds the exact scaled rational quotient.

Every directed square root fixes a finite zero.

On a finite positive operand, sqrtDown rounds the lower square-root bracket downward.

On a finite positive operand, sqrtUp rounds the upper square-root bracket upward.