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
- OddPrimeValuationDistribution.oddBase half = 2 * half + 1
Instances For
Outgoing carry while doubling one digit in the odd base
2 * half + 1.
Equations
- OddPrimeValuationDistribution.oddDoubleCarryStep half carry digit = (2 * digit + carry) / OddPrimeValuationDistribution.oddBase half
Instances For
Number of outgoing carries while doubling a little-endian word in an odd base.
Equations
- One or more equations did not get rendered due to their size.
- OddPrimeValuationDistribution.oddDoubleCarryCountAux half [] x✝ = 0
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.oddDoubleCarryStep_le_one
{half carry digit : ℕ}
(hcarry : carry ≤ 1)
(hdigit : digit < oddBase half)
:
theorem
OddPrimeValuationDistribution.oddDoubleCarryStep_zero_of_lt_succ
{half digit : ℕ}
(hdigit : digit < half + 1)
:
theorem
OddPrimeValuationDistribution.oddDoubleCarryStep_zero_of_lt
{half digit : ℕ}
(hdigit : digit < half)
:
theorem
OddPrimeValuationDistribution.oddDoubleCarryStep_one_of_le
{half digit : ℕ}
(hlower : half ≤ digit)
(hupper : digit < oddBase half)
:
theorem
OddPrimeValuationDistribution.oddDoubleDigitsAux_ofDigits
{half : ℕ}
{digits : List ℕ}
{carry : ℕ}
(hcarry : carry ≤ 1)
(hdigits : ∀ digit ∈ digits, digit < oddBase half)
:
Nat.ofDigits (oddBase half) (oddDoubleDigitsAux half digits carry) = 2 * Nat.ofDigits (oddBase half) digits + carry
theorem
OddPrimeValuationDistribution.padicValNat_oddPrime_centralBinom_ofDigits_eq_carryCount
(half : ℕ)
(hhalf : 0 < half)
[Fact (Nat.Prime (oddBase half))]
(digits : List ℕ)
(hdigits : ∀ digit ∈ digits, digit < oddBase half)
:
padicValNat (oddBase half) (Nat.ofDigits (oddBase half) digits).centralBinom = oddDoubleCarryCountAux half digits 0
In an odd prime base, Kummer's central-binomial valuation is exactly the number of carries produced by doubling any valid padded digit word.