TorchLean API

NN.Floats.IEEEExec.Exec32.Compare

Comparisons for executable IEEE32 values.

The definitions here implement the ordering and classification behavior used by the executable binary32 arithmetic layer.

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