% Hexagon source adaptation of the published Zenodo edition. % Changes are limited to packaging, bibliography rendering, navigation and archive links. % Mathematical formulas and their order are preserved; see the local integrity record. \PassOptionsToPackage{expansion=false,nopatch=footnote}{microtype} \documentclass[11pt]{article} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage{lmodern,microtype} \usepackage{amsmath,amssymb,amsthm,mathtools} \usepackage[a4paper,margin=25mm,headheight=14pt]{geometry} \usepackage{booktabs,array,longtable} \usepackage{tikz,fancyhdr} \usepackage{xurl} \usepackage[colorlinks=true,allcolors=blue!45!black]{hyperref} \hypersetup{pdftitle={Certified rational-anchor filtering for exact GPU scans of power-residue runs},pdfauthor={Brice Pouly}} \pagestyle{fancy}\fancyhf{} \fancyhead[L]{\small Exact GPU scans of power-residue runs} \fancyhead[R]{}\fancyfoot[C]{\thepage} \renewcommand{\headrulewidth}{0.3pt} \newtheorem{theorem}{Theorem}[section] \newtheorem{proposition}[theorem]{Proposition} \newtheorem{lemma}[theorem]{Lemma} \theoremstyle{definition}\newtheorem{remark}[theorem]{Remark} \newcommand{\Fp}{\mathbb F_p} \newcommand{\Z}{\mathbb Z} \newcommand{\cl}{c_r} \newcommand{\data}{\texttt{results/gpu-algorithms/2026-10-02/}} \newcolumntype{P}[1]{>{\raggedright\arraybackslash}p{#1}} \title{Certified rational-anchor filtering\\ for exact GPU scans of power-residue runs} \author{Brice Pouly\thanks{Prepared with artificial-intelligence assistance; see the declaration at the end.}} \date{12 October 2026} \hypersetup{pdfsubject={Publication edition v1.0; 12 October 2026}} \usepackage{bookmark} \begin{document}\maketitle \begin{abstract} We study exact longest monochromatic runs of power-residue colourings, including neutral prefixes and least canonical witnesses. A certified rational cover represents every relevant interval inside a short signed character table. A reflection-compatible schedule retains an anchor; conservative filters reject only known contradictions, bilateral completion recovers the full run, and tie-preserving reduction selects its least witness. We prove this exact-success contract and describe its CUDA realization with separate arithmetic domains below $2^{32}$ and $2^{33}$. On one RTX 5090, two reserved cohorts give ratios $24.00$ and $10.95$ of sums of hot per-prime medians against the identified historical dense engine. A separate batch study gives throughput factors $1.23$--$2.58$ against an already optimized reference. The experiments have different timing boundaries and their factors are reported separately. Short-table multiplicative extraction has close algorithmic antecedents in cryptanalysis; our contribution is its certified organization for exhaustive maxima and witnesses and its measured implementation. Square-root-sized cover parameters do not give a general $O(\sqrt p)$ running-time bound. \end{abstract} \noindent\textbf{Keywords.} Multiplicative characters; monochromatic runs; Rabung construction; rational approximation; CUDA; reproducible computation. \section{Problem and contribution} Rabung's construction uses power-residue colourings to produce lower bounds for van der Waerden numbers~\cite{rabung}. A prime and a colour count encode the colouring succinctly, but the finite conditions must still be checked. Computing an exact run profile is therefore useful both for searching for candidate certificates and for building an experimental census. Distributed searches by Monroe provide an important computational predecessor~\cite{monroe,monroecode}. The published certificates paper separates GPU discovery from pointwise certificate verification~\cite{bounds,boundsv2}. The present paper treats the scanner itself as the object of study. Its exactness theorem concerns ordinary maxima, prefixes and canonical witnesses. The coverage proof and controlled measurements establish this computational contract independently of any census classification or limiting probability law. \paragraph{Reading contract.} A successful scan returns $(M_r,L_r,K_r,w_r)$: the largest ordinary run, the neutral prefix, the Rabung boundary threshold and the least start of a maximizing run. Section~\ref{sec:contract} fixes these conventions. Sections~3--4 establish coverage and conservative selection; Sections~5--6 explain profile sharing and execution; Sections~7--8 distinguish timings from implementation checks. Capacity refusal is a reported failure, not a statement that long runs are absent. The central difficulty is to reduce expensive character evaluations without assuming that long runs behave randomly. A probabilistic estimate for a typical maximum can guide experiments, but cannot justify discarding a candidate in an exact scan. We instead construct a geometric hitting set: every relevant interval has a rational representation with bounded numerator and denominator; a short monochromatic anchor then identifies a candidate whose maximal extent is reconstructed exactly. The contributions developed here are an integer certificate for the cover, a reflection-compatible anchor schedule, conservative bit filters, and an implementation that retains exact maxima, prefixes and canonical witnesses. The implementation combines adaptive warp partitioning, character-profile sharing and concurrent streams, with explicit failures for resource or domain violations. The measured gains have two distinct baselines: the historical dense engine, and a later qualified sparse engine. This distinction is essential to assessing the scale of the improvement. Minkowski's theorem, multiplicativity, Montgomery reduction and CUDA streams are established tools. Our claims concern their explicit assembly for this finite scanning problem and the archived measurements. The article does not claim priority for rational approximation or for any general-purpose GPU technique. The related work below identifies close algorithmic precedents. We make no claim that the primitives or their use for extracting sequences were invented here, and no exhaustive priority claim for the complete assembly. \paragraph{Scope.} The experiments use every $r\in\{2,\ldots,9\}$ dividing $p-1$, rather than only a fixed intersection of congruence classes. The optimized workers accept prime inputs $1000\le p<2^{33}$, using distinct 32-bit and wider paths. Type bounds do not promise successful execution for every input: table, seed and queue guards may refuse a case. Small-prime handling belongs to a separate exact preparation path. All measurements discussed here predate the completed atlas campaign. The atlas and new numerical bounds retain their own evidence; dissemination and evidence limits are collected in Section~\ref{sec:reproducibility}. \subsection{Related work and the precise contribution} First occurrences of power-residue runs were studied by Lehmer and Lehmer and by Rabung and Jordan~\cite{lehmer,rabungjordan}. Buell and Hudson computed longest quadratic-residue and nonresidue runs for primes below 420\,000~\cite{buell}. Their publisher's abstract and bibliography establish that the observable and a census of maxima are older. Their full paper and LSU report 83-017 were not obtained; their internal algorithm is therefore not claimed to differ from ours in every respect. Beullens, Beyne, Udovenko and Vitto~\cite{beullens}, Sections 3.2, 3.4 and 7.2, already exploit multiplicativity, arithmetic subsequences, denominators and reversal to extract many normalized sequences from a short table, with extensions to power-residue symbols. Their Section 3.1 also gives a deterministic table-search variant. Kalu\dj erovi\'c, Kleinjung and Kosti\'c~\cite{kkk}, Sections 3--5 and Appendix A, develop multiplicative extraction, reuse, reversal and bit-matrix transposition. These are close algorithmic precedents, rather than merely the same elementary identity. Their key-recovery contract does not automatically supply exhaustive run maxima and their canonical ties. Conversely, this different output contract does not erase the precedent for the primitives. We cite the revised ePrint text for these details; the related ANTS XIV article has a different title~\cite{kkkants}. Small modular representatives also belong to classical Thue and Euclidean methods and rational reconstruction~\cite{shoup,wang}. Reconstruction seeks a small fraction, often unique if it exists in a regime $2BD
p$ and ensures existence for every relevant interval. Neither the
lattice principle nor rational normalization is new. The contribution
claimed here is the cover--hitting-set--conservative-filter--completion
composition with a stated output contract, not priority for its ingredients.
\begin{table}[ht]
\centering\small
\begin{tabular}{P{.24\textwidth}P{.31\textwidth}P{.37\textwidth}}
\toprule Predecessor & Work and output & Relation to this scanner\\\midrule
Buell--Hudson & Quadratic run maxima and census & Same kind of observable; internal algorithm not inspected.\\
Monroe paper/code & Full power table, shared orders, maximum/prefix/boundary threshold & Dense precedent; no per-position exponentiation is required to fill the table; no canonical witness exposed by the inspected code.\\
Beullens et al.; Kalu\dj erovi\'c et al. & Short-table extraction, reversal, bit operations for key recovery & Direct precedent for primitives; different output and coverage obligations.\\
Thue/reconstruction & Bounded modular representatives; uniqueness/conditional reconstruction & Classical foundations; whole-window existence is the role of our explicit certificate.\\
This work & Certified window cover, complete folded anchor set, safe rejection, exact completion & Exact $M_r,L_r,K_r,w_r$ on successful execution under the stated hypotheses.\\
\bottomrule
\end{tabular}
\caption{Algorithmic comparison, not a common-machine timing comparison or
an assertion of universal priority.}
\end{table}
\section{Exact output contract}\label{sec:contract}
Fix an odd prime $p$ and an admissible $r\ge2$. Choose a surjective additive
label for a multiplicative character of order $r$,
\[
\cl:\Fp^{\times}\longrightarrow\Z/r\Z,
\qquad \cl(xy)=\cl(x)+\cl(y).
\]
For a primitive root $g$, one choice is $\cl(g^j)=j\bmod r$. The kernel
is the subgroup of $r$th powers; the choice of labels permutes the colours
and has no effect on equality of colours. We scan the ordinary integer
sequence $1,\ldots,p-1$. Zero is excluded, and an interval does not wrap
cyclically through it.
Let $M_r$ be the largest length of a constant-colour interval, and let $L_r$
be the longest initial interval with colour zero. Thus $L_r\ge1$, since
$\cl(1)=0$. For a maximal run $[l,h]$, its reflected partner is
$[p-h,p-l]$, because
\begin{equation}\label{eq:reflection}
\cl(p-x)=\cl(x)+\sigma_r,\qquad
\sigma_r=\cl(-1)=\frac{p-1}{2}\bmod r.
\end{equation}
The canonical witness is the least start among all runs of length $M_r$;
reflection allows each pair to contribute $\min(l,p-h)$. A tie is part of
the output contract, not a dispensable side effect of finding the maximum.
The scanner also reports
\begin{equation}\label{eq:K}
K_r=\max\{M_r+1,\, B_r\},\qquad
B_r=\begin{cases}
2L_r+2,&r\mid(p-1)/2,\\
L_r+2,&r\nmid(p-1)/2.
\end{cases}
\end{equation}
Here $B_r$ is a boundary threshold and is unrelated to the table radius
$B$ used below. Criterion (a) for a requested length $k$ checks $p>k$ and
$M_r 4p.
\end{equation}
For every interval $x,x+1,\ldots,x+H$ in $\{1,\ldots,p-1\}$, there are
integers $a,d$ with $1\le d\le D$, $\gcd(a,d)=1$ and
\[
a\equiv dx\pmod p,\qquad |a+jd|\le B\quad(0\le j\le H).
\]
None of these numerators is zero.
\end{theorem}
\begin{proof}
The lattice
\[
\Lambda_x=\{(a,d)\in\Z^2:a\equiv dx\pmod p\}
\]
has basis $(p,0),(x,1)$ and determinant $p$. Apply the determinant-one
shear $(a,d)\mapsto(A,d)=(a+Hd/2,d)$. In these coordinates the centrally
symmetric convex body
\[
\mathcal C=\{(A,d):|d|\le D,\ |A|+H|d|/2\le B\}
\]
has area
\[
\int_{-D}^{D}(2B-H|d|)\,\mathrm d d=4BD-HD^2>4p.
\]
Minkowski's theorem supplies a nonzero lattice point. If $d=0$, then
$a$ is a nonzero multiple of $p$ with $|a|\le B 0$. The convex-body inequality bounds both endpoints
$a$ and $a+Hd$ by $B$ in absolute value, hence every intermediate numerator.
If $s=\gcd(a,d)>1$, divide both coordinates by $s$. Since $s\le d 404=4p$. The window $19,\ldots,23$ has numerator
row $-25,-21,-17,-13,-9$, since $-25+4j\equiv4(19+j)\pmod{101}$.
Multiplicativity reads its colours in the signed table after subtracting
the common label of $4$. With $t=3$, spacing $s=q-t+1=3$ and phase
$\phi=1$, the folded anchor has $b=17=4\cdot4+1$: its quotient
$n=4$ satisfies $n\equiv1\pmod3$. Completion uses
$x=-17\cdot4^{-1}=21\pmod{101}$ and recovers $[19,25]$.
Its reflected partner is $[76,82]$, so its canonical start is $19$.
A literal character scan gives $(M_2,L_2,K_2,w_2)=(7,1,8,19)$.
This arithmetic example illustrates the cover, selection and completion;
it is below the optimized workers' accepted range and is not a GPU timing
or an additional qualification input.
\subsection{Choosing parameters without trusting floating point}
On the branch $HD^2\le4p$, the least table radius satisfying the strict
area inequality is
\begin{equation}\label{eq:Bchoice}
B=\left\lfloor\frac{4p+HD^2}{4D}\right\rfloor+1.
\end{equation}
The branch condition also ensures $HD\le2B$. The implementation checks all
of~\eqref{eq:certificate} using integer arithmetic after choosing parameters;
a rounded square root can propose a candidate, but cannot certify it.
Table capacities and signed filter indices impose additional guards.
Ignoring integer rounding, let $D_0=2\sqrt{p/H}$ and choose $D=D_0/n$.
Then the area boundary gives
\begin{equation}\label{eq:volume}
B\simeq\sqrt{Hp}\left(\frac n2+\frac1{2n}\right),\qquad
BD\simeq p(1+n^{-2}).
\end{equation}
Changing $n=2$ to $n=4$ reduces this rectangle proxy from $1.25p$ to
$1.0625p$, while increasing the table radius. Larger tables put additional
pressure on cache and shared memory. This is an architectural tradeoff,
not a theorem that larger $n$ is always faster.
\begin{figure}[ht]
\centering
\begin{tikzpicture}[scale=0.9]
\fill[blue!8] (-2.5,-1.25)--(2.5,-1.25)--(3.8,0)--(2.5,1.25)--(-2.5,1.25)--(-3.8,0)--cycle;
\draw[blue!65!black,thick] (-2.5,-1.25)--(2.5,-1.25)--(3.8,0)--(2.5,1.25)--(-2.5,1.25)--(-3.8,0)--cycle;
\draw[->](-4.3,0)--(4.4,0) node[right]{$A$};
\draw[->](0,-1.7)--(0,1.8) node[above]{$d$};
\node[below right] at (3.8,0){$B$};
\node[above left] at (0,1.25){$D$};
\node[below left] at (0,-1.25){$-D$};
\node at (0.2,0.62){$|A|+H|d|/2\le B$};
\end{tikzpicture}
\caption{The symmetric clipped cover in sheared coordinates. Its area is
$4BD-HD^2$. The diagram illustrates the certificate, not a measured work count.}
\label{fig:cover}
\end{figure}
\section{Anchors, conservative rejection and exact completion}\label{sec:anchors}
The cover supplies a bounded arithmetic progression of numerators for any
run worth retaining. The implementation enumerates short anchors from this
representation, filters them in words of 32 candidate bits, and extends the
survivors to their true boundaries in the original sequence.
\subsection{A reflection-compatible hitting set}
Suppose a run contains a $q$-window and $3\le t\le q$. There are
$s=q-t+1$ possible starts for a $t$-anchor within that window. Along a
rational row these starts have numerators differing by $d$. A periodic
selection with period $s$ therefore hits at least one of them.
The signed table is folded using reflection. It is useful to make the
selection commute with that fold, rather than relying on a favourable
location of the run.
\begin{lemma}[Symmetric anchor schedule]\label{lem:schedule}
For the increasing representation $a,a+d,\ldots,a+(t-1)d$, define
$b=a+(t-1)d$. The same anchor, in descending order, is
$(b,b-d,\ldots,b-(t-1)d)$. Negating and reversing it sends its first
numerator to $(t-1)d-b$. For $d>2$ and a primitive pair $(b,d)$, write
$b=nd+c$, $0