Level 3: counting the ones of a short word, by a table indexed by its value #
This is the base of the Bit Sum Lemma and the place where its circularity is broken. Levels 1 and 2 reduce “count the ones of a word” to “count the ones of a shorter word”, and that cannot go on for ever: at the bottom something has to count outright. Here it is, and the trick is that a lookup is a bit read at an index, so a table indexed by the value of a short word costs nothing that a product would cost:
Guess a table
Dcut into sections of2 ^ ℓbits, one per possible count. The bit of sectioncat offsetvsays “vhascones”. Sections are the boundary set ofLogTime/BitSum/Blocks.lean, so the walk over counts is a walk over boundaries, and the entry forvin sectioncis at the indexboundary + v– an addition.
Why this pins the table, and pins it locally #
The table is not defined, it is constrained, by three conditions that mention
only neighboring sections (DescriptiveComplexity.BitSum.TableOk):
- section
0is set exactly atv = 0– no ones means no word; - no later section is set at
v = 0; - section
c + 1is set atvexactly when sectioncis set atvwith its lowest one cleared (DescriptiveComplexity.BitSum.ClearLow).
Every one of those is a recursion on the value, never on the count, so no
condition ever has to say “and now do this c times”. Soundness
(DescriptiveComplexity.BitSum.table_sound) is then an induction on the count,
and it needs nothing about the layout beyond the table fitting – the discipline
LogTime/Pow.lean established.
Two things the conditions do not say #
They do not say where the table stops: sections above ℓ are all zero and
satisfy the recursion, so the guess simply runs out of ones to describe. And the
step is guarded by DescriptiveComplexity.IsLowIx, for the reason the
counter's step is: above the top position an element has no bits, so a condition
demanded there would be unsatisfiable rather than merely idle.
The table #
The conditions on the table: the bit of the section of count c at
offset v says “v has c ones”, pinned by a recursion on v alone.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
The table says what it is meant to say: the entry of the section of
count j at offset v holds exactly when v has j ones. The induction is on
the count; each step is one application of the recursion on the value.
Dependency graph
The table exists: its bit at the index i says that the value i names
has the count i names, which is a statement about i alone – so the guess is a
bit vector, and it fits by DescriptiveComplexity.BitSum.table_lt.
Dependency graph
Counting the ones of a short word #
y is the number of ones of the l-bit word x: the level-3
certificate in one existential – the section width, the boundaries, the counter,
the table, and the section whose counter is y, whose entry at x is set.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
The certificate is sound: whatever is guessed, the section it points at
is the one holding the count of x.
Dependency graph
The certificate exists, once the table fits and the counter's fields are wide enough: this is the completeness half of level 3, and every element it guesses has already been built.
Dependency graph
Definability #
The table's conditions are first-order in the bit logic.
Dependency graph
Level 3 is a formula: the whole certificate, guessed in one block.