Documentation

CslibFrontier.Algorithms.WordRAM.ThreeSum.ChanHe.NodeLayout

Disjoint memory layout for complete native Chan–He node construction #

Three supplied signed input arrays precede base. The allocated block consists of three count-prefixed heavy arrays (capacities n₀,n₁,n₂), the 4N packed cells, a reusable residue array of capacity n₀+n₁+n₂, and M histogram cells. Empty arrays still have a count cell.

Main definitions #

References #

This memory layout is an original implementation choice.

Runtime sizes and the fresh allocation base for one complete node.

  • base : ℕ

    The input arrays end no later than this address.

  • n : Fin 3 → ℕ

    The three supplied input lengths.

  • N : ℕ

    Common number of groups; the packed output has 4N cells.

  • M : ℕ

    Positive modulus, supplied by the parent prime search.

  • U : ℕ

    Bound on the magnitudes of this node's inputs.

Total input capacity, shared by the reusable residue workspace.

Count cell immediately preceding a compact heavy array.

Compact heavy output data starts one cell after its count.

All three compact output capacities precede the packed array.

A reusable residue array, after every permanent output.

A reusable histogram, after the full residue capacity.

One-past-end address of the complete allocated block.

Positive tag for the selected packed column.

Polynomial envelope for all addresses, signed values, encodings and histogram counters. Its fixed constant also covers code labels and all setup constants.

Each input fits the reusable residue capacity.

All three compact arrays and their count cells are disjoint, with the packed array next.

Every descriptor is inside its allocated output prefix.

Every descriptor precedes the packed array, including for empty inputs.

The allocated endpoint has a linear size formula.

Descriptor/capacity blocks end where the next one begins.

Every address and padding/tag value is covered by one polynomial envelope.

theorem Cslib.Algorithms.WordRAM.ThreeSum.ChanHe.NodePacking.Layout.count_budget_le (L : Layout) (j : Fin 3) (src t : ℕ) (hs : src ≤ L.base) (ht : t ≤ 4 * L.gap) :
src + L.scratch + L.hist + L.heavy j + L.packed + L.n j * L.n j + 2 * L.n j + L.M + 4 * L.N + 2 * t + 2 * L.U + 64 ≤ L.budget

The complete counting/placement call's budget is derived from the concrete node layout.

All three tags are positive, dominate the input magnitude, and fit the common tag bound.