TorchLean API

FloatLib.Numerics.Core.Representation

Encoded numerical formats #

EncodedFormat F assigns a code type and finite scalar domain to a format identity F. Codes can be machine words, limb records, blocks, codebook indices, or runtime-sized values.

FormatSemantics F supplies the denotation separately. A real-valued denotation can then be noncomputable while storage and arithmetic remain executable. Together the classes define a NumericalSystem; optional capabilities add laws and operations as needed.

These interfaces also cover representations without a radix/exponent description. For the radix-based generic-format approach, see Boldo and Melquiond, Flocq: A Unified Library for Proving Floating-Point Algorithms in Coq (2011), https://doi.org/10.1109/ARITH.2011.40.

class FloatLib.Numerics.EncodedFormat (F : Type u) :
Type (max (v + 1) (w + 1))

Runtime storage and finite scalar domain associated with the format identity F.

  • Code : Type v

    Concrete runtime storage selected by F.

  • Scalar : Type w

    Ordinary finite semantic domain selected by F.

Instances
    class FloatLib.Numerics.FormatSemantics (F : Type u) [EncodedFormat F] :
    Type (max u_1 u_2)

    Complete semantic interpretation of a format's runtime codes.

    Instances
      @[reducible, inline]

      Runtime storage selected by F.

      Instances For
        @[reducible, inline]

        Ordinary finite semantic domain selected by F.

        Instances For
          @[instance_reducible]

          Build format semantics when every stored code has an ordinary finite interpretation.

          Instances For
            @[inline]

            Complete interpretation of one code in F.

            Instances For
              @[reducible]

              The general numerical system assembled from a format's storage and denotation.

              The wrapper is reducible so Lean can reuse structures on FormatCode F and FormatScalar F through NumericalSystem.Code and NumericalSystem.Scalar without forwarding instances.

              Instances For
                @[reducible, inline]

                A format code represents the ordinary scalar value.

                Instances For
                  class FloatLib.Numerics.HasExactSemantics (F : Type u) [EncodedFormat F] [FormatSemantics F] :
                  Type (max (max u_1 u_2) (x + 1))

                  Optional rich exact semantics for a type-directed format.

                  This capability is proof-facing. Executable kernels should call concrete family decoders rather than project through exactSemantics in an arithmetic loop.

                  Instances