TorchLean API

FloatLib.Floats.Formats.Flocq.GenericFormat

Flocq-style generic formats as ordinary FloatLib formats #

The radix/exponent-function model of FloatRep supplies a representation-independent EncodedFormat interface.

The runtime code is a canonical integer-mantissa/integer-exponent pair. Its proof of canonicality is erased by Lean, while its denotation is the corresponding real number. The central theorem representable_iff_genericFormat proves that common-system representability is exactly genericFormat.

The definitions mirror the separation in Flocq between:

Primary references:

Type-level identity of the generic radix/exponent-function format.

The constructor carries no format data. The radix and exponent function are type parameters, so specialized users do not pass a runtime descriptor through arithmetic kernels.

Instances For
    @[reducible, inline]

    Canonical mantissa/exponent codes of a valid Flocq-style generic format.

    Instances For
      @[instance_reducible]
      @[simp]

      A canonical code represents exactly the real obtained from its mantissa and exponent.

      Common FloatLib representability coincides exactly with the Flocq-style generic_format predicate.

      noncomputable def FloatLib.Floats.Formats.Flocq.encodeGeneric (β : Numerics.Radix) (fexp : ) [ValidExp fexp] (x : ) (hx : genericFormat β fexp x) :

      Choose a canonical code for a value already known to belong to the generic format.

      This function is proof-facing and noncomputable. Concrete fixed-precision format families supply their own executable packing kernels.

      Instances For

        encodeGeneric denotes the real value from which it was chosen.

        noncomputable def FloatLib.Floats.Formats.Flocq.roundCode (β : Numerics.Radix) (fexp : ) [ValidExp fexp] (mode : RoundingMode) (x : ) :

        Round a real input and choose a canonical code for the rounded generic-format value.

        Instances For
          theorem FloatLib.Floats.Formats.Flocq.roundCode_represents (β : Numerics.Radix) (fexp : ) [ValidExp fexp] (mode : RoundingMode) (x : ) :
          Numerics.FormatRepresents (GenericFormat β fexp) (roundCode β fexp mode x) (mode.round x)

          The selected code denotes exactly the standard-mode rounded result.

          Relational quantization contract for standard Flocq-style rounding modes.

          Instances For

            roundCode implements the common relational quantization contract.

            Rounding an already representable real denotes that same real.