The columns of a product, and the carry chain that adds one block of them #
The schoolbook product of two P-bit numbers is a sum of columns,
x · y = Σ_j c_j 2 ^ j, where c_j counts the pairs of set bits whose indices
add to j – a count the Bit Sum Lemma delivers, one column at a time
(DescriptiveComplexity.BitSum.mul_eq_colSum). What the Bit Sum Lemma does
not deliver is the outer sum: summing the 2 P weighted columns is an
iterated addition again, and every direct route to it fails – brute force,
carries guessed for the whole product, digit tables, Chinese remainders.
The way out is the block split, taken once, plus a guessed carry chain per
block. Cut the columns into blocks of g with 2 ^ g > P; the sum of one
block is Σ_{t<g} c_{a+t} 2 ^ t, and adding it column by column keeps a running
remainder below P – so the whole chain of a block is g remainders of g
bits, which fits in one element and is laid out with the boundary-set
device. That is exactly the “guess the carries” route that is ruled out for the
whole product (there it is P remainders, one element cannot hold
them); confined to a block it is affordable, and no further descent is needed.
This file is the ℕ side of that construction, with no structure in sight:
DescriptiveComplexity.BitSum.intervalSum– the weighted sum of a range of columns, and its concatenation law (DescriptiveComplexity.BitSum.intervalSum_append);DescriptiveComplexity.BitSum.carryChain– the remainders of the column-wise addition, defined as quotients of the partial sums, with the three equations the certificate checks: the first column (DescriptiveComplexity.BitSum.carryChain_base), one step (DescriptiveComplexity.BitSum.carryChain_step), and the final remainder being the high bits (DescriptiveComplexity.BitSum.carryChain_last);DescriptiveComplexity.BitSum.eq_packVal_of_windowsandDescriptiveComplexity.BitSum.packVal_evenOdd– reading a packed element off its windows, and re-assembling the even and the odd blocks into the sum of all columns;DescriptiveComplexity.BitSum.colWordN/DescriptiveComplexity.BitSum.colCountN– the word whose ones are one column, and the column count, with the product identityDescriptiveComplexity.BitSum.mul_eq_colSum.
Reading a bit as a number #
A bit, as the number it contributes: the digit of x at i.
Dependency graph
One more bit of a remainder: the next binary digit, in the form the carry chain steps through.
Dependency graph
A number is the sum of its bits, below any width that bounds it.
Dependency graph
The same, for a number known to fit.
Dependency graph
A number with no high bits is small: the converse of
Nat.testBit_lt_two_pow, which the guessed elements' vanishing conditions are
read through.
Dependency graph
A number with no low bits is a shifted quotient.
Dependency graph
A number whose bits are another's, shifted, is that number shifted: the
identity that reads a certificate's tail element as 2 ^ b times its value.
Dependency graph
Weighted sums of column ranges #
The weighted sum of a range of columns: Σ_{t<m} h (a + t) · 2 ^ t,
the value of the columns a, …, a + m - 1 read from position a.
Equations
- DescriptiveComplexity.BitSum.intervalSum h a m = ∑ t ∈ Finset.range m, h (a + t) * 2 ^ t
Instances For
Dependency graph
Dependency graph
One more column on top.
Dependency graph
Dependency graph
Concatenating two ranges of columns: the second range enters shifted by the width of the first. Every regrouping below is this identity.
Dependency graph
The sum of a range fits just above the widest column.
Dependency graph
The carry chain of one range #
The remainder after adding the columns up to a + t: what has been
accumulated and not yet written, i.e., the partial sum shifted below its first
unwritten position. The certificate stores these, one field per column.
Equations
- DescriptiveComplexity.BitSum.carryChain h a t = DescriptiveComplexity.BitSum.intervalSum h a (t + 1) / 2 ^ (t + 1)
Instances For
Dependency graph
The remainders stay small: below any bound on the columns.
Dependency graph
The first column: it splits into the lowest bit of the sum and the first remainder.
Dependency graph
One step of the chain: the incoming remainder plus the next column splits into the next bit of the sum and the outgoing remainder. This is the equation the certificate checks at every boundary.
Dependency graph
The final remainder is the high part: what is left after the last column is exactly the bits of the sum above the range.
Dependency graph
Reading a packed element off its windows #
An element whose windows are a packing's fields is the packing: equal windows at every field, no bits above, and the values fitting their fields pin the number bit by bit. This is how the soundness half reads the two half-sums off the guessed elements.
Dependency graph
Re-assembling the two half-sums: the packing of the even block sums plus the packing of the odd ones, shifted by one block, is the weighted sum of all the columns they cover. This is the identity behind the one addition of the certificate.
Dependency graph
The columns of a product #
The word of one column: its bit at i says that y has a one at i
and x a one at j - i – a pair of set bits whose indices add to j. It is a
sub-mask of y, so it is always the value of an element.
Equations
Instances For
Dependency graph
What the bits of a column word are.
Dependency graph
A column word is a sub-mask of y.
Dependency graph
The count of one column: the number of ones of its word among the
first P positions.
Equations
Instances For
Dependency graph
A column has no more ones than there are positions.
Dependency graph
The product is the weighted sum of its column counts – the schoolbook multiplication, columns grouped by weight, under the one condition that no pair of set bits reaches past the available positions.