TorchLean API

FloatLib.Floats.Formats.BinaryInterchange.DirectedSemantics.Basic

Basic lemmas for format-parameterized directed rounding #

Shared arithmetic facts support both directed dyadic and rational rounding proofs. Further lemmas give closed forms for the smallest positive subnormal and a strict power-of-two bound for the largest finite value. All statements are uniform in FloatFormat.

Increasing a natural exponent by one does not decrease its power of two.

Natural powers of two are positive.

Natural powers of two grow strictly with the exponent.

theorem FloatLib.Floats.Formats.BinaryInterchange.Model.pow2_add (left right : ) :
pow2 (left + right) = pow2 left * pow2 right

Split a natural power of two across an exponent sum.

theorem FloatLib.Floats.Formats.BinaryInterchange.Model.pow2_mul (left right : ) :
pow2 left * pow2 right = pow2 (left + right)

Multiplicative form of pow2_add.

Floor and ceiling shifts #

Shifting right and restoring the removed power of two cannot exceed the original number.

A ceiling right shift, followed by restoration of its scale, covers the original number.

A ceiling shift is at most one larger than the corresponding floor shift.

A floor right shift never exceeds the corresponding ceiling right shift.

The leading power of two does not exceed a nonzero natural number.

A nonzero natural number is below the next power after its leading bit.

Format constants #

The subnormal grid starts strictly below the smallest normal exponent.

The subnormal exponent plus the explicit fraction width is the minimum normal exponent.

The smallest positive subnormal is explicit field packing with fraction one.

@[simp]

The smallest positive subnormal denotes one unit at the minimum subnormal exponent.

Closed form for the largest finite positive value of an arbitrary format.

theorem FloatLib.Floats.Formats.BinaryInterchange.Model.abs_signed_mul_bpow_le_toReal_posMaxFinite (fmt : FloatFormat) (sign : Bool) (mantissa : ) (exponent : ) (hmantissa : mantissa pow2 fmt.fracWidth + fmt.maxFiniteFracField) (hexponent : exponent fmt.maxNormalExponent - Int.ofNat fmt.fracWidth) :
|(if sign = true then -1 else 1) * mantissa * bpow exponent| (posMaxFinite fmt).toReal

A signed magnitude whose mantissa and exponent do not exceed those of the largest finite value is bounded by that value.

Every finite IEEE value lies between the two largest-finite endpoints.

The finiteness hypothesis excludes infinities and NaNs; the bound follows from the descriptor's exponent and fraction fields.

The largest finite value is strictly below the next normal power of two.