Ternary prefixes and doubling carries #
This file gives the definitions used by the carry-language theory and its
bounded C3 corollary. Ternary digit lists are little-endian, following
Nat.digits.
Length of the canonical base-three expansion of n.
Equations
- GKPCarry.ternaryLength n = (Nat.digits 3 n).length
Instances For
The first depth ternary digits of n contain at least two 2s.
Equations
- GKPCarry.hasTwoTernaryTwosBelow depth n = (2 ≤ List.count 2 (List.take depth (Nat.digits 3 n)))
Instances For
Count outgoing carries while doubling a little-endian ternary digit list.
Equations
- GKPCarry.ternaryDoubleCarryCountAux [] x✝ = 0
- GKPCarry.ternaryDoubleCarryCountAux (digit :: digits) x✝ = GKPCarry.ternaryDoubleCarryStep x✝ digit + GKPCarry.ternaryDoubleCarryCountAux digits (GKPCarry.ternaryDoubleCarryStep x✝ digit)
Instances For
Count carries while doubling a little-endian ternary digit list.
Equations
- GKPCarry.ternaryDoubleCarryCount digits = GKPCarry.ternaryDoubleCarryCountAux digits 0
Instances For
Number of doubling carries visible in the first depth ternary digits.
Equations
- GKPCarry.prefixTernaryDoubleCarryCount depth n = GKPCarry.ternaryDoubleCarryCount (List.take depth (Nat.digits 3 n))
Instances For
theorem
GKPCarry.two_le_prefixTernaryDoubleCarryCount_of_hasTwoTernaryTwosBelow
{depth n : ℕ}
(h : hasTwoTernaryTwosBelow depth n)
:
Two digit-2s in a prefix force at least two ternary doubling carries.
A prefix cannot contain more doubling carries than the complete word.