TorchLean API

FloatLib.Floats.Formats.Posit.Model.Decode

Exact posit decoding #

Every posit word is classified, and ordinary values decode into the shared exact dyadic carrier. The one-pass compiled decoder is proved equal to the transparent field-based definition.

@[noinline]

Decode a nonzero finite posit code directly into the shared dyadic execution carrier.

The sign and complete encoded word are supplied separately so callers that already classified the word can reuse the same extraction. decodeFiniteDyadic below remains the model-facing boundary.

Instances For
    @[inline]

    Decode a nonzero finite posit directly into the shared dyadic execution carrier.

    This decoder computes sign restoration, regime scanning, and trailing-field powers once. decodeFields exposes the same quantities as independent projections for proofs; the theorem below establishes their equality.

    Instances For

      The one-pass execution decoder agrees exactly with the proof-facing field decoder.

      Complete exact interpretation of a posit word.

      Instances For
        def FloatLib.Floats.Formats.Posit.Model.instDecidableEqExactValue.decEq {format✝ : Format} (x✝ x✝¹ : ExactValue format✝) :
        Decidable (x✝ = x✝¹)
        Instances For
          @[instance_reducible]
          @[inline]

          Decode every posit word, retaining its exact tapered fields.

          Instances For
            theorem FloatLib.Floats.Formats.Posit.Model.decodeExact_eq_finite_iff {format : Format} (value : Model format) (fields : DecodedFields format) :
            value.decodeExact = ExactValue.finite fields value.isNaR = false value.isZero = false value.decodeFields = fields

            Characterize the nonzero finite branch of exact posit decoding.

            @[inline, implemented_by _private.FloatLib.Floats.Formats.Posit.Model.Decode.0.FloatLib.Floats.Formats.Posit.Model.toDyadicImpl?]

            Decode the ordinary value directly into the shared exact dyadic carrier.

            none identifies NaR exactly. The unique posit zero maps to the canonical dyadic zero; all other words retain their exact sign, integer significand, and binary scale.

            Instances For
              @[simp]

              Exact decoding recognizes the unique posit zero word.

              @[simp]

              Exact decoding recognizes the unique posit NaR word.

              @[simp]

              The unique posit zero maps to the canonical shared dyadic zero.

              @[simp]

              NaR has no ordinary dyadic interpretation.

              theorem FloatLib.Floats.Formats.Posit.Model.toDyadic?_eq_some_decodeFields {format : Format} (value : Model format) (hnar : value.isNaR = false) (hzero : value.isZero = false) :

              An ordinary posit decodes to the dyadic value of its exact tapered fields.