TorchLean API

NN.Floats.IEEEExec.Exec32

Executable IEEE-754 binary32 (IEEE32Exec) #

TorchLean uses two complementary ways to talk about "float32":

We implement IEEE32Exec as raw UInt32 bits and provide:

We also provide a Context IEEE32Exec instance so the spec layer can run modules with an executable scalar. That is why we import NN.Spec.Core.Context here.

About transcendentals #

IEEE-754 does not specify implementations for transcendental functions (exp, tanh, ...). In practice those are provided by libm (or vendor math libraries) and vary across platforms.

We provide deterministic implementations for a few transcendentals in Lean so examples can run without delegating to the host runtime. For the remaining ones, we may still delegate to Lean's Float (binary64) and round back to binary32. These functions are executable and stable, but they are not claimed to be correctly rounded or to match any particular hardware/libm.

References #

Executable IEEE-754 binary32 value, stored as raw bits.

Instances For
    @[inline]

    Wrap raw binary32 bits as an IEEE32Exec.

    Instances For
      @[inline]

      Extract the raw binary32 bits of an IEEE32Exec.

      Instances For
        @[implicit_reducible]

        Default inhabitant: all bits zero, i.e. +0.0.

        Binary32 bit layout #

        IEEE-754 binary32 is stored as:

        For NaNs, the "quiet" bit is the top fraction bit.

        Mask selecting the sign bit (bit 31).

        Instances For

          Mask selecting the 8-bit exponent field (bits 30..23).

          Instances For

            Mask selecting the 23-bit fraction field (bits 22..0).

            Instances For

              The IEEE-754 "quiet NaN" indicator bit (top fraction bit).

              Instances For

                8-bit value 0xFF, used to test the “all ones” exponent field.

                Instances For
                  @[inline]

                  True iff the sign bit (bit 31) is set.

                  Instances For
                    @[inline]

                    Extract the 8-bit exponent field (bits 30..23).

                    Instances For
                      @[inline]

                      Extract the 23-bit fraction field (bits 22..0).

                      Instances For
                        @[inline]

                        Predicate for NaN: exponent all ones and fraction nonzero.

                        Instances For
                          @[inline]

                          Predicate for quiet NaN (NaN with the quiet bit set).

                          Instances For
                            @[inline]

                            Predicate for signaling NaN (NaN with the quiet bit clear).

                            Instances For
                              @[inline]

                              Predicate for infinity: exponent all ones and fraction zero.

                              Instances For
                                @[inline]

                                Predicate for signed zero (both +0 and -0).

                                Instances For
                                  @[inline]

                                  Predicate for finiteness: exponent field is not all ones (excludes NaN/Inf).

                                  Instances For
                                    @[inline]

                                    +0.0 as an executable binary32 constant.

                                    Instances For
                                      @[inline]

                                      -0.0 as an executable binary32 constant.

                                      Instances For
                                        @[inline]

                                        +1.0 as an IEEE-754 binary32 constant.

                                        Instances For
                                          @[inline]

                                          -1.0 as an IEEE-754 binary32 constant.

                                          Instances For
                                            @[inline]

                                            +∞ as an executable binary32 constant.

                                            Instances For
                                              @[inline]

                                              -∞ as an executable binary32 constant.

                                              Instances For
                                                @[inline]

                                                A canonical quiet NaN payload used by the executable kernel.

                                                Instances For

                                                  NaN selection / payload propagation #

                                                  IEEE-754 leaves some freedom in how NaNs are "chosen" when multiple NaNs appear. For reproducibility (and nicer debugging), we make the choice deterministic (left-to-right) and we quiet signaling NaNs by setting the quiet bit.

                                                  @[inline]

                                                  Quiet a NaN by setting the quiet bit (and leave non-NaNs unchanged).

                                                  Instances For

                                                    If x is a NaN, return it (quieted).

                                                    Instances For

                                                      Choose a NaN from two operands.

                                                      This is the "NaN propagation" policy used by most binary ops in this file:

                                                      • if any operand is a signaling NaN, return that operand (quieted), left-to-right,
                                                      • otherwise if any operand is a quiet NaN, return that operand, left-to-right,
                                                      • otherwise return none.
                                                      Instances For

                                                        Like chooseNaN2, but for ternary ops (used for fma).

                                                        Instances For

                                                          Adjacent floats (nextUp/nextDown) #

                                                          @[inline]

                                                          Smallest positive subnormal (bit pattern 0x00000001, value 2^-149).

                                                          Instances For
                                                            @[inline]

                                                            Smallest negative subnormal (bit pattern 0x80000001, value -2^-149).

                                                            Instances For
                                                              @[inline]

                                                              Largest finite positive float32 (bit pattern 0x7F7FFFFF).

                                                              Instances For
                                                                @[inline]

                                                                Largest finite negative float32 (bit pattern 0xFF7FFFFF).

                                                                Instances For
                                                                  @[inline]

                                                                  nextUp x is the next representable float32 strictly greater than x.

                                                                  IEEE-754 special cases:

                                                                  • NaN propagates (quieted).
                                                                  • nextUp (+∞) = +∞.
                                                                  • nextUp (-0) = +minSubnormal (since +0 is not strictly greater than -0).
                                                                  Instances For
                                                                    @[inline]

                                                                    nextDown x is the next representable float32 strictly less than x.

                                                                    IEEE-754 special cases:

                                                                    • NaN propagates (quieted).
                                                                    • nextDown (-∞) = -∞.
                                                                    • nextDown (+0) = -minSubnormal (since -0 is not strictly less than +0).
                                                                    Instances For
                                                                      @[inline]

                                                                      Flip the sign bit (works for finite/Inf/NaN, and distinguishes ±0).

                                                                      Instances For
                                                                        @[inline]

                                                                        Clear the sign bit.

                                                                        Instances For

                                                                          Exact dyadic value (-1)^sign * mant * 2^exp used as an intermediate for finite ops.

                                                                          Instances For

                                                                            2^k as a natural number.

                                                                            Instances For

                                                                              Round n / 2^shift to nearest, ties-to-even.

                                                                              This is the primitive "shift + rounding" operation we use when shrinking a mantissa back down to a fixed bit width. It is the same tie-breaking policy as IEEE round-to-nearest-even.

                                                                              Instances For

                                                                                Construct a raw binary32 bit-pattern from fields.

                                                                                mkBits sign exp frac places:

                                                                                • sign in bit 31,
                                                                                • exp in bits 30..23 (8 bits),
                                                                                • frac in bits 22..0 (masked to 23 bits).
                                                                                Instances For

                                                                                  Decode a finite binary32 into an exact dyadic value.

                                                                                  Returns none for NaN/Inf.

                                                                                  Instances For

                                                                                    If toDyadic? x = some d then x is not a NaN.

                                                                                    Informal: toDyadic? only returns some _ for finite floats; NaNs map to none.

                                                                                    If toDyadic? x = some d then x is not an infinity.

                                                                                    Informal: toDyadic? only returns some _ for finite floats; infinities map to none.

                                                                                    Rounding back to binary32 #

                                                                                    The general pattern for the finite ops in this file is:

                                                                                    1. decode float32(s) to an exact intermediate representation (Dyadic for + - * fma sqrt, rationals for /),
                                                                                    2. compute the exact result in that intermediate representation,
                                                                                    3. round once to float32 using round-to-nearest, ties-to-even.

                                                                                    Round an exact dyadic value to binary32 (ties-to-even).

                                                                                    This function implements:

                                                                                    • overflow to ±Inf,
                                                                                    • gradual underflow into subnormals (down to exponent -149),
                                                                                    • underflow-to-zero below 2^-150 (half the minimum subnormal, where ties-to-even chooses 0),
                                                                                    • mantissa rounding to the 24-bit precision of binary32 normal numbers.
                                                                                    Instances For

                                                                                      Exact dyadic arithmetic (finite core) #

                                                                                      Dyadic is closed under + and * (at the exact level). We use these helpers before rounding back to float32.

                                                                                      Exact dyadic addition.

                                                                                      We align exponents by shifting the mantissa of the operand with the larger exponent, add signed integers, and then return an exact dyadic (no rounding yet).

                                                                                      Instances For

                                                                                        Exact rationals for division #

                                                                                        For division we compute an exact rational num/den (with den > 0) and then round it to binary32 using round-to-nearest, ties-to-even.

                                                                                        Round num/den to nearest, ties-to-even (assumes den > 0).

                                                                                        Instances For

                                                                                          Test whether num/den < 2^k without converting to reals.

                                                                                          Instances For

                                                                                            Test whether num/den ≥ 2^k without converting to reals.

                                                                                            Instances For

                                                                                              Compute ⌊log₂(num/den)⌋ as an Int (assumes num > 0 and den > 0).

                                                                                              We start from the rough estimate log2(num) - log2(den) and then adjust by checking against powers of two.

                                                                                              Instances For

                                                                                                Round an exact rational num/den to binary32 (ties-to-even).

                                                                                                This is the division analogue of roundDyadicToIEEE32: it uses the same exponent thresholds and the same final mantissa rounding policy.

                                                                                                Instances For

                                                                                                  IEEE754 addition (round-to-nearest, ties-to-even), with NaN/Inf rules.

                                                                                                  Instances For
                                                                                                    @[inline]

                                                                                                    IEEE754 subtraction (defined as addition with sign-flip).

                                                                                                    Instances For

                                                                                                      IEEE754 multiplication (round-to-nearest, ties-to-even), with NaN/Inf rules.

                                                                                                      Instances For

                                                                                                        IEEE754 division (round-to-nearest, ties-to-even), with NaN/Inf rules.

                                                                                                        Instances For

                                                                                                          IEEE754 fused multiply-add: compute x*y+z and round once (ties-to-even).

                                                                                                          Instances For

                                                                                                            If both inputs decode to dyadics, add is “exact dyadic add, then round once”.

                                                                                                            Informal: for finite x,y, we compute the exact dyadic value dx + dy and apply IEEE round-to-nearest-even.

                                                                                                            theorem TorchLean.Floats.IEEE754.IEEE32Exec.mul_eq_roundDyadicToIEEE32_of_toDyadic? {x y : IEEE32Exec} {dx dy : Dyadic} (hx : x.toDyadic? = some dx) (hy : y.toDyadic? = some dy) :
                                                                                                            x.mul y = roundDyadicToIEEE32 { sign := dx.sign ^^ dy.sign, mant := dx.mant * dy.mant, exp := dx.exp + dy.exp }

                                                                                                            If both inputs decode to dyadics, mul is “exact dyadic multiply, then round once”.

                                                                                                            Informal: for finite x,y, the exact product is a dyadic with mantissa dx.mant * dy.mant and exponent dx.exp + dy.exp, and we round that back to binary32.

                                                                                                            theorem TorchLean.Floats.IEEE754.IEEE32Exec.fma_eq_roundDyadicToIEEE32_of_toDyadic? {x y z : IEEE32Exec} {dx dy dz : Dyadic} (hx : x.toDyadic? = some dx) (hy : y.toDyadic? = some dy) (hz : z.toDyadic? = some dz) :
                                                                                                            x.fma y z = roundDyadicToIEEE32 (addDyadic { sign := dx.sign ^^ dy.sign, mant := dx.mant * dy.mant, exp := dx.exp + dy.exp } dz)

                                                                                                            If all inputs decode to dyadics, fma x y z is “exact dyadic (x*y) + z, then round once”.

                                                                                                            Informal: for finite inputs, we compute the exact dyadic product dx*dy, add dz, and finally apply IEEE round-to-nearest-even.

                                                                                                            theorem TorchLean.Floats.IEEE754.IEEE32Exec.div_eq_roundRatToIEEE32_of_toDyadic? {x y : IEEE32Exec} {dx dy : Dyadic} (hx : x.toDyadic? = some dx) (hy : y.toDyadic? = some dy) (hy0 : dy.mant 0) :
                                                                                                            x.div y = have sign := dx.sign ^^ dy.sign; have eDiff := dx.exp - dy.exp; match match eDiff with | Int.ofNat sh => (dx.mant.shiftLeft sh, dy.mant) | Int.negSucc sh => (dx.mant, dy.mant.shiftLeft (sh + 1)) with | (num, den) => roundRatToIEEE32 sign num den

                                                                                                            If x and y decode to dyadics and the denominator mantissa is nonzero, div x y is obtained by forming the exact rational quotient and rounding once.

                                                                                                            Informal: for finite nonzero y, we compute the exact value (dx.mant * 2^dx.exp) / (dy.mant * 2^dy.exp) as a rational num/den with an exponent adjustment, then apply IEEE round-to-nearest-even.

                                                                                                            IEEE754 square root (ties-to-even).

                                                                                                            Instances For

                                                                                                              Compare two exact dyadics by exact integer comparison.

                                                                                                              This is used internally by executable rounding and special-case logic. The implementation normalizes the exponents to a common minimum exponent and compares the scaled integer mantissas.

                                                                                                              Instances For

                                                                                                                ceil(n / 2^shift) for naturals, implemented via shifts (used for directed rounding).

                                                                                                                Instances For

                                                                                                                  Directed rounding down (toward -∞) for a positive dyadic mant * 2^exp.

                                                                                                                  Instances For

                                                                                                                    Directed rounding up (toward +∞) for a positive dyadic mant * 2^exp.

                                                                                                                    Instances For

                                                                                                                      Directed rounding down (toward -∞) of an exact dyadic to float32.

                                                                                                                      Instances For

                                                                                                                        Directed rounding up (toward +∞) of an exact dyadic to float32.

                                                                                                                        Instances For

                                                                                                                          addDown x y is a float32 lower bound for the exact real sum (when finite).

                                                                                                                          Instances For

                                                                                                                            addUp x y is a float32 upper bound for the exact real sum (when finite).

                                                                                                                            Instances For
                                                                                                                              @[inline]

                                                                                                                              subDown x y is a float32 lower bound for the exact real difference (when finite).

                                                                                                                              Instances For
                                                                                                                                @[inline]

                                                                                                                                subUp x y is a float32 upper bound for the exact real difference (when finite).

                                                                                                                                Instances For

                                                                                                                                  mulDown x y is a float32 lower bound for the exact real product (when finite).

                                                                                                                                  Instances For

                                                                                                                                    mulUp x y is a float32 upper bound for the exact real product (when finite).

                                                                                                                                    Instances For

                                                                                                                                      Directed rounding for exact rationals (division-friendly) #

                                                                                                                                      For divDown/divUp we need outward rounding of an exact rational num/den to the float32 grid. Our dyadic-directed rounders (roundDyadicDown/roundDyadicUp) already have a clean soundness proof, so we reduce rational rounding to dyadic rounding by building a dyadic enclosure of num/den:

                                                                                                                                      We then apply roundDyadicDown/roundDyadicUp to these dyadics.

                                                                                                                                      This is sound (it produces outward-rounded endpoints), but it is not necessarily optimally tight; a larger ratApproxShift improves tightness at some computational cost.

                                                                                                                                      Number of extra bits used when turning num/den into a dyadic enclosure.

                                                                                                                                      Instances For

                                                                                                                                        ceil(num/den) for naturals, totalized (returns 0 when den = 0).

                                                                                                                                        Instances For

                                                                                                                                          Lower dyadic mantissa for num/den at scale 2^ratApproxShift.

                                                                                                                                          Instances For

                                                                                                                                            Upper dyadic mantissa for num/den at scale 2^ratApproxShift.

                                                                                                                                            Instances For

                                                                                                                                              Directed rounding down (toward -∞) for a rational ±(num/den) with den > 0.

                                                                                                                                              We do not attempt to be "correctly rounded" in the IEEE-754 sense; we only need a sound lower bound.

                                                                                                                                              Instances For

                                                                                                                                                Directed rounding up (toward +∞) for a rational ±(num/den) with den > 0.

                                                                                                                                                Instances For

                                                                                                                                                  divDown x y is a float32 lower bound for the exact real quotient (when finite and y ≠ 0).

                                                                                                                                                  Instances For

                                                                                                                                                    divUp x y is a float32 upper bound for the exact real quotient (when finite and y ≠ 0).

                                                                                                                                                    Instances For

                                                                                                                                                      IEEE754 numerical comparison.

                                                                                                                                                      Returns none (unordered) if either operand is NaN; otherwise returns an Ordering.

                                                                                                                                                      Instances For

                                                                                                                                                        Strict order induced by IEEE-754 comparison.

                                                                                                                                                        lt x y is true exactly when compare x y = some .lt. In particular, if either side is NaN then lt x y is false (because compare returns none).

                                                                                                                                                        Instances For

                                                                                                                                                          Non-strict order induced by IEEE-754 comparison.

                                                                                                                                                          le x y is true when compare x y returns .lt or .eq, and false otherwise (including the NaN unordered case).

                                                                                                                                                          Instances For

                                                                                                                                                            Order lemmas #

                                                                                                                                                            IEEE-754 comparisons treat NaNs as unordered, so in particular le x x is not true for NaNs. For the interval layer, we mainly need the basic fact that le is reflexive on finite values.

                                                                                                                                                            @[simp]

                                                                                                                                                            IEEE32Exec.le is reflexive on finite values.

                                                                                                                                                            Informally: if x is a finite float32, then x ≤ x. (NaNs are excluded by the isFinite premise: for NaN, isFinite x = false and x ≤ x is false because compare returns none.)

                                                                                                                                                            This lemma is used by the executable interval layer to show that the "point interval" [x, x] is valid whenever x is finite.

                                                                                                                                                            @[simp]

                                                                                                                                                            isFinite x = true → x ≤ x is always true.

                                                                                                                                                            This looks a bit odd, but it's exactly the side-goal produced by simp [Valid, point] in the executable interval module (NN/Floats/Interval/IEEEExec32.lean). Registering this as a simp lemma lets that file stay a one-liner.

                                                                                                                                                            IEEE754 minimum: NaNs propagate; minimum(-0,+0) = -0.

                                                                                                                                                            Instances For

                                                                                                                                                              IEEE754 maximum: NaNs propagate; maximum(-0,+0) = +0.

                                                                                                                                                              Instances For

                                                                                                                                                                IEEE754 minNum: if exactly one operand is a quiet NaN, return the other operand.

                                                                                                                                                                Signaling NaNs still propagate (quieted).

                                                                                                                                                                Instances For

                                                                                                                                                                  IEEE754 maxNum: if exactly one operand is a quiet NaN, return the other operand.

                                                                                                                                                                  Signaling NaNs still propagate (quieted).

                                                                                                                                                                  Instances For

                                                                                                                                                                    Convert to an exact Float (binary64); finite float32 values embed exactly in binary64.

                                                                                                                                                                    Instances For

                                                                                                                                                                      Convert/round an IEEE binary64 Float to float32 (ties-to-even).

                                                                                                                                                                      Instances For

                                                                                                                                                                        Fixed-point scale (in bits) used by the integer-only exp/log approximations.

                                                                                                                                                                        Instances For

                                                                                                                                                                          Fixed-point encoding of 1 at scale fixedScale (i.e. 2^fixedScale).

                                                                                                                                                                          Instances For

                                                                                                                                                                            Integer power of two: pow2Int k = 2^k as an Int.

                                                                                                                                                                            Instances For

                                                                                                                                                                              Round an integer quotient num/den to the nearest integer, ties-to-even.

                                                                                                                                                                              Assumes den > 0.

                                                                                                                                                                              Instances For

                                                                                                                                                                                Divide by 2^shift, rounding to nearest with ties-to-even.

                                                                                                                                                                                Instances For

                                                                                                                                                                                  Shift by a power of two: multiply when k ≥ 0, divide when k < 0.

                                                                                                                                                                                  Division uses ties-to-even rounding.

                                                                                                                                                                                  Instances For

                                                                                                                                                                                    Fixed-point multiplication at scale fixedScale (ties-to-even).

                                                                                                                                                                                    Instances For

                                                                                                                                                                                      Fixed-point division at scale fixedScale (ties-to-even).

                                                                                                                                                                                      If a and b are fixed-point at scale fixedScale, the result is at the same scale.

                                                                                                                                                                                      Instances For

                                                                                                                                                                                        Divide by a natural number, rounding to nearest with ties-to-even.

                                                                                                                                                                                        Instances For

                                                                                                                                                                                          Convert a dyadic number to a signed fixed-point integer at scale fixedScale.

                                                                                                                                                                                          Instances For

                                                                                                                                                                                            Convert a signed fixed-point integer at scale fixedScale to a dyadic number.

                                                                                                                                                                                            Instances For

                                                                                                                                                                                              Fixed-point approximation to ln 2 at scale fixedScale.

                                                                                                                                                                                              Instances For

                                                                                                                                                                                                Fixed-point approximation to 1/ln 2 at scale fixedScale.

                                                                                                                                                                                                Instances For

                                                                                                                                                                                                  Fixed-point Taylor coefficients (highest degree first) for 2^x on [-1/2, 1/2].

                                                                                                                                                                                                  Instances For

                                                                                                                                                                                                    Evaluate the fixed-point 2^x polynomial approximation using Horner’s method.

                                                                                                                                                                                                    Instances For

                                                                                                                                                                                                      Deterministic exp (no delegation to Float): range-reduced 2^(x/ln2) with a fixedpoint polynomial.

                                                                                                                                                                                                      Instances For

                                                                                                                                                                                                        Deterministic log (no delegation to Float): normalize x = m*2^k and use an atanh-series for log m.

                                                                                                                                                                                                        Instances For

                                                                                                                                                                                                          Deterministic sinh (no delegation to Float): defined via exp.

                                                                                                                                                                                                          Instances For

                                                                                                                                                                                                            Deterministic cosh (no delegation to Float): defined via exp.

                                                                                                                                                                                                            Instances For

                                                                                                                                                                                                              Deterministic tanh (no delegation to Float): stable form tanh x = s*(1 - 2/(exp(2*|x|)+1)).

                                                                                                                                                                                                              Instances For

                                                                                                                                                                                                                Deterministic sin/cos #

                                                                                                                                                                                                                Unlike exp/log, sin and cos are used by the runtime FFT layer (NN.Runtime.*.Fft) to build twiddle factors. Delegating to the host Float implementation makes results platform-dependent.

                                                                                                                                                                                                                We implement sin/cos purely inside Lean:

                                                                                                                                                                                                                1. scale the input down by a power of two so |y| < 1/2,
                                                                                                                                                                                                                2. approximate sin y and cos y by exact Taylor partial sums (degree 13 / 12),
                                                                                                                                                                                                                3. scale back up using m applications of the double-angle formulas.

                                                                                                                                                                                                                This is deterministic and uses only the IEEE32Exec kernel ops (roundRatToIEEE32, add/mul/sub, etc.). We do not claim correctly-rounded libm behavior; the goal is reproducible execution.

                                                                                                                                                                                                                Round the exact rational d / den to binary32, where d is an exact dyadic mant * 2^exp.

                                                                                                                                                                                                                We package the dyadic exponent into a rational numerator/denominator and call roundRatToIEEE32.

                                                                                                                                                                                                                Instances For

                                                                                                                                                                                                                  Taylor partial sums on |y| < 1/2 #

                                                                                                                                                                                                                  We encode the partial sums using a common factorial denominator so the coefficients are exact integers, not approximations.

                                                                                                                                                                                                                  For z = y^2:

                                                                                                                                                                                                                  Deterministic sin implementation (shared core via sinCos).

                                                                                                                                                                                                                  Instances For

                                                                                                                                                                                                                    Deterministic cos implementation (shared core via sinCos).

                                                                                                                                                                                                                    Instances For

                                                                                                                                                                                                                      Public sin / cos #

                                                                                                                                                                                                                      We expose sin/cos as executable ops on IEEE32Exec using the deterministic implementation above, together with standard IEEE special-case conventions.

                                                                                                                                                                                                                      @[implicit_reducible]

                                                                                                                                                                                                                      Pretty-print using Lean's Float printer (via toFloat).

                                                                                                                                                                                                                      @[implicit_reducible]

                                                                                                                                                                                                                      Coerce naturals to binary32 by converting through Lean's Float and re-encoding.

                                                                                                                                                                                                                      @[implicit_reducible]

                                                                                                                                                                                                                      Numeral literals for IEEE32Exec.

                                                                                                                                                                                                                      This allows writing:

                                                                                                                                                                                                                      • (1 : IEEE32Exec)
                                                                                                                                                                                                                      • (42 : IEEE32Exec)

                                                                                                                                                                                                                      The interpretation is NatFloat (binary64) → IEEE32Exec via ofFloat, i.e. it rounds the exact integer to the nearest representable float32 (which is exact for small enough integers).

                                                                                                                                                                                                                      @[implicit_reducible]

                                                                                                                                                                                                                      0.0 as an executable binary32 value (chosen as +0.0).

                                                                                                                                                                                                                      @[implicit_reducible]

                                                                                                                                                                                                                      1.0 as an executable binary32 value.

                                                                                                                                                                                                                      @[implicit_reducible]

                                                                                                                                                                                                                      Unary negation (IEEE-754 sign flip, with NaN payload rules).

                                                                                                                                                                                                                      @[implicit_reducible]

                                                                                                                                                                                                                      IEEE-754 addition (with NaN/Inf rules).

                                                                                                                                                                                                                      @[implicit_reducible]

                                                                                                                                                                                                                      IEEE-754 subtraction (with NaN/Inf rules).

                                                                                                                                                                                                                      @[implicit_reducible]

                                                                                                                                                                                                                      IEEE-754 multiplication (with NaN/Inf rules).

                                                                                                                                                                                                                      @[implicit_reducible]

                                                                                                                                                                                                                      IEEE-754 division (with NaN/Inf rules).

                                                                                                                                                                                                                      @[implicit_reducible]

                                                                                                                                                                                                                      Exponentiation instance.

                                                                                                                                                                                                                      This is a deterministic executable choice, not a claim about correctly-rounded pow: we implement a small set of IEEE-like special cases and handle integer exponents exactly enough to avoid the most common footguns (negative bases, 0^0, 1^∞, etc.). For general non-integer exponents we fall back to exp (b * log a) on positive bases.

                                                                                                                                                                                                                      @[implicit_reducible]

                                                                                                                                                                                                                      Boolean equality with IEEE-754 NaN/zero conventions.

                                                                                                                                                                                                                      • If either side is NaN, we return false.
                                                                                                                                                                                                                      • If both are zeros (either sign), we return true.
                                                                                                                                                                                                                      • Otherwise we compare raw bits.
                                                                                                                                                                                                                      @[implicit_reducible]

                                                                                                                                                                                                                      Strict order instance, defined via IEEE32Exec.lt.

                                                                                                                                                                                                                      @[implicit_reducible]

                                                                                                                                                                                                                      Non-strict order instance, defined via IEEE32Exec.le.

                                                                                                                                                                                                                      @[implicit_reducible]

                                                                                                                                                                                                                      Decidable < inherited from the compare-based definition.

                                                                                                                                                                                                                      @[implicit_reducible]

                                                                                                                                                                                                                      Decidable inherited from the compare-based definition.

                                                                                                                                                                                                                      @[implicit_reducible]

                                                                                                                                                                                                                      min operator, implemented by IEEE-754 minimum.

                                                                                                                                                                                                                      @[implicit_reducible]

                                                                                                                                                                                                                      max operator, implemented by IEEE-754 maximum.

                                                                                                                                                                                                                      @[implicit_reducible]

                                                                                                                                                                                                                      Provide the MathFunctions interface using the deterministic implementations in this file.

                                                                                                                                                                                                                      @[implicit_reducible]

                                                                                                                                                                                                                      Numeric constants used by the spec library, instantiated at binary32.

                                                                                                                                                                                                                      @[implicit_reducible]

                                                                                                                                                                                                                      Context instance so the spec layer can execute with IEEE32Exec scalars.