TorchLean API

FloatLib.Floats.Formats.BinaryInterchange.StaticByte.Core.Runtime

Static-byte runtime representation #

Nominal binary formats of at most eight bits share a compact byte carrier, family interface, model adapters, raw table execution, and exact operation specifications. The persistent code is a UInt8 together with an erased range proof. No FloatFormat, BitVec, or arbitrary-precision integer is stored in a value.

Each standards package supplies a nominal type and a Family instance. The instance fixes the binary-interchange proof model, proves that its codes fit in one byte, and names the monomorphic kernels used at runtime. Table construction is isolated in Core.Construction; conversion and lifting theorems are isolated in Core.Proof.

Nominal Family and Plans.TablePlan instances use always_inline so the compiler can eliminate their closed format metadata and policy branches at a public call. The named table definitions remain shared and lazy.

OCP, IEEE, ONNX, and custom format packages can share these carrier and refinement interfaces. Each descriptor still determines its own exceptional-value policy.

Lean represents subtypes identically to their data carrier, so Code F has the runtime representation of UInt8; its bound is proof-only. See Lean Init.Prelude, https://github.com/leanprover/lean4/blob/v4.34.0/src/Init/Prelude.lean#L641-L643.

benchmarks/scripts/checks/static-lowbit-codegen.sh checks the intended allocation and specialization properties.

@[reducible, inline]

Bit-exact binary-interchange model value used to specify and prove a static byte format.

Instances For
    @[reducible, inline]

    Direct byte code for one at-most-eight-bit binary-interchange model.

    The proof excludes patterns above the declared format width and is erased by Lean's compiler.

    Instances For
      @[inline]

      Interpret a direct byte code in its exact-width binary proof model.

      Instances For

        Six byte kernels and their refinement equations for one binary-interchange model.

        The executable fields consume and return direct byte codes. Their equations interpret those codes in the independent binary model and compare them with its specifications. A family may therefore select exhaustive native-index tables, direct byte arithmetic, or a model adapter independently for each operation without changing the universal carrier.

        Instances For

          Descriptor and certified kernels for a nominal static-byte format.

          The class contains no global registry. It is resolved from the nominal format type, and concrete packages provide monomorphic kernel fields rather than selecting a backend at runtime.

          • format : FloatFormat

            Binary-interchange format used as the proof model.

          • width_le_eight : (format F).bitWidth 8

            Every valid code fits in one byte.

          • kernels : Kernels (format F)

            Statically selected proved kernels.

          Instances

            Inspection metadata for a nominal static-byte format.

            This metadata is separate from Family so standards text never enters the runtime dictionaries used by arithmetic.

            • standard : String

              Standard or specification that defines the nominal format.

            Instances
              @[reducible, inline]

              Direct byte carrier selected by a static-byte family.

              Instances For
                @[inline]

                Convert a valid byte code to the exact-width binary proof model.

                Instances For
                  @[inline]
                  def FloatLib.Floats.Formats.BinaryInterchange.StaticByte.modelToByteCode (format : FloatFormat) (width_le_eight : format.bitWidth 8) (value : ModelValue format) :
                  ByteCode format

                  Convert one model value to its direct valid byte code.

                  Instances For

                    View an at-most-eight-bit binary-interchange model through the shared finite-encoding backend.

                    The encoding is a proved bijection between exact model values and their stored words. It is the only binary-specific input required by the format-independent TinyTable implementation.

                    Instances For
                      @[inline]
                      def FloatLib.Floats.Formats.BinaryInterchange.StaticByte.runBinary {format : FloatFormat} {spec : ModelValue formatModelValue formatModelValue format} (width_le_eight : format.bitWidth 8) (kernel : ExecFloat.Backend.TinyTable.CertifiedBinary (encoding format width_le_eight) spec) (left right : ByteCode format) :
                      ByteCode format

                      Execute a shared certified binary table on the static-byte carrier.

                      Instances For
                        @[inline]
                        def FloatLib.Floats.Formats.BinaryInterchange.StaticByte.runUnary {format : FloatFormat} {spec : ModelValue formatModelValue format} (width_le_eight : format.bitWidth 8) (kernel : ExecFloat.Backend.TinyTable.CertifiedUnary (encoding format width_le_eight) spec) (value : ByteCode format) :
                        ByteCode format

                        Execute a shared certified unary table on the static-byte carrier.

                        Instances For
                          @[inline]
                          def FloatLib.Floats.Formats.BinaryInterchange.StaticByte.runTernary {format : FloatFormat} {spec : ModelValue formatModelValue formatModelValue formatModelValue format} (width_le_eight : format.bitWidth 8) (kernel : ExecFloat.Backend.TinyTable.CertifiedTernary (encoding format width_le_eight) spec) (left right addend : ByteCode format) :
                          ByteCode format

                          Execute a shared certified ternary table on the static-byte carrier.

                          Instances For
                            @[inline]
                            def FloatLib.Floats.Formats.BinaryInterchange.StaticByte.modelTernary (format : FloatFormat) (width_le_eight : format.bitWidth 8) (op : ModelValue formatModelValue formatModelValue formatModelValue format) (left right addend : ByteCode format) :
                            ByteCode format

                            Adapt a model-level ternary operation to the direct byte carrier.

                            Instances For
                              @[inline]

                              Convert one family model value to its direct valid byte code.

                              Instances For
                                @[inline]

                                Interpret a universal static-byte value in the binary proof model.

                                Instances For
                                  @[inline]

                                  Repack a binary proof-model value into the direct static-byte carrier.

                                  Instances For
                                    @[inline]

                                    Construct a static-byte value from a natural bit pattern, reduced to the format width.

                                    Instances For
                                      @[inline]

                                      Read the direct byte stored by a static-byte value.

                                      Instances For
                                        @[inline]

                                        Read the canonical natural-number bit pattern.

                                        Instances For

                                          Static-byte addition specification lifted from the binary proof model.

                                          Instances For

                                            Static-byte subtraction specification lifted from the binary proof model.

                                            Instances For

                                              Static-byte multiplication specification lifted from the binary proof model.

                                              Instances For

                                                Static-byte division specification lifted from the binary proof model.

                                                Instances For

                                                  Static-byte square-root specification lifted from the binary proof model.

                                                  Instances For

                                                    Static-byte fused multiply-add specification lifted from the binary proof model.

                                                    Instances For