Documentation

LeanPool.GKPCarry.UnitCarryCounting

Counting deficient-carry ternary units #

Powers of two modulo a power of three range over unit residues, whose least significant ternary digit is nonzero. This file refines the full-word automaton count to that unit slice. Among unit words of length n + 3, exactly (n + 9) * 2 ^ n create fewer than two doubling carries.

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

Natural value of a fixed-length ternary word.

Equations
Instances For
    theorem GKPCarry.ternaryWordValue_lt {length : } (word : List.Vector (Fin 3) length) :
    ternaryWordValue word < 3 ^ length
    def GKPCarry.ternaryWordValueFin {length : } (word : List.Vector (Fin 3) length) :
    Fin (3 ^ length)

    The value of a ternary word, packaged in its complete residue block.

    Equations
    Instances For
      @[reducible, inline]

      Fixed-length ternary words with a nonzero least significant digit. The parameter is the tail length, so the full word has length length + 1.

      Equations
      Instances For
        theorem GKPCarry.ternaryWordValue_mod_three {length : } (word : List.Vector (Fin 3) (length + 1)) :
        ternaryWordValue word % 3 = word.head
        theorem GKPCarry.ternaryWordValue_coprime_three_pow_iff {length : } (word : List.Vector (Fin 3) (length + 1)) :
        (ternaryWordValue word).Coprime (3 ^ (length + 1)) word.head 0
        def GKPCarry.ternaryUnitWordsHeadTailEquiv (length : ) :
        TernaryUnitWords length { digit : Fin 3 // digit 0 } × List.Vector (Fin 3) length

        Split a unit word into its nonzero head digit and its remaining digits.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          theorem GKPCarry.card_ternaryUnitWords (length : ) :
          Fintype.card (TernaryUnitWords length) = 2 * 3 ^ length

          There are 2 * 3 ^ length unit words with length + 1 ternary digits.

          def GKPCarry.ternaryUnitWordToUnit (length : ) :
          TernaryUnitWords length(ZMod (3 ^ (length + 1)))ˣ

          Convert a ternary unit word to the corresponding unit modulo a power of three.

          Equations
          Instances For
            noncomputable def GKPCarry.ternaryUnitWordEquiv (length : ) :
            TernaryUnitWords length (ZMod (3 ^ (length + 1)))ˣ

            Unit words are equivalent to the full unit group modulo the corresponding power of three.

            Equations
            Instances For
              @[simp]
              theorem GKPCarry.ternaryUnitWordEquiv_apply (length : ) (word : TernaryUnitWords length) :
              (ternaryUnitWordEquiv length) word = ternaryUnitWordToUnit length word
              theorem GKPCarry.val_ternaryUnitWordEquiv_apply (length : ) (word : TernaryUnitWords length) :
              (↑((ternaryUnitWordEquiv length) word)).val = ternaryWordValue word
              theorem GKPCarry.ternaryDoubleCarryCountAux_append_replicate_zero (digits : List ) (count carry : ) (hcarry : carry 1) :

              Fixed-length leading zeroes do not change the carry count, so a word and the canonical ternary expansion of its value have the same count.

              Deficient-carry unit words #

              @[reducible, inline]

              Unit words whose doubling produces fewer than two carries.

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

                Remove the nonzero leading digit and record the automaton state it enters.

                Equations
                Instances For

                  Peeling the nonzero least significant digit splits deficient unit words into the states reached by digit 1 and digit 2.

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

                    Exact deficient-carry count on ternary unit words of length n + 3.