TorchLean API

FloatLib.Floats.Formats.Flocq.Theory.Format.Formats

Flocq-style formats (FIX / FLX / FLT) #

Exponent-selection functions fexp : ℤ → ℤ describe three real-valued format families:

FLT has no upper exponent bound or overflow. Executable binary formats with infinities, NaNs, and signed zeros are defined in FloatLib/Floats/Formats/BinaryInterchange/.

References:

@[reducible, inline]

A positive number of radix digits for FLX, FLT, and FTZ formats.

Raw exponent functions remain available for algebraic proofs, but callers accepting an integer configuration should first use FormatPrecision.ofInt?. This prevents a zero or negative precision from being silently reinterpreted through an absolute-value conversion.

This is Mathlib's proof-erased positive-natural carrier rather than another project-local structure.

Instances For

    Convert a proof-carrying format precision to the integer parameter used by exponent formulas.

    Instances For

      Check a natural-number precision at a configuration boundary.

      Instances For

        Check an integer precision, rejecting zero and every negative value.

        Instances For
          @[simp]

          A checked precision remains positive after conversion to the integer exponent parameter.

          @[simp]

          Natural precision validation fails exactly at zero.

          @[simp]

          Integer precision validation fails exactly for nonpositive inputs.

          fixExp emin is the simplest exponent-selection function: it always returns the same exponent.

          This is Flocq's FIX_exp. It describes values living on a single fixed grid $\beta^{\mathtt{emin}}\mathbb{Z}$, as in fixed-point arithmetic or quantization.

          Instances For

            fixExp emin satisfies the exponent-validity axioms ValidExp. Registering the result as an instance lets the FIX theorems reuse the generic format lemmas shared with FLX and FLT.

            theorem FloatLib.Floats.Formats.Flocq.ulp_zero_FIX {β : Numerics.Radix} (emin : ) :
            ulp β (fixExp emin) 0 = bpow β emin

            The ULP at zero for a fixed-point grid is its fixed grid step.

            FIXFormat emin x says that x is exactly representable on the fixed grid with exponent emin.

            The predicate is phrased through an existential FloatRep β so that it composes with the rest of the rounding model (toReal, ULP bounds and so on).

            Instances For

              flxExp prec is the unbounded-exponent family.

              This is Flocq's FLX_exp: a floating-point format with no exponent bounds and mantissa precision prec. It is a convenient intermediate model for proofs because it removes the underflow and overflow corner cases while still tracking mantissa rounding.

              Instances For
                @[reducible, inline]
                abbrev FloatLib.Floats.Formats.Flocq.flxValidExp (prec : ) (h : 0 < prec) :

                flxExp prec satisfies ValidExp for positive precision.

                Instances For

                  flxExp prec satisfies the generic exponent axioms exactly when prec is positive.

                  The unbounded exponent selector associated with a checked precision.

                  Instances For

                    A checked precision automatically discharges the FLX exponent-validity obligation.

                    @[reducible, inline]

                    The FLX exponent selector is monotone for every precision parameter.

                    Instances For
                      @[reducible, inline]

                      The FLX exponent selector has bounded one-step growth.

                      Instances For

                        Exact representability predicate for FLX.

                        The precision is positive, and $x=m\beta^e$ for an integer mantissa satisfying $|m|<\beta^{\mathtt{prec}}$.

                        Instances For
                          theorem FloatLib.Floats.Formats.Flocq.not_flxFormat_of_nonpos {β : Numerics.Radix} (prec : ) (hprec : prec 0) (x : ) :

                          Nonpositive precision is rejected by the explicit FLX format predicate.

                          The unbounded FLX exponent function has no negligible exponent.

                          theorem FloatLib.Floats.Formats.Flocq.ulp_zero_FLX {β : Numerics.Radix} (prec : ) (hprec : 0 < prec) :
                          ulp β (flxExp prec) 0 = 0

                          Consequently, the generic ULP of zero is zero for FLX.

                          fltExp emin prec is the lower-exponent-bounded family with gradual underflow.

                          This is Flocq's FLT_exp. The exponent is bounded below by emin but has no upper bound, so the format models gradual underflow but not overflow, infinities, or NaNs. Gradual underflow is captured by taking max (e - prec) emin.

                          Instances For
                            @[reducible, inline]
                            abbrev FloatLib.Floats.Formats.Flocq.fltValidExp (emin prec : ) (h : 0 < prec) :
                            ValidExp (fltExp emin prec)

                            fltExp emin prec satisfies ValidExp for positive precision.

                            This validity witness connects proofs to an executable binary descriptor through BinaryInterchange.Model.fexpOf and BinaryInterchange.Model.roundAt.

                            Instances For
                              theorem FloatLib.Floats.Formats.Flocq.validExp_FLT_iff (emin prec : ) :
                              ValidExp (fltExp emin prec) 0 < prec

                              fltExp emin prec satisfies the exponent axioms exactly for positive precision.

                              The gradual-underflow exponent selector associated with a checked precision.

                              Instances For

                                A checked precision automatically discharges the gradual-underflow validity obligation.

                                @[reducible, inline]

                                The gradual-underflow FLT exponent selector has bounded one-step growth.

                                Instances For
                                  @[reducible, inline]

                                  The gradual-underflow FLT exponent selector is monotone.

                                  Instances For

                                    Exact representability predicate for FLT.

                                    The precision is positive, and $x=m\beta^e$ with $|m|<\beta^{\mathtt{prec}}$ and $\mathtt{emin}\le e$. In particular, every nonzero value has magnitude at least $\beta^{\mathtt{emin}}$.

                                    Instances For
                                      theorem FloatLib.Floats.Formats.Flocq.not_fltFormat_of_nonpos {β : Numerics.Radix} (emin prec : ) (hprec : prec 0) (x : ) :
                                      ¬FLTFormat emin prec x

                                      Nonpositive precision is rejected by the explicit FLT format predicate.

                                      FLT has a negligible-exponent witness at emin.

                                      theorem FloatLib.Floats.Formats.Flocq.ulp_zero_FLT {β : Numerics.Radix} (emin prec : ) (hprec : 0 < prec) :
                                      ulp β (fltExp emin prec) 0 = bpow β emin

                                      The ULP at zero for FLT is the smallest grid step $\beta^{\mathtt{emin}}$.