Most-significant-bit arithmetic for fusion trees #
The arithmetic expressions use multiplication, subtraction, Boolean operations and shifts. Their correctness is distinct from execution on a bounded-word RAM: the intermediate products need multiple physical words. The construction follows pages 7–8 of the MIT 6.851 Spring 2021 lecture 12 notes, https://courses.csail.mit.edu/6.851/spring21/lectures/L12.pdf.
Main definitions #
powerFlags: parallel comparisons against consecutive powers of two.smallMSB: count the successful comparisons and subtract one.clusterSummary: compress the nonzero-cluster markers by multiplication.widthMSB: two comparison/count stages for arbitrary input widths.
Main results #
smallMSB_eq_log2: correctness without a most-significant-bit primitive.clusterMarkers_guard: exact nonzero detection, without intercluster borrowing.widthMSB_eq_log2: full arithmetic correctness, including zero and nonsquare widths.widthMSB_virtual_bounds: all recorded arithmetic intermediates fit in6wbits.
References #
One at the low bit of each of s fields of width s + 1.
Instances For
Field i contains the comparison threshold 2 ^ i.
Instances For
A guard bit at the top of every field.
Instances For
Simultaneously compare z with every 2 ^ i, for i < s.
The output has a zero-or-one digit in every radix-2^(s+1) field.
Instances For
Multiplication counts the successful power-of-two comparisons.
Instances For
Most-significant set bit for a positive input of at most s bits.
The expression contains no logarithm or bit-search operation; constants depend only on s.
Instances For
The comparison expression has exactly the promised Boolean digits; subtraction does not borrow between fields and no correctness oracle is a hypothesis.
Counting the packed flags gives the number of powers of two at most the input.
The most significant bit of each of s clusters, each s bits wide.
Instances For
Set a cluster's marker exactly when the cluster is nonempty. The original high bits are separated before subtraction, preventing borrows between clusters.
Instances For
Shifts moving diagonal marker products to positions s² + i.
Instances For
Precomputed multiplier for the cluster markers.
Instances For
One bit per nonempty cluster, computed by multiply, shift, and mask. The final mask removes the off-diagonal multiplication terms.
Instances For
The masked product compresses exactly the original cluster-marker bits. Cross terms are collision-free everywhere, including outside the final retained interval.
The compressed summary fits in s bits, including for an empty input.
Two parallel power-comparison/count stages, with extraction of the selected cluster.
The value for zero is explicitly zero. All constants depend only on s.
Instances For
Ceiling of the square root, with zero width assigned zero clusters. This is a width-dependent preprocessing constant, not a run-time square-root instruction.
Instances For
The cluster capacity covers nonsquare widths and uses at most twice the input width.
Width-specific MSB arithmetic, including zero and nonsquare widths.
Instances For
Every arithmetic value in one powers-of-two comparison/count stage. This records intermediates before masking or shifting, so oversized products cannot be hidden.
Instances For
Every arithmetic value in marking and compressing the clusters, including the full product before shifting and masking.
Instances For
Every value in both comparison/count stages and the marking/compression stage fits
in 6w virtual bits. These bounds support a future multiword implementation; they do not
claim execution with a 6w-bit physical word.