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 into the shared dyadic execution carrier.

The sign and the encoded word are separate arguments, so callers that already classified the word can reuse the extraction. decodeFiniteDyadic below is the model-facing entry point.

Instances For
    @[inline]

    Decode a nonzero finite posit 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, and the theorem below proves the two agree.

    Instances For

      The one-pass execution decoder agrees with the field decoder used in proofs.

      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.Internal.toDyadic?]

            Decode the ordinary value into the shared exact dyadic carrier.

            none means NaR and nothing else. The unique posit zero maps to the canonical dyadic zero, and all other words keep 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.