Documentation

DescriptiveComplexity.LogTime.BitSum.Ones

Counting ones, and the two atoms level 3 counts with #

The Bit Sum Lemma is about how many ones a word has, and this file says what that means and gives the two bit-level operations its base level (LogTime/BitSum/Table.lean) breaks the circularity with.

The count #

DescriptiveComplexity.BitSum.onesBelow x w is the number of ones of x among the first w positions. It is a Finset.card, not a recursion, because every statement about it is about changing one bit: clearing a set bit lowers the count by one (DescriptiveComplexity.BitSum.onesBelow_clear), and that single fact is the whole recursion the level-3 table is pinned by. The width is a parameter rather than “all of them” because levels 1 and 2 count ones below a position, not of a whole element.

The two atoms #

Counting ones, in ℕ #

The number of ones of x below the position w.

Equations
Instances For
    Dependency graph
    Dependency graph
    theorem DescriptiveComplexity.BitSum.onesBelow_clear {x x' i w : ℕ} (hi : x.testBit i = true) (hiw : i < w) (hx' : ∀ (j : ℕ), x'.testBit j = (x.testBit j && decide (j ≠ i))) :
    onesBelow x' w + 1 = onesBelow x w

    Clearing a one lowers the count by one – whichever one it is. The level-3 table clears the lowest, but the counting does not care.

    Dependency graph

    Clearing the lowest one #

    x' is x with its lowest one cleared: an index that is set with nothing set below it, and every other bit copied.

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

      Place values, in the index naming #

      p is the place value of the index i: its only bit is at i. What DescriptiveComplexity.powArithDef had to prove in FO(≤, +, ×) is, in the index naming, this one line.

      Equations
      Instances For
        Dependency graph

        Definability #