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. Lean erases its proof of canonicality, and its denotation is the corresponding real number. The central theorem representable_iff_genericFormat proves that common-system representability coincides with 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 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.

      It is noncomputable and meant for proofs. Concrete fixed-precision format families supply their own executable packing kernels.

      Instances For

        encodeGeneric denotes the real value from which it was chosen.

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

        Instances For

          The selected code denotes the rounded result in the given direction.

          Relational quantization contract for the six rounding directions of IEEERoundingMode.

          Instances For

            roundCode implements the common relational quantization contract.

            Rounding an already representable real denotes that same real.