Multi-stage trimmed Yates transform on the word RAM #
Executes d coordinate passes of yatesTransform (+1 for zeta, -1 for Möbius) over an active
subset domain, falling back to precomputed stage tables below the cardinality cutoff (stagesCode,
exec_stagesCode).
Main definitions #
Cslib.Algorithms.WordRAM.TrimmedYates.IsStageMod: modified-register footprint ofstagesCode.Cslib.Algorithms.WordRAM.TrimmedYates.stagesCode:d-stage trimmed Yates loop storing stage trie roots atrRootsOut[0 .. d].
Main results #
Cslib.Algorithms.WordRAM.TrimmedYates.natAbs_yatesTransform_le,yatesTransform_natOne_eq_intOne: magnitude bound and scalar-cast bridge foryatesTransform.Cslib.Algorithms.WordRAM.TrimmedYates.stagesCode_preserves,exec_stagesCode: register frame andExecWithinspecification forstagesCode.
@[reducible, inline]
Registers potentially modified by stagesCode.
Allocate (d + 1) stage-root slots at Reg.free (returned in rRootsOut), store
rStageCurRoot as stage 0, and run d trimmed passes over dom.
theorem Cslib.Algorithms.WordRAM.TrimmedYates.exec_stagesCode {w d domPtr free initRoot fbBase cutoff signMode B₀ B : ℕ} {dom : List (Finset (Fin d))} {P_low : Finset (Fin d) → Prop} {initFn : ℕ → ℕ} {G : Finset (Fin d) → ℤ} (x : WordRAM.Data numRegs) (hz : x.regs rZero = 0) (ho : x.regs rOne = 1) (hd : x.regs Reg.dim = d) (hdp : x.regs Reg.entryPtr = domPtr) (hdl : x.regs Reg.entryCount = dom.length) (hcut : x.regs rStageCutoff = cutoff) (hsm : x.regs rSignMode = signMode) (hfbb : x.regs rFbRoots = fbBase) (hir : x.regs rStageCurRoot = initRoot) (hfree : x.regs Reg.free = free) (hfree_pos : 1 ≤ free) (hnd : dom.Nodup) (hdom : HoldsDom x.mem domPtr dom) (hdom_below : domPtr + 2 * dom.length ≤ free) (hdom_closed :
∀ X ∈ dom,
∀ coord ∈ X,
(cutoff ≤ (X.erase coord).card → X.erase coord ∈ dom) ∧ ((X.erase coord).card < cutoff → P_low (X.erase coord))) (htrie_init : HoldsTrie x.mem free d initRoot initFn) (hinit_eq : ∀ X ∈ dom, initFn (setMask X) = WordRAM.Signed.encode (G X)) (hfb_valid :
0 < cutoff →
fbBase + d ≤ free ∧ ∀ k < d,
∃ (fbFn : ℕ → ℕ),
HoldsTrie x.mem free d (x.mem (fbBase + k)) fbFn ∧ ∀ (Y : Finset (Fin d)),
Y.card < cutoff →
P_low Y →
fbFn (setMask Y) = WordRAM.Signed.encode
(BitString.yatesTransform (if signMode = 0 then 1 else -1) (List.take k (List.finRange d)) G Y)) (hG_le : ∀ (Y : Finset (Fin d)), (G Y).natAbs ≤ B₀) (hB : 2 ^ d * B₀ ≤ B) (hfit_val : WordRAM.Fits w (8 * B + 4)) (hfit_free : WordRAM.Fits w (free + d + 1 + d * (2 * d * dom.length + 2))) (hfit_mask : WordRAM.Fits w (2 ^ d)) :
have c := if signMode = 0 then 1 else -1;
∃ (y : WordRAM.Data numRegs) (endFree : ℕ),
WordRAM.ExecWithin w stagesCode x y (d * (dom.length * (32 * d + 63) + 22) + 7) ∧ y.regs rRootsOut = free ∧ y.regs Reg.free = endFree ∧ free + d + 1 ≤ endFree ∧ endFree ≤ free + d + 1 + d * (2 * d * dom.length + 2) ∧ (∀ k ≤ d,
∃ (stFn : ℕ → ℕ),
HoldsTrie y.mem endFree d (y.mem (free + k)) stFn ∧ ∀ X ∈ dom,
stFn (setMask X) = WordRAM.Signed.encode (BitString.yatesTransform c (List.take k (List.finRange d)) G X)) ∧ (∀ (a : ℕ), a < free ∨ endFree ≤ a → y.mem a = x.mem a) ∧ ∀ (i : Fin numRegs), ¬IsStageMod i → y.regs i = x.regs i