Native heavy extraction and light placement #
The input, unsigned residue array and histogram are supplied by the actual Count.program.
One scan copies heavy integers, in input order, to a compact output. Each light integer is
tagged and placed directly in the packed node array. The third pass negates its integer and
its residue, and writes both copies required by arrZ.
The mathematical comparator is Anthropic's Buckets.lean
and NodeArray.lean at formal-math@16a5ce41304fcdaea4e0be7c132e1c361dc26da5.
The native code, encoding arithmetic and execution proofs here are original. No Light
execution theorem or source-machine simulation is assumed.
Main definitions #
Place.program: a fixed scan with runtime bases, length, modulus, tag and column.Place.heavyList: compact heavy elements in input order.Place.memory: exact writes of a prefix of the scan, including both third-column copies.
References #
Input array base.
Unsigned residue array base.
Input length.
Histogram base.
Compact heavy output base.
Packed node output base.
Positive modulus, decoded unsigned.
Twice the positive tag added to a light integer.
Column in a four-cell group.
Distance to the second write: zero for X/Y, 4M for Z.
Zero for X/Y, one for Z.
Input cursor.
Number of heavy integers already written.
Temporary address.
Current remainder.
Current value and its tagged encoding.
Twice the current magnitude.
Current input sign.
Constant one.
Constant two.
Constant four.
Constant zero.
Current histogram count.
Integer contribution before the positive tag.
The target index is exactly the residue of the signed contribution.
The compact array is the input subsequence selected by the histogram test.
The native compact output has exactly the existing heavy subset as its underlying set.
Copy a heavy integer without changing its signed encoding.
Tag a light integer using its magnitude and sign, then write its required cells.
Every iteration reads the original integer, its unsigned key and its exact bucket size.
The same finite code handles every input length, width, modulus and output length.
All runtime parameters survive the scan.
A scan can only change its heavy capacity block and its packed output block.