TorchLean API

NN.Floats.Interval.IEEEExec32

Executable IEEE32Exec endpoint intervals #

This module contains the executable interval definitions for IEEE32Exec endpoints.

It keeps the API small: the main goal is to have an executable interval type with endpoints in the same discrete grid as IEEE-754 binary32 (IEEE32Exec), using outward-rounded endpoint arithmetic (addDown/addUp/mulDown/mulUp).

Soundness theorems (enclosure proofs) are not bundled here; they are best stated relative to a chosen real/extended-real interpretation (see NN/Floats/IEEEExec/BridgeERealTotal.lean).

An executable closed interval with IEEE-754 binary32 semantics (IEEE32Exec) as endpoints.

This type is intended for computation (endpoint arithmetic with outward rounding). Soundness theorems relating these intervals to real/extended-real interpretations are stated in separate bridge files (so theorems can choose the right notion of "real meaning" for the application).

Instances For

    Membership predicate: x lies between lo and hi using the IEEE32Exec order.

    Instances For
      @[implicit_reducible]

      Enable x ∈ I notation for executable Interval32 intervals.

      @[simp]

      Unfold membership: x ∈ I ↔ I.lo ≤ x ∧ x ≤ I.hi.

      Validity predicate for executable intervals.

      We require both endpoints to be finite (not NaN/Inf) and ordered (lohi).

      Instances For
        @[inline]

        Degenerate interval [x, x].

        Instances For
          @[inline]

          Interval hull / union enclosure of two executable intervals.

          This is the smallest interval (by endpoints) that contains both A and B, computed by taking the minimum of lower endpoints and maximum of upper endpoints.

          Implementation note: we use IEEE-754 minimum/maximum so NaNs propagate.

          Instances For
            @[inline]

            Outward-rounded interval addition.

            Instances For
              @[inline]

              Interval negation: -[lo, hi] = [-hi, -lo].

              Instances For
                @[inline]

                Outward-rounded interval subtraction.

                Instances For

                  Helper combinators for interval multiplication.

                  mul needs the minimum/maximum of 4 corner products. We expose these helpers (instead of keeping them private) so downstream soundness proofs can unfold Interval32.mul in a stable way.

                  Minimum of 4 float values, using IEEE minimum (NaNs propagate).

                  Instances For

                    Maximum of 4 float values, using IEEE maximum (NaNs propagate).

                    Instances For

                      Outward-rounded interval multiplication via the classical 4-corner rule.

                      We compute downward-rounded lower-corner products for the lower bound and upward-rounded products for the upper bound, then take the min/max across corners.

                      Instances For
                        @[inline]

                        The "whole" interval [-∞, +∞] (useful as a conservative fallback).

                        Instances For

                          Executable Boolean x ≤ y using IEEE compare.

                          If compare is unordered (none, i.e. NaN involved), we return false.

                          Instances For

                            Returns true iff the real interval denoted by I contains 0.

                            We use this to conservative-handle division by an interval that straddles zero: a single interval cannot precisely represent the true quotient set (which is typically a union), so we return whole instead.

                            Instances For

                              Interval division via the classical 4-corner rule when the denominator interval does not contain 0.

                              If 0 ∈ B, we conservatively return whole = [-∞,+∞].

                              Instances For
                                @[inline]

                                Interval reciprocal 1/B, implemented as a special case of interval division.

                                If 0 ∈ B, we return whole.

                                Instances For