TorchLean API

NN.MLTheory.Proofs.Approximation.FloatInterval.Semantics

Floating-Point Interval Semantics #

Interval-domain semantics for ExecFloat.Binary 8 23 neural networks.

This file formalizes the interval domain, concretization map, executable interval operators, and the exact-interval-image property used by the floating-point interval-approximation theorem of Hwang, Lee, Park, Park, and Saad, Floating-Point Neural Networks Are Provably Robust Universal Approximators (arXiv:2506.16065).

Basic aliases #

@[reducible, inline]

Shorthand for the executable binary32 float type used in this development.

Instances For

    ExecFloat.Binary 8 23 is stored as a UInt32 bit-pattern, so the carrier is finite. We use this only to obtain Finset.univ for paper-style “finite hull” definitions; nothing is computed.

    Small helper lemmas about the ExecFloat.Binary 8 23 order #

    Reflexivity of away from NaN, which is as much as IEEE 754 order gives.

    Interval domain I (Eq. 6) #

    The interval abstract domain of Eq. 6: either the top element or a pair of float endpoints.

    • top : I

      No information: every float is possible.

    • range : FFI

      The floats between the two endpoints, inclusive.

    Instances For

      Concretization γ for abstract intervals (Eq. 7).

      Instances For
        @[instance_reducible]

        Membership in an abstract interval, via the concretization γI.

        @[reducible, inline]

        Abstract boxes B ∈ I^d.

        Instances For

          Concretization γ for boxes (Eq. 7).

          Instances For

            A box is in [-1,1]^d (paper: “abstract boxes in [-1,1]^d”).

            Instances For
              @[simp]

              Everything is in , NaN included; that is what makes the sound fallback.

              @[simp]

              Membership in a range interval unfolds to the two float comparisons.

              @[inline]

              Point interval ⟨x,x⟩.

              Instances For
                @[inline]

                Point box ⟨x,x⟩^d.

                Instances For

                  Executable interval operators for +, *, and ReLU #

                  @[inline]

                  Minimum of two ExecFloat.Binary 8 23 values (NaN-aware, via min).

                  Instances For
                    @[inline]

                    Maximum of two ExecFloat.Binary 8 23 values (NaN-aware, via max).

                    Instances For
                      @[inline]

                      Minimum of four ExecFloat.Binary 8 23 values, computed via nested min2.

                      Instances For
                        @[inline]

                        Maximum of four ExecFloat.Binary 8 23 values, computed via nested max2.

                        Instances For
                          @[inline]

                          Return true iff any of the four arguments is NaN.

                          Instances For

                            Corner-based interval addition for ExecFloat.add.

                            Instances For

                              Corner-based interval multiplication for ExecFloat.mul.

                              Instances For
                                @[inline]

                                Executable ReLU for ExecFloat.Binary 8 23, defined via max.

                                Instances For

                                  Exact ReLU♯ for intervals, using monotonicity of ReLU: for ⟨a,b⟩, ReLU([a,b]) = [ReLU(a), ReLU(b)].

                                  Instances For

                                    Eq. (8): exact interval hull on finite sets #

                                    Totalized extended-real interpretation (defaults to 0 only on NaN).

                                    Instances For

                                      Away from NaN, float comparison agrees with the order on EReal under the total embedding.

                                      This is the lemma that buys the whole development a linear order to take minima and maxima in: ExecFloat.Binary 8 23 itself has no LinearOrder, but its non-NaN part embeds into one.

                                      A nonempty finite set of floats has an element attaining the minimum of its EReal image.

                                      A minimizing element of s, chosen classically.

                                      Choice rather than computation because several distinct floats can share one EReal value (the two zeros), so "the" minimum is not well defined as a float; every use below only needs some minimizer.

                                      Instances For

                                        A maximizing element of s, chosen classically.

                                        Instances For

                                          Interval hull for a finite set of floats:

                                          • if the set contains a NaN (paper: ⊥ ∈ S), otherwise
                                          • the interval ⟨min S, max S⟩.
                                          Instances For

                                            The hull contains every element of the set it was built from. All three soundness proofs below reduce to this one fact.

                                            Interval ops ⊕♯/⊗♯/σ♯ instantiated from hull #

                                            Concretization of an interval as a Finset, by filtering the (finite) float type.

                                            Instances For

                                              Concretization of a box as a Finset of points. Finite because F is, which is what lets the abstract operators be defined as images of concrete ones rather than by endpoint formulas.

                                              Instances For

                                                Membership in the Finset concretization is coordinatewise interval membership.

                                                @[inline]

                                                Build a 2D box from two intervals (coordinate 0 is A, coordinate 1 is B).

                                                Instances For

                                                  Abstract addition +♯: the hull of float addition over the whole input box.

                                                  Defined as an image rather than by adding endpoints, because float addition is not monotone in the presence of NaN and signed zeros, so an endpoint formula would not be exact. absorbs.

                                                  Instances For

                                                    Abstract multiplication *♯, again as the hull of the concrete image over the box.

                                                    Instances For

                                                      Abstract ReLU, the hull of the concrete image.

                                                      Instances For

                                                        Interval summation ◦∑♯ from the paper: fold with addSharp.

                                                        Instances For

                                                          OpsExact implements the finite interval semantics used for exact interval-image statements.

                                                          The Sound class isolates the operation-level obligations used by higher-level semantic proofs. The addition, multiplication, and ReLU obligations are proved below, followed by the canonical ExecFloat.Binary 8 23 instance.

                                                          The per-operation soundness obligations the interval semantics rests on: every abstract operation must contain the concrete result of any pair of members of its arguments.

                                                          Instances

                                                            Soundness of abstract addition: concrete sums of members stay in the abstract sum.

                                                            Soundness of abstract multiplication.

                                                            Soundness of the interval sum ◦∑♯: folding concrete additions stays inside the folded intervals.

                                                            Proved by induction on the list rather than on Fin n, so that the accumulator interval can vary; the base case needs 0 ∈ ⟨0, 0⟩, which is where the non-NaN side condition on zero comes in.

                                                            Exact interval-image property for rounded targets #

                                                            Float interval set {x | a ≤ x ∧ x ≤ b} (avoids needing Preorder).

                                                            Instances For

                                                              m is a minimum of g on the set S, stated without choosing a canonical min.

                                                              Instances For

                                                                M is a maximum of g on the set S, stated without choosing a canonical max.

                                                                Instances For

                                                                  For each box B, the abstract output interval is exactly the interval hull of the rounded target's direct image on γ(B), expressed via existential min/max witnesses.

                                                                  Instances For

                                                                    A constant target has an exact interval image: the point interval ⟨c, c⟩.

                                                                    The easiest instance of the exactness property, and the one the constant-target construction of the paper needs; the nonemptiness hypothesis is what supplies the min and max witnesses.

                                                                    Two-layer interval evaluator using OpsExact #

                                                                    Parameters of a 2-layer MLP of shape d → h → 1 for the exact interval semantics (OpsExact).

                                                                    • W1 : Fin hFin dF

                                                                      Weight matrix for layer 1.

                                                                    • b1 : Fin hF

                                                                      Bias for layer 1.

                                                                    • W2 : Fin 1Fin hF

                                                                      Weight matrix for layer 2.

                                                                    • b2 : Fin 1F

                                                                      Bias for layer 2.

                                                                    Instances For
                                                                      def NN.MLTheory.Proofs.UniversalApproximation.FloatIntervalApprox.TwoLayerMLPExact.aff {d m : } (W : Fin mFin dF) (b : Fin mF) (x : Fin dF) :
                                                                      Fin mF

                                                                      Apply an affine layer to an input vector using IEEE32Exec arithmetic.

                                                                      Instances For

                                                                        Evaluate a 2-layer ReLU MLP on a concrete input, using the exact op wrappers (OpsExact.relu).

                                                                        Instances For
                                                                          noncomputable def NN.MLTheory.Proofs.UniversalApproximation.FloatIntervalApprox.TwoLayerMLPExact.affSharp {d m : } (W : Fin mFin dF) (b : Fin mF) (B : I.Box d) :

                                                                          Interval affine transform aff♯ using corner multiplication and interval summation.

                                                                          Instances For

                                                                            Interval semantics ν♯ for 2-layer ReLU MLPs.

                                                                            Instances For
                                                                              theorem NN.MLTheory.Proofs.UniversalApproximation.FloatIntervalApprox.TwoLayerMLPExact.aff_sound [OpsExact.Sound] {d m : } (W : Fin mFin dF) (b : Fin mF) (B : I.Box d) (hW : ∀ (i : Fin m) (j : Fin d), FloatLib.Floats.ExecFloat.Binary.isNaN (W i j) = false) (hb : ∀ (i : Fin m), FloatLib.Floats.ExecFloat.Binary.isNaN (b i) = false) {x : Fin dF} :
                                                                              x I.γ Baff W b x I.γ (affSharp W b B)

                                                                              The abstract affine transform is sound, given that no weight or bias is NaN.

                                                                              Weights enter as point intervals, so the proof is mulSharp soundness coordinatewise, then sumSharp soundness, then one addSharp for the bias, in exactly the order aff computes.

                                                                              theorem NN.MLTheory.Proofs.UniversalApproximation.FloatIntervalApprox.TwoLayerMLPExact.eval_sound [OpsExact.Sound] {d h : } (net : Net d h) (B : I.Box d) (hW1 : ∀ (i : Fin h) (j : Fin d), FloatLib.Floats.ExecFloat.Binary.isNaN (net.W1 i j) = false) (hb1 : ∀ (i : Fin h), FloatLib.Floats.ExecFloat.Binary.isNaN (net.b1 i) = false) (hW2 : ∀ (i : Fin 1) (j : Fin h), FloatLib.Floats.ExecFloat.Binary.isNaN (net.W2 i j) = false) (hb2 : ∀ (i : Fin 1), FloatLib.Floats.ExecFloat.Binary.isNaN (net.b2 i) = false) {x : Fin dF} :
                                                                              x I.γ Beval net x evalSharp net B

                                                                              The abstract semantics ν♯ of a two-layer ReLU network overapproximates the concrete one.

                                                                              Set-level restatement: the image of the concretization is contained in the abstract output.

                                                                              This is the form the approximation theorem cites, since it speaks about images of sets rather than about individual points.

                                                                              Specialization to a point box: the abstract semantics contains the concrete value at x.

                                                                              Worth stating separately because it says the abstraction has no false negatives at single inputs, which is what a verifier reports back to a user.