Documentation

LeanPool.OddPrimeValuationDistribution.CarryArithmetic

Doubling carries in an arbitrary odd base #

Write an odd base as 2 * half + 1. This module defines the two-state doubling transducer in that base and proves its arithmetic correctness. When the base is prime, the carry count is exactly the prime-adic valuation of the central binomial coefficient.

The odd base represented by its lower half-size.

Equations
Instances For

    Outgoing carry while doubling one digit in the odd base 2 * half + 1.

    Equations
    Instances For

      Number of outgoing carries while doubling a little-endian word in an odd base.

      Equations
      Instances For

        Output digits while doubling in an odd base. The final carry is retained as the most significant output digit.

        Equations
        Instances For
          theorem OddPrimeValuationDistribution.oddBase_one_lt {half : } (hhalf : 0 < half) :
          1 < oddBase half
          theorem OddPrimeValuationDistribution.oddDoubleCarryStep_le_one {half carry digit : } (hcarry : carry 1) (hdigit : digit < oddBase half) :
          oddDoubleCarryStep half carry digit 1
          theorem OddPrimeValuationDistribution.oddDoubleCarryStep_lt_base {half carry digit : } (hhalf : 0 < half) (hcarry : carry 1) (hdigit : digit < oddBase half) :
          oddDoubleCarryStep half carry digit < oddBase half
          theorem OddPrimeValuationDistribution.oddDoubleCarryStep_local (half carry digit : ) :
          (2 * digit + carry) % oddBase half + oddBase half * oddDoubleCarryStep half carry digit = 2 * digit + carry
          theorem OddPrimeValuationDistribution.oddDoubleCarryStep_zero_of_lt_succ {half digit : } (hdigit : digit < half + 1) :
          oddDoubleCarryStep half 0 digit = 0
          theorem OddPrimeValuationDistribution.oddDoubleCarryStep_one_of_succ_le {half digit : } (hlower : half + 1 digit) (hupper : digit < oddBase half) :
          oddDoubleCarryStep half 0 digit = 1
          theorem OddPrimeValuationDistribution.oddDoubleCarryStep_zero_of_lt {half digit : } (hdigit : digit < half) :
          oddDoubleCarryStep half 1 digit = 0
          theorem OddPrimeValuationDistribution.oddDoubleCarryStep_one_of_le {half digit : } (hlower : half digit) (hupper : digit < oddBase half) :
          oddDoubleCarryStep half 1 digit = 1
          theorem OddPrimeValuationDistribution.oddDoubleDigitsAux_length (half : ) (digits : List ) (carry : ) :
          (oddDoubleDigitsAux half digits carry).length = digits.length + 1
          theorem OddPrimeValuationDistribution.oddDoubleDigitsAux_lt_base {half : } (hhalf : 0 < half) {digits : List } {carry : } (hcarry : carry 1) (hdigits : digitdigits, digit < oddBase half) (value : ) :
          value oddDoubleDigitsAux half digits carryvalue < oddBase half
          theorem OddPrimeValuationDistribution.oddDoubleDigitsAux_ofDigits {half : } {digits : List } {carry : } (hcarry : carry 1) (hdigits : digitdigits, digit < oddBase half) :
          Nat.ofDigits (oddBase half) (oddDoubleDigitsAux half digits carry) = 2 * Nat.ofDigits (oddBase half) digits + carry
          theorem OddPrimeValuationDistribution.oddDoubleDigitsAux_sum_add_carries {half : } {digits : List } {carry : } (hcarry : carry 1) (hdigits : digitdigits, digit < oddBase half) :
          (oddDoubleDigitsAux half digits carry).sum + (oddBase half - 1) * oddDoubleCarryCountAux half digits carry = 2 * digits.sum + carry
          theorem OddPrimeValuationDistribution.padicValNat_oddPrime_centralBinom_ofDigits_eq_carryCount (half : ) (hhalf : 0 < half) [Fact (Nat.Prime (oddBase half))] (digits : List ) (hdigits : digitdigits, digit < oddBase half) :

          In an odd prime base, Kummer's central-binomial valuation is exactly the number of carries produced by doubling any valid padded digit word.