Documentation

LeanPool.GKPCarry.BadCarryCounting

Counting deficient-carry ternary words #

The automaton gives an exact enumeration theorem. Among all ternary words of length m ≥ 2, precisely (m + 5) * 2 ^ (m - 2) create fewer than two carries when doubled. The theorem below uses the subtraction-free parameterization m = n + 2.

def GKPCarry.ternaryWordDigits {length : } (word : List.Vector (Fin 3) length) :

Convert a fixed-length word over Fin 3 to a list of natural digits.

Equations
Instances For
    @[reducible, inline]
    abbrev GKPCarry.BadCarryWordsFrom (state : BadCarryState) (length : ) :

    Fixed-length ternary words that remain outside .good when read from a given automaton state.

    Equations
    Instances For
      @[reducible, inline]
      abbrev GKPCarry.BadCarryWords (length : ) :

      Fixed-length ternary words whose doubling creates fewer than two carries.

      Equations
      Instances For
        def GKPCarry.badCarryWordsFromSuccEquiv (state : BadCarryState) (length : ) :
        BadCarryWordsFrom state (length + 1) (digit : Fin 3) × BadCarryWordsFrom (badCarryStateStep state digit) length

        Peeling the least significant digit gives the recursive decomposition of deficient-carry words.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For

          Recursive dynamic-programming count for words read from a given state.

          Equations
          Instances For

            The recursive count is the actual cardinality of the corresponding finite word type.

            Exact dynamic-programming count of deficient-carry ternary words.

            theorem GKPCarry.card_badCarryWords (n : ) :
            Fintype.card (BadCarryWords (n + 2)) = (n + 7) * 2 ^ n

            Headline enumeration theorem: among all ternary words of length n + 2, exactly (n + 7) * 2 ^ n have fewer than two doubling carries.

            theorem GKPCarry.card_allTernaryWords (n : ) :
            Fintype.card (List.Vector (Fin 3) (n + 2)) = 3 ^ (n + 2)

            The ambient set contains all 3 ^ (n + 2) ternary words.