Documentation

CslibFrontier.Algorithms.WordRAM.ExactTriangle.Classes

Native residue-class query lists #

The fixed program calls QueryScan.program for each residue, storing the computed class count and its row-major coordinate pairs. Each class receives a disjoint block of capacity 2n². The cost of scanning once per residue is included; no class table is supplied as input.

This adapts the class builder in the pinned Theorem 17 program.

Main definitions #

Main results #

@[reducible, inline]

Source residue matrix.

@[reducible, inline]

Query-scanner output pointer.

@[reducible, inline]

Matrix side.

@[reducible, inline]

Query-scanner selected residue.

@[reducible, inline]

Query-scanner emitted count.

@[reducible, inline]

Array of class counts.

@[reducible, inline]

Array of disjoint query blocks.

@[reducible, inline]

Number of residues to enumerate.

@[reducible, inline]

Current class.

@[reducible, inline]

Constant one.

@[reducible, inline]

Count address.

@[reducible, inline]

Capacity in words of a query block.

Reuse the certified scanner with a disjoint register bank for the outer loop.

Compute the class's output pointer, scan, record its count, and advance.

The modulus is runtime data; the program itself is independent of it.

Fixed instruction graph, with no physical-width reads.

theorem Cslib.Algorithms.WordRAM.ExactTriangle.Classes.exec {w : ℕ} (x : WordRAM.Data 20) (R : ℕ → ℕ) (h1 : WordRAM.Fits w 1) (hinput : ∀ q < x.regs size * x.regs size, x.mem (x.regs src + q) = R q) (hsource : x.regs src + x.regs size * x.regs size ≤ x.regs counts) (hblocks : x.regs counts + x.regs modulus ≤ x.regs queries) (hcount : WordRAM.Fits w (x.regs counts + x.regs modulus)) (hquery : WordRAM.Fits w (x.regs queries + 2 * (x.regs size * x.regs size) * x.regs modulus)) (harea : WordRAM.Fits w (2 * (x.regs size * x.regs size))) :
∃ (y : WordRAM.Data 20), WordRAM.ExecWithin w program x y (x.regs modulus * (14 * (x.regs size * x.regs size) + 14) + 6) ∧ y.regs cursor = x.regs modulus ∧ (∀ j < x.regs modulus, y.mem (x.regs counts + j) = Nat.count (fun (q : ℕ) => R q = j) (x.regs size * x.regs size)) ∧ (∀ j < x.regs modulus, ∀ q < x.regs size * x.regs size, R q = j → y.mem (x.regs queries + 2 * (x.regs size * x.regs size) * j + 2 * Nat.count (fun (k : ℕ) => R k = j) q) = q / x.regs size ∧ y.mem (x.regs queries + 2 * (x.regs size * x.regs size) * j + 2 * Nat.count (fun (k : ℕ) => R k = j) q + 1) = q % x.regs size) ∧ ∀ (a : ℕ), ¬(x.regs counts ≤ a ∧ a < x.regs counts + x.regs modulus) → ¬(x.regs queries ≤ a ∧ a < x.regs queries + 2 * (x.regs size * x.regs size) * x.regs modulus) → y.mem a = x.mem a

Enumerate every residue class into actual count and coordinate arrays. The source matrix, count array and query capacity blocks must occur in that order. The final halt is excluded.