TorchLean API

FloatLib.Floats.Formats.Posit.Model.Basic

Posit words and exceptional encodings #

The exact-width posit carrier, zero, and Not-a-Real words. These definitions support storage, equality, and bitwise reasoning. Regime parsing and finite decoding are defined in later modules.

Exact-width proof model for one posit descriptor.

Instances For
    def FloatLib.Floats.Formats.Posit.instDecidableEqModel.decEq {format✝ : Format} (x✝ x✝¹ : Model format✝) :
    Decidable (x✝ = x✝¹)
    Instances For
      @[instance_reducible]
      Instances For
        @[instance_reducible]
        instance FloatLib.Floats.Formats.Posit.instReprModel {format✝ : Format} :
        Repr (Model format✝)
        @[inline]
        def FloatLib.Floats.Formats.Posit.Model.ofBits {format : Format} (bits : BitVec format.bits) :
        Model format

        Wrap an exact-width bit vector.

        Instances For
          @[inline]

          Encode the low format.bits bits of a natural number.

          Instances For
            @[inline]

            Read the complete encoded word as a natural number.

            Instances For

              Every exact-width posit word lies below its descriptor's modulus.

              @[simp]

              Re-encoding a model's exact bit pattern preserves it.

              @[simp]
              theorem FloatLib.Floats.Formats.Posit.Model.toNatBits_ofNatBits_of_lt {format : Format} (bits : ) (hbits : bits < format.modulus) :
              (ofNatBits bits).toNatBits = bits

              In-range natural bits are unchanged by exact-width encoding.

              @[instance_reducible]
              @[inline]

              The unique zero encoding.

              Instances For
                @[inline]

                The unique Not-a-Real encoding, 100...0.

                Instances For
                  @[simp]

                  The unique zero value encodes as the all-zero word.

                  @[simp]

                  The unique NaR value encodes as the word containing only the sign bit.

                  Zero and NaR are distinct for every valid posit width.

                  @[inline]

                  Whether this is the unique zero code.

                  Instances For
                    @[inline]

                    Whether this is the unique Not-a-Real code.

                    Instances For
                      @[simp]

                      The zero predicate recognizes the canonical zero value.

                      @[simp]

                      The NaR predicate recognizes the canonical NaR value.

                      @[simp]

                      The canonical zero value is not NaR.

                      @[simp]

                      The canonical NaR value is not zero.

                      @[simp]
                      theorem FloatLib.Floats.Formats.Posit.Model.isNaR_eq_true_iff {format : Format} (value : Model format) :
                      value.isNaR = true value = nar format

                      The NaR predicate recognizes exactly the standard's unique NaR word.

                      @[simp]
                      theorem FloatLib.Floats.Formats.Posit.Model.isZero_eq_true_iff {format : Format} (value : Model format) :
                      value.isZero = true value = zero format

                      The zero predicate recognizes exactly the standard's unique zero word.