TorchLean API

FloatLib.Floats.Formats.Flocq.Theory.Format.Digits

Integer Digits, Scaling, and Slices #

These definitions are the effective integer layer used by radix-based rounding algorithms. Signed division and remainder use Int.tdiv and Int.tmod, matching Flocq's quotient and remainder toward zero rather than Lean's Euclidean / and % operations.

Integer radix power, with the Flocq convention that negative powers are zero.

Instances For
    @[simp]

    At nonnegative exponents, intPower is the ordinary natural radix power.

    @[simp]

    At negative exponents, the integer radix-power convention returns zero.

    The zeroth integer radix power is one.

    The signed radix digit at position k.

    Instances For
      @[simp]

      Every radix digit of zero is zero.

      @[simp]

      Signed digit extraction commutes with integer negation.

      theorem FloatLib.Floats.Formats.Flocq.digit_of_neg_index (β : Numerics.Radix) (n : ) {k : } (hk : k < 0) :
      digit β n k = 0

      Integer digit positions below zero contain no digit.

      Every signed digit has absolute value strictly smaller than the radix.

      Shift an integer left for nonnegative k, and right with truncation for negative k.

      Instances For
        theorem FloatLib.Floats.Formats.Flocq.scale_of_nonneg (β : Numerics.Radix) (n : ) {k : } (hk : 0 k) :
        scale β n k = n * intPower β k

        A nonnegative scale multiplies by the corresponding radix power.

        theorem FloatLib.Floats.Formats.Flocq.scale_of_neg (β : Numerics.Radix) (n : ) {k : } (hk : k < 0) :
        scale β n k = n.tdiv (intPower β (-k))

        A negative scale divides toward zero by the corresponding positive radix power.

        @[simp]

        Scaling the zero value gives zero.

        @[simp]

        A zero-place scale leaves the integer unchanged.

        @[simp]

        Radix scaling commutes with integer negation.

        Extract width radix digits beginning at start; negative widths produce zero.

        Instances For
          @[simp]
          theorem FloatLib.Floats.Formats.Flocq.slice_zero_value (β : Numerics.Radix) (start width : ) :
          slice β 0 start width = 0

          Every radix slice of zero is zero.

          theorem FloatLib.Floats.Formats.Flocq.slice_of_neg_width (β : Numerics.Radix) (n start : ) {width : } (hwidth : width < 0) :
          slice β n start width = 0

          A negative-width radix slice is empty and therefore evaluates to zero.

          theorem FloatLib.Floats.Formats.Flocq.slice_abs_lt_power (β : Numerics.Radix) (n start : ) {width : } (hwidth : 0 width) :
          |slice β n start width| < intPower β width

          A nonnegative-width slice has absolute value below the corresponding radix power.

          @[simp]
          theorem FloatLib.Floats.Formats.Flocq.slice_neg (β : Numerics.Radix) (n start width : ) :
          slice β (-n) start width = -slice β n start width

          Radix slicing commutes with integer negation.

          Number of base-β digits in the absolute value of an integer.

          Instances For
            @[simp]

            Zero has no significant radix digits.

            @[simp]

            Radix digit count depends only on the integer's absolute value.

            theorem FloatLib.Floats.Formats.Flocq.digits_pos {β : Numerics.Radix} {n : } (hn : n 0) :
            0 < digits β n

            Every nonzero integer has a positive radix digit count.

            theorem FloatLib.Floats.Formats.Flocq.digits_bounds (β : Numerics.Radix) {n : } (hn : n 0) :
            β.base ^ (digits β n - 1) n.natAbs n.natAbs < β.base ^ digits β n

            A nonzero integer lies between consecutive powers selected by its digit count.

            The radix digit count of a positive integer is the magnitude of its real embedding.

            theorem FloatLib.Floats.Formats.Flocq.intCast_lt_bpow_digits (β : Numerics.Radix) {n : } (hn : 0 < n) :
            n < bpow β (digits β n)

            A positive integer is strictly below the radix power selected by its digit count.

            theorem FloatLib.Floats.Formats.Flocq.intCast_add_one_le_bpow_digits (β : Numerics.Radix) {n : } (hn : 0 < n) :
            ↑(n + 1) bpow β (digits β n)

            The successor of a positive integer does not exceed its next radix-power boundary.

            theorem FloatLib.Floats.Formats.Flocq.digits_unique (β : Numerics.Radix) {n : } (hn : n 0) {d : } (hd : 0 < d) (hlower : β.base ^ (d - 1) n.natAbs) (hupper : n.natAbs < β.base ^ d) :
            digits β n = d

            The power bounds uniquely determine the digit count of a nonzero integer.

            theorem FloatLib.Floats.Formats.Flocq.digits_mono_abs (β : Numerics.Radix) {n m : } (hn : n 0) (hnm : n.natAbs m.natAbs) :
            digits β n digits β m

            Digit count is monotone with respect to integer absolute value away from zero.

            theorem FloatLib.Floats.Formats.Flocq.digits_mul_le (β : Numerics.Radix) {n m : } (hn : n 0) (hm : m 0) :
            digits β (n * m) digits β n + digits β m

            A nonzero product uses at most the sum of the operand digit counts.

            A positive radix power has one more digit than its exponent.