Documentation

CslibFrontier.Algorithms.WordRAM.ThreeSum.ChanHe.CountCall

Charged calls to Chan–He collision counting #

The prime searches keep their parameters outside the counting workspace. Each of the three set arrays has a fixed pair of base/length registers and its own result register. This module charges argument setup and result delivery as well as the complete native counting routine.

Main definitions #

Main results #

Counting workspace in a larger, fixed register file.

Length register for the selected set.

Base register for the selected set.

@[reducible, inline]

Residue scratch base.

@[reducible, inline]

Histogram base.

@[reducible, inline]

Encoded positive modulus.

Collision-count output register for the selected set.

@[reducible, inline]

Counting input base register.

@[reducible, inline]

Counting scratch base register.

@[reducible, inline]

Counting input length register.

@[reducible, inline]

Counting encoded-modulus register.

@[reducible, inline]

Counting histogram base register.

@[reducible, inline]

Counting result register.

Five runtime register copies deliver the counting arguments.

A complete native count call, including argument and result copies.

theorem Cslib.Algorithms.WordRAM.ThreeSum.ChanHe.CountCall.exec {w M : ℕ} (j : Fin 3) (x : WordRAM.Data 64) (values : ℕ → ℤ) (hM : 0 < M) (hmod : GenericRAM.Signed.Fits w ↑M) (hmodreg : x.regs modulus = WordRAM.Signed.encode ↑M) (hfit : ∀ i < x.regs (length j), GenericRAM.Signed.Fits w (values i)) (hs : WordRAM.Fits (w + 2) (x.regs (source j) + x.regs (length j))) (hk : WordRAM.Fits (w + 2) (x.regs scratch + x.regs (length j))) (hd : WordRAM.Fits (w + 2) (x.regs histogram + M)) (ht : WordRAM.Fits (w + 2) (x.regs (length j) * x.regs (length j) + x.regs (length j) + 1)) (hsk : x.regs (source j) + x.regs (length j) ≤ x.regs scratch) (hkd : x.regs scratch + x.regs (length j) ≤ x.regs histogram) (hinput : ∀ i < x.regs (length j), x.mem (x.regs (source j) + i) = WordRAM.Signed.encode (values i)) (hinj : Set.InjOn values ↑(Finset.range (x.regs (length j)))) :
∃ (y : WordRAM.Data 64), WordRAM.ExecWithin (w + 2) (program j) x y (34 * x.regs (length j) + 5 * M + 24) ∧ y.mem = Count.memory x.mem values (x.regs (length j)) M (x.regs scratch) (x.regs histogram) ∧ y.regs (result j) = ThreeSum.ChanHe.coll (Finset.image values (Finset.range (x.regs (length j)))) M ∧ ∀ (i : Fin 64), 28 ≤ ↑i → i ≠ result j → y.regs i = x.regs i

A native count call costs 34n+5M+24, including five argument copies and one result copy. The mathematical input is an injective array enumeration, as required by the existing set-based Chan–He collision count. All registers outside the workspace, except its chosen result, survive.