Documentation

Complexity.Foundations.Data.BitString.Counter

A binary counter #

A word of fixed length is a counter, read least significant bit first (Cslib.BitString.lsbValue). Increment (Cslib.BitString.increment) flips the trailing ones of the least significant end and the first zero, discarding the final carry, so it keeps the length and wraps around from the word of ones to the word of zeros. Counting from the word of m zeros enumerates the words of length m in order of value (Cslib.BitString.iterate_increment), each reached at its value (Cslib.BitString.iterate_increment_lsbValue). Exhaustive searches in polynomial space enumerate their candidates in this way, storing only the current one.

Main definitions #

Main results #

Binary increment, least significant bit first, discarding the final carry.

Instances For

    The value of a word in binary, least significant bit first.

    Instances For
      @[simp]

      Increment keeps the length.

      @[simp]

      Iterated increment keeps the length.

      A word of length m has value below 2 ^ m.

      Below the largest value, increment adds one.

      theorem Cslib.BitString.lsbValue_injective {w w' : List Bool} :
      w.length = w'.length → lsbValue w = lsbValue w' → w = w'

      Words of the same length are determined by their values.

      @[simp]

      The word of zeros has value 0.

      The word of ones has the largest value.

      A word with a true has a positive value.

      A word without true has value 0.

      The counter counts: the j-th iterate from the word of m zeros has value j, for j < 2 ^ m.

      Every word is reached by counting up to its value.