TorchLean API

FloatLib.Floats.Formats.BinaryInterchange.DirectedSemantics.Positive

Positive directed rounding for arbitrary executable float formats #

The shift-based directed rounders used by Model are related to the independent Flocq-style real semantics at the scaled-mantissa boundary, before subnormal and normal values are packed into interchange fields.

All definitions are uniform in FloatFormat.

Independent directed semantics #

@[reducible, inline]

Round a real downward on the gradual-underflow grid of fmt, before overflow handling.

Instances For
    @[reducible, inline]

    Round a real upward on the gradual-underflow grid of fmt, before overflow handling.

    Instances For

      Executable scaled-mantissa rounding #

      Floor a natural mantissa after expressing it at targetExponent.

      Instances For

        Ceil a natural mantissa after expressing it at targetExponent.

        Instances For
          theorem FloatLib.Floats.Formats.BinaryInterchange.Model.roundMantissaAtExponentUp_ne_zero (mantissa : ) (exponent targetExponent : ) (hm : mantissa 0) :
          roundMantissaAtExponentUp mantissa exponent targetExponent 0

          Ceiling alignment preserves nonzeroness of a positive mantissa.

          theorem FloatLib.Floats.Formats.BinaryInterchange.Model.roundMantissaAtExponentDown_le_up (mantissa : ) (exponent targetExponent : ) :
          roundMantissaAtExponentDown mantissa exponent targetExponent roundMantissaAtExponentUp mantissa exponent targetExponent

          Floor alignment never exceeds ceiling alignment at the same exponent.

          theorem FloatLib.Floats.Formats.BinaryInterchange.Model.roundMantissaAtExponentUp_le_down_add_one (mantissa : ) (exponent targetExponent : ) :
          roundMantissaAtExponentUp mantissa exponent targetExponent roundMantissaAtExponentDown mantissa exponent targetExponent + 1

          Ceiling alignment is at most one unit above floor alignment.

          theorem FloatLib.Floats.Formats.BinaryInterchange.Model.floor_scaledMagnitude (mantissa : ) (exponent targetExponent : ) :
          Flocq.floorRound (mantissa * Flocq.bpow Numerics.binaryRadix (exponent - targetExponent)) = Int.ofNat (roundMantissaAtExponentDown mantissa exponent targetExponent)

          Downward shifting computes the integer floor of a scaled positive dyadic.

          theorem FloatLib.Floats.Formats.BinaryInterchange.Model.ceil_scaledMagnitude (mantissa : ) (exponent targetExponent : ) :
          Flocq.ceilRound (mantissa * Flocq.bpow Numerics.binaryRadix (exponent - targetExponent)) = Int.ofNat (roundMantissaAtExponentUp mantissa exponent targetExponent)

          Upward shifting computes the integer ceiling of a scaled positive dyadic.

          theorem FloatLib.Floats.Formats.BinaryInterchange.Model.roundMantissaAtExponentDown_mul_bpow_le (mantissa : ) (exponent targetExponent : ) :
          (roundMantissaAtExponentDown mantissa exponent targetExponent) * bpow targetExponent mantissa * bpow exponent

          Floor alignment at any target exponent is a lower bound for the exact dyadic magnitude.

          theorem FloatLib.Floats.Formats.BinaryInterchange.Model.le_roundMantissaAtExponentUp_mul_bpow (mantissa : ) (exponent targetExponent : ) :
          mantissa * bpow exponent (roundMantissaAtExponentUp mantissa exponent targetExponent) * bpow targetExponent

          Ceiling alignment at any target exponent is an upper bound for the exact dyadic magnitude.