\pdfoutput=1 \documentclass[11pt]{article} \usepackage[T1]{fontenc} \usepackage{lmodern} \usepackage{amsmath,amssymb,amsthm,mathtools,booktabs,array} \usepackage[margin=1in]{geometry} \usepackage[colorlinks=true,urlcolor=blue,citecolor=blue]{hyperref} \newtheorem{theorem}{Theorem} \newtheorem{lemma}[theorem]{Lemma} \newtheorem{corollary}[theorem]{Corollary} \newtheorem{proposition}[theorem]{Proposition} \theoremstyle{remark} \newtheorem{remark}[theorem]{Remark} \newcommand{\rem}{\operatorname{rem}} \newcommand{\calls}{\operatorname{calls}} \newcommand{\eq}{\operatorname{eq}} \newcommand{\coprime}{\perp\!\!\!\perp} % Lean identifiers, breakable after dots and underscores. \newcommand{\lean}[1]{\nolinkurl{#1}} \makeatletter\g@addto@macro\UrlBreaks{\do\_}\makeatother \emergencystretch=2em \title{The Euclidean algorithm is not optimal among uniform processes} \author{Jason Davies\thanks{\href{mailto:jason@jasondavies.com}{\nolinkurl{jason@jasondavies.com}}}} \date{October 28, 2026} \begin{document} \maketitle \begin{abstract} Reusing a stored Euclidean prefix, we show that every pair $a\geq b$ has a derivation of $\gcd(a,b)$ from $a,b$ with $O(\log a/\log\log a)$ applications of the remainder function alone; Euclid's algorithm needs order $\log a$ in the worst case. These derivations bound the intrinsic complexity of gcd and coprimeness by the same order, refuting Moschovakis's conjectured logarithmic lower bounds for uniform processes; by his best-uniform-process theorem, a single uniform process attains this bound. The Main Conjecture for algorithms remains open. We also prove an $\Omega(\log\log a)$ lower bound on this complexity for almost all coprime pairs and give, for each $\varepsilon>0$, a nondeterministic register program computing gcd that, on every input $a\geq b\geq1$, has a successful computation using at most $\varepsilon\log a+O(1)$ remainder calls. The upper bound also answers negatively an open problem of van den Dries and Moschovakis on the closure depth of the gcd. The main bounds and the refutations are formalised in Lean~4; the best-uniform-process theorem is cited. \end{abstract} \noindent\textbf{AI transparency statement.} The main result, its formalisation in Lean and the manuscript were produced by artificial intelligence. The human author initiated the broader research and directed the AI systems, but did not write the text. Details are given at the end of the paper. \section{Introduction}\label{sec:intro} Van den Dries and Moschovakis asked whether the Euclidean algorithm is optimal among its peers, the algorithms that compute the gcd from the remainder function \cite[p.~390]{vddm2004}. Moschovakis's Main Conjecture (in his monograph \cite{moschovakis2019}, henceforth ``the book'') asserts that for every algorithm $\alpha$ from $\rem$ and the zero test $\eq_0$ computing $\gcd(x,y)$ there is an $r>0$ such that $\alpha$ makes more than $r\log x$ remainder calls on infinitely many pairs $x>y\geq1$ \cite[p.~2]{moschovakis2019}. Uniform processes are the book's abstract model of computation from given primitives: every deterministic or nondeterministic recursive program induces one \cite[\S4A, Proposition~4A.1]{moschovakis2019}, but a uniform process need not be implemented by any finite program. Moschovakis stated versions of the conjecture for uniform processes in his 2012 notes and in the book; we refute both (Section~\ref{sec:certificates}). For algorithms the conjecture remains open. \paragraph{Derivations.} A \emph{derivation} from $a,b$ is a finite list that starts with $a,b$ and in which each further entry is $\rem(x,y)$ for earlier entries $x,y$ with $y>0$. Each further entry is one \emph{instruction}, that is, one remainder call. Entries already in the list are \emph{available} and may be reused; no constants and no other operations are supplied. Let $G(a,b)$ be the least number of instructions in a derivation containing $\gcd(a,b)$. Thus $G(a,0)=G(a,1)=0$. Arithmetic used in the proofs, such as subtraction, sorting or comparison, only selects instructions; it is never itself an instruction. So $G$ measures the length of a derivation, not the work of finding one. Logarithms are to base $2$. \begin{theorem}\label{thm:main} There is a constant $C$ such that for all integers $a\geq4$ and $0\leq b\leq a$, \[ G(a,b)\leq C\,\frac{\log a}{\log\log a}. \] \end{theorem} \paragraph{Idea of the proof.} The key is to store one short Euclidean prefix and reuse it many times. For sufficiently large $n$, let $a>b$ be coprime with $a\leq N=2^n$. Store a Euclidean prefix $r_0=a,r_1=b,\ldots,r_h$, where $h=3k$ and $k=2^{\lfloor(\log n)/2\rfloor}$ is about $\sqrt n$. If the prefix reaches a positive remainder at most $N^{3/4}$, take one further remainder and recurse on the resulting smaller pair. Otherwise, modulo every $m>N^{1/3}$, each residue class contains at most three prefix values, so the prefix occupies at least $k+1$ residue classes (Lemma~\ref{lem:prefix}). A close pair of residues lets three remainder calls produce a positive value below $m/k$ (Lemma~\ref{lem:gap}). Reusing the same prefix, we repeatedly shrink the modulus from $r_h$ to at most $N^{1/3}$ in $O(n/\log n)$ calls. Since $m$ need not be coprime to $a$ or $b$, two recursive gcd derivations on inputs at most $N^{1/3}$ finish: of $d=\gcd(m,\rem(a,m))$, and then of $\gcd(d,\rem(b,m))$. If $T(n)$ is the worst derivation cost for inputs at most $2^n$, the resulting recurrence \eqref{eq:recurrence} gives $T(n)=O(n/\log n)$. Taking $k$ about $n^c$ with $c$ close to $1$ instead sharpens the upper coefficient to $3+o(1)$ (Corollary~\ref{cor:three}): each contraction costs three calls and removes about $\log k\approx\log n$ bits, while the prefix stays negligible. \paragraph{Consequences and further results.} Section~\ref{sec:certificates} shows that $G(a,b)$ equals the intrinsic remainder-call complexity of coprimeness in the book's Euclidean structure on positive coprime inputs, and bounds those of gcd to within $2$ (Proposition~\ref{prop:certificates}). Theorem~\ref{thm:main} therefore refutes Conjecture~3.4 of \cite{moschovakis2012} and version (4F-5) of the Main Conjecture, and shows that lower bounds from the homomorphism method cannot exceed $O(\log a/\log\log a)$ for these problems. The book's best-uniform-process theorem then gives a single process with the same bound on every input. The upper bound also settles an open problem of van den Dries and Moschovakis on the closure depth of the gcd (Corollary~\ref{cor:closure-depth}). We also prove that $G(a,b)\geq(1-o(1))\log\log N$ for all but $o(N^2)$ coprime pairs $2\leq b0$, a nondeterministic register program with a successful computation costing at most $\varepsilon\log a+O(1)$ on each input $a\geq b\geq1$ (Theorem~\ref{thm:registers}). The number of registers grows as $\varepsilon$ decreases. Sections~\ref{sec:normalization}--\ref{sec:construction} prove Theorem~\ref{thm:main} and its refinements, Section~\ref{sec:certificates} treats certificates and uniform processes, Sections~\ref{sec:loglog} and~\ref{sec:programs} give the lower bound and the register programs, Section~\ref{sec:discussion} discusses open problems, and Section~\ref{sec:checks} and Appendix~\ref{app:lean} describe the computational checks and the Lean formalisation. \paragraph{Related work.} The known intrinsic lower bounds give $\Omega(\log\log a)$ on special families of coprime pairs \cite{vddm2004,vddm2009}, \cite[Theorem~6C.5]{moschovakis2019}, also for richer primitives such as addition and integer quotient, and for depth. Pratt's unpublished nondeterministic algorithm \cite[Theorem~2E.2 and Problems~x2E.17--x2E.19]{moschovakis2019} matches this order on successive Fibonacci numbers \cite[Corollary~6C.7]{moschovakis2019}. For remainder-only derivations, our almost-all bound gives the same order on a set of full density among coprime pairs. Mansour, Schieber and Tiwari proved lower bounds for gcd and coprimeness in computation trees with richer arithmetic, including the floor operation \cite{mst1991a,mst1991b}; van den Dries and Moschovakis compare them with the intrinsic bounds \cite[pp.~2:3--2:4]{vddm2009}. In a different model, Bshouty obtained the optimal bound $\Theta(\log N/\log\log N)$ for gcd on inputs in $[0,N]$ using a random access machine with linear operations, shifts, comparisons and indirect addressing \cite[Theorems~i and~ii, p.~3]{bshouty1989}. His construction tabulates blocks of the binary gcd algorithm \cite{stein1967}, \cite[\S4.5.2]{knuth1997}, computing table entries on demand and counting their construction \cite[\S4, Algorithm~D and Lemma~5, pp.~12--14]{bshouty1989}. Here the saving comes from reusing a Euclidean prefix with remainder as the only instruction. \section{Normalisation}\label{sec:normalization} Write $g=\gcd(a,b)>0$. For positive $y$, \[ \rem(gx,gy)=g\rem(x,y). \] Every generated value is divisible by $g$. Consequently scaling a derivation, or dividing all its values by $g$, preserves its length and the validity of every instruction. Hence \begin{equation}\label{eq:normalize} G(a,b)=G(a/g,b/g). \end{equation} Define \[ T(n)=\max_{0\leq b\leq a\leq 2^n,\ a>0}G(a,b). \] Euclid's remainders form a derivation containing $\gcd(a,b)$, so $G$ and $T$ are finite. By \eqref{eq:normalize} it suffices to bound $G$ on coprime pairs; the cases $a=b$, $b=0$ and $b=1$ need no instructions. \section{Three-call contractions}\label{sec:contractions} \begin{lemma}\label{lem:gap} If $m>0$ is available and a finite collection $S$ of available values occupies $t\geq2$ residue classes modulo $m$, at most three instructions generate $w$ with \[ 0r_1=b>\cdots>r_h>0$ be a Euclidean prefix of a coprime pair, with $r_{i-1}=q_i r_i+r_{i+1}$ and $q_i\geq1$ for $1\leq i2a/r_h$, each residue class modulo $m$ contains $r_i$ for at most three indices $0\leq i\leq h$. The prefix therefore occupies $t$ residue classes with $3t\geq h+1$. \end{lemma} \begin{proof} Let $q_h=\lfloor r_{h-1}/r_h\rfloor\geq1$ and $r_{h+1}=\rem(r_{h-1},r_h)$, so that the recurrence also holds for $i=h$. For $i0$. If it is $1$, then $E\geq1$ as $AE=1+BC$, and $\sigma\geq2$ because $M_{s,u}$ has $u-s\geq2$ factors, so $D\geq B>0$. In both cases $D\leq\tau+B'-B\leq\tau+A'-B<2A'$, since $B'\leq A'$ (as $A\geq B$ and $C\geq E$) and $\tau\leq\sigma\leq\sigma A2a/r_h$, one stored prefix serves every later modulus, although these moduli are not known in advance. If $h=3k$ with $k\geq1$, then $3t\geq3k+1$, so the prefix occupies at least $k+1$ residue classes modulo every available $m>2a/r_h$, and Lemma~\ref{lem:gap} applied to the prefix gives three instructions that generate \begin{equation}\label{eq:contract} 02\cdot44/10$ its residues are $4,7,0$, and the close pair $4<7$ gives a contraction step as in Lemma~\ref{lem:gap} (this prefix is too short for \eqref{eq:contract}, so we read off the residues directly): \[ \rem(44,10)=4,\qquad \rem(17,10)=7,\qquad \rem(7,4)=3, \] with new modulus $3<10/(3-1)$. One more instruction, $\rem(10,3)=1$, finishes. This derivation takes five instructions; Euclid reaches $1$ in four. The example illustrates contraction without a saving on this pair. \section{Construction and recurrence}\label{sec:construction} Fix an integer $n>16$ and put \[ N=2^n,\qquad p=\lfloor(\log n)/2\rfloor\geq2,\qquad k=2^p,\qquad h=3k, \qquad J=\lceil n/p\rceil, \] so that $k\leq\sqrt n$ and $k^J\geq N$. After normalisation, assume $a>b>1$ are coprime and $a\leq N$. We use $N^{3/4}$ as the \emph{early threshold} and $N^{1/3}$ as the \emph{target modulus}. Any thresholds $N^\alpha,N^\beta$ with $\alpha<1$, $\alpha+\beta>1$ and $2\beta<1$ would do: these make the early recursive problem smaller, let the prefix lemma apply above the target, and make the two final problems together smaller. \paragraph{Phase (i): the prefix.} Starting from $r_1=b$, generate the Euclidean remainders $r_2,r_3,\ldots$, one instruction each, until the most recent value is at most $N^{3/4}$ or $r_h$ is available. This costs at most $h$ instructions. Since the inputs are coprime, Euclid's algorithm reaches $1$ before $0$, so the stopping value is positive. If the stopping value $c$ is at most $N^{3/4}$, generate the next remainder $sN^{3/4}$, so $2a/r_h<2N^{1/4}12$), and Lemma~\ref{lem:prefix} applies to every available $m>N^{1/3}$. Starting at $m=r_h$, repeatedly replace $m$ by the value $w$ of \eqref{eq:contract} until $00$, there is an $a_0$ such that for every $a\geq a_0$ and $0\leq b\leq a$, \[ G(a,b)\leq(3+\varepsilon)\frac{\log a}{\log\log a}. \] Equivalently, the uniform upper bound has coefficient $3+o(1)$. \end{corollary} \begin{proof} Fix $0N^\alpha$, so $2a/r_h<2N^{1-\alpha}=2N^{\beta/2}0$, the ratio $f(\lceil qn\rceil)/f(n)$ tends to $q$. Taking upper limits in the recurrence yields \[ \Lambda\leq\max\{\alpha \Lambda,\ 2\beta \Lambda+3/c\}. \] Since $\alpha<1$ and $\Lambda\geq0$, this implies $(1-2\beta)\Lambda\leq3/c$. As $T$, and hence $\Lambda$, does not depend on $c$ or $\beta$, this holds for all $00$ with $g(a_n,b_n)>C\log a_n$ for all $n$ \cite[Open Problem, p.~2:11]{vddm2009}. Here, following \cite[p.~2:4]{vddm2009}, the stages live in $\mathbb Z$, $\operatorname{iq}(x,y)=\lfloor x/y\rfloor$ and $\rem(x,y)=x-y\operatorname{iq}(x,y)$ for $y\neq0$, and $\operatorname{iq}(x,0)=\rem(x,0)=x$; these total operations agree with the remainder used in derivations, whose divisors are always positive. \begin{corollary}\label{cor:closure-depth} For integers $a\geq4$ and $b\geq1$, \[ g(a,b)\leq1+G(a,\rem(b,a)) =O\left(\frac{\log a}{\log\log a}\right). \] Hence the Open Problem has a negative answer: no such sequences $a_n,b_n$ exist. \end{corollary} \begin{proof} Put $r=\rem(b,a)$, so $r\in S_1$, $0\leq r0$ (by definedness of either appended remainder). Thus $\pi(g)$ divides both input images. Conversely every common divisor of those images divides $\pi(g)$ by induction over the derivation. This proves the bounds for $\mathcal N_0$. In $\mathcal N_\varepsilon$ the lower-bound argument is unchanged, and every certificate in $\mathcal N_0$ is also one in $\mathcal N_\varepsilon$, so both bounds transfer to $\calls_{\rem}(\mathcal N_\varepsilon,\gcd,a,b)$. \end{proof} \begin{remark}\label{rem:noncoprime} \begin{enumerate} \item At $(0,0)$ the output is an input, and the substructure with universe $\{0\}$ and no facts is a certificate. \item For gcd restricted to positive inputs, appending $\eq_0(a)=\mathrm{ff}$ and $\eq_0(b)=\mathrm{ff}$ keeps input images in the domain, at no remainder cost. \item For a positive noncoprime input, adding $\eq_1(g)=\mathrm{ff}$ to the gcd certificate certifies noncoprimeness. So the sublogarithmic bound holds for both truth values of coprimeness, and since each overhead is a fixed additive constant, Corollary~\ref{cor:three} holds for all three complexities of Corollary~\ref{cor:refute} below on positive inputs. \end{enumerate} \end{remark} \paragraph{The conjectures refuted.} Moschovakis's 2012 notes state: \begin{quote} \textbf{Conjecture 3.4} \cite[p.~19]{moschovakis2012}. There is a rational number $r>0$ such that for infinitely many $a\geq b\geq1$, $\calls_{\rem}(\mathcal N_\varepsilon,\coprime,a,b)\geq r\log a$. \end{quote} The book formulates one precise version of the Main Conjecture \cite[p.~151]{moschovakis2019}: there are a set $\mathcal D\subseteq\mathbb N^2$ and a $K>0$ such that \[ (x,y)\in\mathcal D\ \Longrightarrow\ \calls_{\rem}(\mathrm{Eucl},x,y)\leq L(x,y)\leq K\calls_{\rem}(\mathcal A,\gcd,x,y), \tag{4F-5} \] where $L(x,y)=2\log\max(x,y)$ for $(x,y)\neq(0,0)$, $L(0,0)=0$, and $\calls_{\rem}(\mathrm{Eucl},x,y)$ counts the remainder calls of the Euclidean algorithm $\mathrm{Eucl}$ (the book writes $\varepsilon$) on $(x,y)$. The book states (4F-5) for the Euclidean algorithm in $\mathbf N_\varepsilon$, so its $\mathcal A$ is $\mathcal N_\varepsilon$; we treat both $\mathcal A=\mathcal N_\varepsilon$ and $\mathcal A=\mathcal N_0$. The book adds that $\mathcal D$ then satisfies its conditions (4F-3) and (4F-4); the latter makes the intrinsic complexity unbounded on $\mathcal D$, so $\mathcal D$ is infinite (for finite $\mathcal D$ the statement is trivial). We refute the weaker statement obtained by dropping the first inequality and requiring only that $\mathcal D$ be infinite. \begin{corollary}\label{cor:refute} The intrinsic complexities \[ \calls_{\rem}(\mathcal N_\varepsilon,\coprime,a,b),\qquad \calls_{\rem}(\mathcal N_0,\gcd,a,b),\qquad \calls_{\rem}(\mathcal N_\varepsilon,\gcd,a,b) \] are $O(\log a/\log\log a)$, uniformly in $1\leq b\leq a$. Consequently Conjecture~3.4 of \cite{moschovakis2012} is false, and so is the version (4F-5) of the Main Conjecture with $\mathcal A=\mathcal N_0$ or $\mathcal A=\mathcal N_\varepsilon$: for every $r>0$ only finitely many pairs $a\geq b\geq1$ satisfy $\calls_{\rem}(\mathcal N_\varepsilon,\coprime,a,b)\geq r\log a$, and for every $K>0$ only finitely many pairs $(x,y)\in\mathbb N^2$ satisfy $L(x,y)\leq K\calls_{\rem}(\mathcal A,\gcd,x,y)$. \end{corollary} \begin{proof} By Theorem~\ref{thm:main}, Proposition~\ref{prop:certificates} and Remark~\ref{rem:noncoprime}, each complexity is at most $G(a,b)+2$ on positive inputs, which gives the first assertion; the refutations follow since $\log a/\log\log a=o(\log a)$. For (4F-5), symmetry covers $x0$, all but $o(N^2)$ of these pairs satisfy $G(a,b)>(1-\varepsilon)\log\log N$. \end{proposition} \begin{proof} For $B\geq1$ call $(a,b)$ \emph{$B$-regular} if $|qb-pa|\geq a/(Bq)$ whenever $q\in\mathbb N$, $q\geq1$, $p\in\mathbb Z$ and $qb\neq pa$. We first bound the cost on regular pairs, then count the irregular ones. Every generated value has an integer representation $v=ua+wb$. On a regular pair, $v>0$ implies $v\geq a/(B(|u|+|w|))$: for $w\neq0$ use regularity with $q=|w|$, and for $w=0$ note $v\geq a$. Let $H_t$ bound the coefficient norm $|u|+|w|$ in one such representation of each value available after $t$ instructions, starting with $H_0=1$. In an instruction $r=\rem(x,y)$, write $x=sy+r$. Since generated values are at most $a$, the quotient satisfies $s\leq a/y\leq BH_t$. Subtracting $s$ times the representation of $y$ from that of $x$ gives \[ H_{t+1}\leq H_t+BH_t^2\leq2BH_t^2,\qquad H_t\leq(2B)^{2^t-1}. \] Producing $1$ within $d$ instructions therefore forces \[ 1\geq\frac{a}{BH_d},\qquad a\leq\frac{(2B)^{2^d}}2. \] To count irregular pairs below $N$, choose a witness $0<|qb-pa|0$ there are a fixed register program $P$ and a constant $B\geq0$ such that \[ \forall a\geq b\geq1,\qquad c_P(a,b)\leq\varepsilon\log a+B. \] \end{theorem} \begin{proof} Put $k=2^p$, $h=3k$ and $W=h+6$: two inputs, $h+1$ prefix values, a modulus and two scratch registers. Initialise the registers $x_0,\ldots,x_{W-1}$ at $(a,b,a,b,a,\ldots,a)$. If $b=0$, return $a$; otherwise enter the main line. There the program may perform any assignment $x_l:=\rem(x_i,x_j)$ with $i,j,l\geq2$, or pass to verification with a candidate $x_i\neq0$, $i\geq2$. Verification sets $x_0:=\rem(x_0,x_i)$ and $x_1:=\rem(x_1,x_i)$, halts with $x_i$ if both are $0$, and loops otherwise; the main line never writes $x_0,x_1$. Every register value is divisible by $\gcd(a,b)$, so a candidate that passes verification is the gcd, and Euclid's algorithm gives a convergent computation. The computations below move values between registers for readability; copying is never needed (Appendix~\ref{app:lean}). Multiplying every value by $g=\gcd(a,b)$ turns a computation on $(a/g,b/g)$ into one on $(a,b)$ with the same remainder count, so it suffices to treat coprime pairs. Let $S(n)$ be the maximum, over coprime $1\leq b\leq a\leq2^n$ and over states with $a,b$ in two work registers, of the least number of remainder calls with which main-line moves of $P_p$ place $1$ in a work register. Fix $0<\beta<1/2$ and put $\alpha=1-\beta/2$ and $N=2^n$. Compute the Euclidean remainders $r_0=a,r_1=b,r_2,\ldots$ in working registers, stopping at $r_h$ or at the first $r_j\leq N^\alpha$. If $1$ has been reached, no further generation is needed. In the remaining early case, one further remainder gives the positive coprime pair $r_j,r_{j+1}$, bounded by $N^\alpha$, at total cost at most $h$; continue with that pair, in the same registers. This restart needs no stack, but the two recursive derivations of Phase~(iii) in Section~\ref{sec:construction} would, so the final step below uses Euclid's algorithm instead. Otherwise $r_h>N^\alpha$. As in the late case of Corollary~\ref{cor:three}, now with $p$ fixed, the prefix lemma applies to every modulus above $N^\beta$ for large $n$, and by \eqref{eq:contract} at most $\lceil n/p\rceil$ contractions, using a modulus register and two scratch registers, produce a positive $m\leq N^\beta$. Then put $u=\rem(a,m)$ and $v=\rem(b,m)$, and run Euclid's algorithm in place on $m,u$ and then on the result $d$ and $v$. Each run takes at most $2\log m+3$ calls, and the result is $\gcd(d,v)=\gcd(m,a,b)=1$. Thus, eventually in $n$, \[ S(n)\leq\max\left\{S(\lceil\alpha n\rceil)+h,\quad h+3\lceil n/p\rceil+4\beta n+7\right\}. \] Let $\Lambda=\limsup_{n\to\infty}S(n)/n$, which is finite since Euclid gives $S(n)=O(n)$. Passing to upper limits, $\Lambda$ satisfies $\Lambda\leq\max\{\alpha\Lambda,\ 3/p+4\beta\}$, and since $\alpha<1$, $\Lambda\leq3/p+4\beta$. The program does not depend on $\beta$, so $\Lambda\leq3/p$. Take $n=\lceil\log a\rceil$ and add the two verification calls. Finally, choose $p>3/\varepsilon$ and absorb the finitely many smaller inputs in $B$. \end{proof} The program depends on $\varepsilon$ but not on the inputs. The Main Conjecture lets its coefficient $r$ depend on the program, so the family is consistent with it; no single sublogarithmic program is obtained. \paragraph{Recursive programs.} Theorem~\ref{thm:registers} also holds for the book's recursive programs: writing one function per line of $P_p$ yields a finite nondeterministic tail-recursive program with the same remainder cost \cite[\S\S2A, 2C, 2E]{moschovakis2019}. Lean verifies this translation for every register program on its model of the book's recursive machine, a specialisation of the book's Table~1, and proves an input-independent bound on the stacks (Appendix~\ref{app:lean}). \section{Discussion and open problems}\label{sec:discussion} \paragraph{The gap.} The intrinsic complexity of coprimeness in $\mathcal N_\varepsilon$ is $\Omega(\log\log a)$ on almost all coprime pairs and $O(\log a/\log\log a)$ on all positive pairs. Closing this gap is open; unlike Bshouty's bound in his model, our upper bound is not known to be optimal. \paragraph{One program.} For this construction, an obstacle to one sublogarithmic program is reusable access to a prefix whose length grows with the input. A nondeterministic program can guess the close pair, but it must hold all $h+1$ prefix values; regenerating them would cost about $h$ calls per contraction. By Theorem~\ref{thm:registers}, $W=3\cdot2^p+6$ registers give coefficient $3/p$, roughly $3/\log W$, so no lower bound $c\log a$ with $c>0$ independent of the number of registers holds for nondeterministic register programs. A register program has only a fixed number of slots for prefix values. Does every nondeterministic register program computing gcd with $W$ registers make at least $c\log a/\log W$ remainder calls on infinitely many inputs, for an absolute $c>0$? Such a bound cannot rest on how quickly values shrink, since $\rem(m+1,m)=1$. Pratt's algorithm is itself a nondeterministic register program \cite[Theorem~2E.2]{moschovakis2019}; compare also the book's question whether recursion reduces to tail recursion in the pointed Euclidean structure \cite[Problem~x2G.6]{moschovakis2019}. Recursion permits unbounded saved state, but does not directly provide reusable access to an arbitrarily long prefix. Can one fixed recursive program retain and repeatedly access a growing prefix at the same remainder cost? Every certificate becomes a computation of some program \cite[Proposition~2E.1]{moschovakis2019}, but not of one program for all certificates. \paragraph{Stronger lower-bound methods.} The limit established in Section~\ref{sec:certificates} leaves room for arguments combining homomorphisms with additional restrictions on computations. In particular, the conjecture of a logarithmic lower bound for deterministic uniform processes remains open \cite[Conjecture~3.9, p.~23]{moschovakis2012}, \cite[\S4H and p.~188]{moschovakis2019}. \section{Computational checks}\label{sec:checks} The Python planner in the accompanying repository\footnote{\url{https://github.com/jasondavies/euclid-uniform-processes}; this paper describes release \texttt{v1.0}.} chooses instructions offline with unrestricted arithmetic, using the parameters of Theorem~\ref{thm:main} from Section~\ref{sec:construction}; below a base size (256 bits by default) it uses Euclid's algorithm. A separate replay script then checks operand availability, nonzero divisors, every remainder equation and the final gcd. A benchmark script samples $25$ coprime pairs at each size: $a$ is uniform among integers of that bit length, and $b$ is drawn uniformly from $\{2,\ldots,a-1\}$ until $\gcd(a,b)=1$. It also runs the successive Fibonacci pair $(F_k,F_{k-1})$ with $F_k$ the first Fibonacci number of that bit length. The table gives remainder calls; the Euclidean count stops when $1$ first appears. \begin{center} \small \begin{tabular}{rcccc}\toprule & \multicolumn{2}{c}{Random pairs: min / median / max} & \multicolumn{2}{c}{Fibonacci pair}\\ \cmidrule(lr){2-3}\cmidrule(l){4-5} Input bits & Construction & Euclid & Construction & Euclid\\\midrule 512 & 193 / 210 / 228 & 266 / 295 / 337 & 53 & 735\\ 2048 & 612 / 626 / 644 & 1136 / 1192 / 1260 & 106 & 2948\\ 8192 & 1918 / 1957 / 1985 & 4664 / 4774 / 4890 & 212 & 11798\\\bottomrule \end{tabular} \end{center} All $78$ derivations and the example of Section~\ref{sec:contractions} pass replay. On the Fibonacci pairs, Euclid's worst case, the bits removed by successive contractions roughly double (32, 66, 131 and 248 at 512 bits), so few contractions are needed. These samples illustrate the construction; the asymptotic claim rests on the proof. With the parameters of Corollary~\ref{cor:three} and $c$ near $1$, the prefix exceeds the whole Euclidean sequence at these sizes, so the coefficient $3$ is asymptotic only. The accompanying repository also checks scaled and noncoprime inputs, rejects invalid traces, and tests the prefix lemma over a finite range. The repository README gives scripts, commands, test ranges, seeds and individual results. The Python checks are not formally verified; the unrestricted arithmetic used to plan instructions is outside the derivations. \appendix \section{Formal verification}\label{app:lean} The development uses Lean~4.35.0 \cite{deMouraUllrich2021} with mathlib \cite{mathlib2020} at its v4.35.0 tag; the pinned mathlib commit is \texttt{56a005855ea17e0b0958f73ec801ae140b0a1679}. The proved library contains no proof placeholders or added axioms; the axiom audit reports only \texttt{propext}, \texttt{Classical.choice}, and \texttt{Quot.sound}. Table~\ref{tab:lean} gives the main declarations; the repository README gives the complete map and reproduction commands. The general theory of uniform processes, including Theorem~4F.1 used in Corollary~\ref{cor:uniform}, and the historical lower bounds are cited, not formalised. The certificate bounds and conjecture refutations are formalised independently of that theory, with certificates represented by their facts. The consequence of Lemma~\ref{lem:fact-representation} that we use, equality of the book-style and fact-based complexities, is formalised too: Lean states the book's definitions for $\mathcal N_\varepsilon$ and $\mathcal N_0$ directly (finite partial substructures with partial operations, generation, homomorphisms on the universe, certification and the norm $\calls_{\rem}$) and proves that the resulting intrinsic complexities equal the fact-based ones used in the refutations. Corollary~\ref{cor:closure-depth} is formalised with the source's definitions of $\operatorname{iq}$, $\rem$ and the closure stages, including their conventions at zero divisors. The development is also packaged for the comparator of the Palomar registry: \texttt{Challenge.lean} imports only mathlib and states the main theorems with every definition visible and deliberate \texttt{sorry} placeholders, and \texttt{Solution.lean} imports the proved library, independently of these placeholders. The comparator checks that the proved statements are exactly those of \texttt{Challenge.lean} and replays the proofs through Lean's kernel and the independent kernels NanoDa and con-ron; we ran it on release \texttt{v1.0} of the repository. \texttt{comparator.json} lists all twenty-two compared theorems, including that $G$ and the closure depth are attained (\lean{generates_G}, \lean{ClosureDepth.depth_mem}), so the bounds on them are not about empty infima; Table~\ref{tab:lean} marks those included here with ${}^\dagger$. Version~2 of the Palomar registry entry PALOMAR-2026-10-23-000012 \cite{palomar2026} records this verification for release \texttt{v1.0} (commit \texttt{2548681}), covering all twenty-two compared theorems. \paragraph{Arithmetic bounds.} Costs are lengths of explicit remainder derivations. The finite theorem \lean{sizeCost_step} proves the recurrence from natural-number size parameters; it does not assume a recurrence for the cost function. For the initial Big-O proof, Lean uses the parameters of Section~\ref{sec:construction}, computing $p$ as $\lfloor\lfloor\log n\rfloor/2\rfloor$, which equals $\lfloor(\log n)/2\rfloor$, and checks the integer rounding estimates before passing to real logarithms. The refinement uses the tunable parameters of Corollary~\ref{cor:three} and checks the rounding limits preserving coefficient $3$. For Proposition~\ref{prop:loglog}, Lean takes $B=a^{2^{-d}}/2$ separately for each pair instead of splitting into dyadic ranges. It proves the stated constant $40$ and the exceptional-set limit for every fixed $0<\varepsilon\leq1$ (larger $\varepsilon$ are trivial), with threshold $(1-\varepsilon)\log\log N$. \paragraph{Programs and machine computations.} For Theorem~\ref{thm:registers}, Lean defines the book's register programs over $\mathcal N_0$ (\lean{Register.Program}): lines numbered from $0$, each a halt or a list of alternative assignments and branchings, with the book's prime terms $x_i$, $\rem(x_i,x_j)$, $\mathrm{tt}$, $\mathrm{ff}$ and $\eq_0(x_i)$, and the book's iterator semantics, in which $\rem(x,0)$ is undefined. The program $P_p$ is written in this syntax (\lean{TailSource.program}), with no stack, and each remainder evaluation is charged once, including the two verification calls. Every convergent execution returns the gcd, and one exists on every input. The cost proofs use a generator that may also relabel all registers at once. \lean{TailSource.run_trace_relabel} replays such runs by single-register commands at the same cost and with no extra registers: it tracks the relabelling in the proof, and writes each new remainder to a register no other value occupies, which exists by pigeonhole whenever two names share a register. The tail-recursive form (\lean{TailRecursive}) compiles the register program into a language of nondeterministic first-order programs (\lean{Recursive}): terms with variables, remainder, a zero-test conditional and calls of internal symbols, each symbol with a set of alternative bodies, evaluated call by value. The compiler (\lean{Register.compile}) follows the book's reduction of iteration to tail recursion \cite[\S2C]{moschovakis2019}: each line becomes a function of the $W$ registers, an assignment a tail call with one argument replaced, a branching on $\eq_0(x_i)$ a zero-test conditional between two tail calls and one on $\mathrm{tt}$ or $\mathrm{ff}$ a single tail call, a halt its term, and alternative commands alternative bodies. For every register program, \lean{Register.eval_iff_halts} matches evaluations exactly, in value and remainder cost, with convergent computations; every call is a tail call, whose arguments, remainder operands and conditional guards contain no internal calls (\lean{Register.compile_tailRecursive}); and the machine's control and value stacks never hold more than $2W+4$ entries in all, on any input and however long the computation runs (\lean{Register.stacks_bounded}). For Theorem~\ref{thm:registers}, $W=3\cdot2^p+6$, so the stacks never exceed $6\cdot2^p+16$ entries (\lean{TailRecursive.stacks_bounded}); each closure environment has at most $W$ entries. For every program in the language, \lean{Recursive.Machine.eval_iff_steps} proves exact-cost equivalence with a specialisation of the book's two-stack machine: arguments are evaluated right to left, zero tests and branches are separate transitions, and only remainder transitions are charged \cite[Table~1, p.~75]{moschovakis2019}. Closures represent substitution in machine states, not extra program data. \begin{table}[!h] \centering\small \caption{Main results and Lean declarations, all in the namespace \texttt{ShortGCD}. Names marked ${}^\dagger$ are compared against \texttt{Challenge.lean}.} \label{tab:lean} \begin{tabular}{@{}>{\raggedright\arraybackslash}p{0.29\textwidth}>{\raggedright\arraybackslash}p{0.67\textwidth}@{}} \toprule Paper & Lean declaration(s)\\\midrule Theorem~\ref{thm:main} & \lean{uniform_real_bound}, \lean{generates_G}${}^\dagger$\\ Normalisation \eqref{eq:normalize} & \lean{G_normalize}\\ Lemma~\ref{lem:gap} & \lean{small_remainder}\\ Lemma~\ref{lem:prefix} & \lean{prefix_class_card_le_three}, \lean{residue_card_three}; for \eqref{eq:contract}, \lean{prefix_reservoir}\\ Lemma~\ref{lem:fact-representation} (consequence used) & \lean{Book.callsCoprimeness_eq}${}^\dagger$, \lean{Book.callsRemGcd_eq}${}^\dagger$, \lean{Book.callsGcd_eq}${}^\dagger$\\ Corollary~\ref{cor:three} & \lean{uniform_real_bound_three}${}^\dagger$, \lean{uniform_intrinsic_bound_three}${}^\dagger$\\ Proposition~\ref{prop:certificates} & \lean{callsGcd_le}, \lean{callsGcd_zero_left}, \lean{callsRemGcd_le_callsGcd}, \lean{exists_certifiesGcd}${}^\dagger$, \lean{G_le_callsRemGcd}${}^\dagger$, \lean{G_le_callsGcd}${}^\dagger$, \lean{callsCoprimeness_eq_G}${}^\dagger$\\ Remark~\ref{rem:noncoprime} & \lean{callsCoprimeness_le}, \lean{exists_certifiesCoprimeness}${}^\dagger$\\ Corollary~\ref{cor:refute} & \lean{not_conjecture_3_4}${}^\dagger$, \lean{not_main_conjecture_4F5}${}^\dagger$, \lean{not_main_conjecture_4F5_Neps}${}^\dagger$, and the literal readings \lean{not_conjecture_3_4_literal}${}^\dagger$, \lean{not_main_conjecture_4F5_literal}${}^\dagger$\\ Corollary~\ref{cor:uniform} & Cited Theorem~4F.1; not formalised here\\ Corollary~\ref{cor:closure-depth} & \lean{ClosureDepth.depth_le}, \lean{ClosureDepth.depth_mem}${}^\dagger$, \lean{ClosureDepth.depth_bound}, \lean{ClosureDepth.no_logarithmic_sequences}${}^\dagger$\\ Proposition~\ref{prop:loglog} & \lean{AlmostAll.card_D_le}, \lean{G_eq_D}, \lean{tendsto_card_callsCoprimeness_loglog}${}^\dagger$\\ Theorem~\ref{thm:registers} & \lean{TailProgram.Fixed.limsup_profile_le}, \lean{TailProgram.Fixed.eventually_accepts_bound}, \lean{TailSource.executes_iff}, \lean{TailSource.total_registers}, \lean{TailSource.executes_correct}${}^\dagger$, \lean{TailSource.executes_total}${}^\dagger$, \lean{TailSource.arbitrarily_small_coefficient}${}^\dagger$\\ Recursive programs (Section~\ref{sec:programs}) & \lean{TailRecursive.program_tailRecursive}, \lean{TailRecursive.stacks_bounded}, \lean{TailRecursive.executes_iff_steps}, \lean{TailRecursive.arbitrarily_small_coefficient}\\ \bottomrule \end{tabular} \end{table} \section*{Acknowledgements} I thank Shubhendu Trivedi for helpful comments. \section*{Declaration of AI-generated research and authorship} This manuscript is the product of an AI-driven research process. During a broader investigation initiated by the human author, an AI system, GPT-6-Astra, identified the principal result. The author then directed AI systems to formalise the results in Lean and to prepare this manuscript. The AI systems developed the results and their presentation, including the mathematical exposition, the formalisation, and the organisation and writing of the text; the human author wrote no part of the manuscript. The systems were GPT-6-Astra (OpenAI), used through Codex, and Claude Opus~5.5 (Anthropic), used through Claude Code. Both contributed to the Lean formalisation and to the review and revision of the manuscript. The Lean development gives a machine-checkable version of the main claims. Lean's kernel checks the proofs, including the mathlib results they use, relative to the axioms listed in Appendix~\ref{app:lean}. That includes the equality of the book-style and fact-based complexities, the consequence of Lemma~\ref{lem:fact-representation} that we use; the book's general theory of uniform processes, used through the cited Theorem~4F.1, is not formalised. The human author has checked the arguments and takes full responsibility for the content of this paper, including the correctness of its mathematics, and for the accuracy of this disclosure. \begin{thebibliography}{10} \raggedright \bibitem{bshouty1989} Nader H. Bshouty. \emph{Euclidean GCD algorithm is not optimal}. Research Report 1989-376-38, Department of Computer Science, University of Calgary, December 1989. \href{https://doi.org/10.11575/PRISM/30475}{doi:10.11575/\allowbreak PRISM/30475}. \bibitem{chorgoldreich1990} Benny Chor and Oded Goldreich. An improved parallel algorithm for integer GCD. \emph{Algorithmica} 5(1--4):1--10, 1990. \href{https://doi.org/10.1007/BF01840374}{doi:10.1007/BF01840374}. \bibitem{deMouraUllrich2021} Leonardo de Moura and Sebastian Ullrich. The Lean~4 theorem prover and programming language. In \emph{Automated Deduction -- CADE~28}, Lecture Notes in Computer Science, vol.~12699, pp.~625--635. Springer, 2021. \href{https://doi.org/10.1007/978-3-030-79876-5_37}{doi:10.1007/978-3-030-79876-5\_37}. \bibitem{kmr1987} Ravindran Kannan, Gary Miller and Larry Rudolph. Sublinear parallel algorithm for computing the greatest common divisor of two integers. \emph{SIAM Journal on Computing} 16(1):7--16, 1987. \href{https://doi.org/10.1137/0216002}{doi:10.1137/0216002}. \bibitem{knuth1997} Donald E. Knuth. \emph{The Art of Computer Programming, Vol.~2: Seminumerical Algorithms}, 3rd ed. Addison-Wesley, Reading, MA, 1997. \bibitem{mst1991a} Yishay Mansour, Baruch Schieber and Prasoon Tiwari. A lower bound for integer greatest common divisor computations. \emph{Journal of the ACM} 38(2):453--471, 1991. \href{https://doi.org/10.1145/103516.103522}{doi:10.1145/103516.103522}. \bibitem{mst1991b} Yishay Mansour, Baruch Schieber and Prasoon Tiwari. Lower bounds for computations with the floor operation. \emph{SIAM Journal on Computing} 20(2):315--327, 1991. \href{https://doi.org/10.1137/0220020}{doi:10.1137/0220020}. \bibitem{mathlib2020} The mathlib Community. The Lean mathematical library. In \emph{Proceedings of the 9th ACM SIGPLAN International Conference on Certified Programs and Proofs (CPP 2020)}, pp.~367--381. ACM, 2020. \href{https://doi.org/10.1145/3372885.3373824}{doi:10.1145/3372885.3373824}. \bibitem{moschovakis2012} Yiannis N. Moschovakis. \emph{Absolute lower bounds for uniform processes}. Unpublished lecture notes (first draft), January 25, 2012. \url{https://www.math.ucla.edu/~ynm/nadalb.pdf}. \bibitem{moschovakis2019} Yiannis N. Moschovakis. \emph{Abstract Recursion and Intrinsic Complexity}. Lecture Notes in Logic, vol.~48. Cambridge University Press and Association for Symbolic Logic, 2019. \href{https://doi.org/10.1017/9781108234238}{doi:10.1017/9781108234238}. \bibitem{palomar2026} Palomar registry. Entry PALOMAR-2026-10-23-000012, version~2, for commit \texttt{2548681} of \url{https://github.com/jasondavies/euclid-uniform-processes}. \url{https://palomar-registry.org/entry?id=PALOMAR-2026-10-23-000012&version=2}. \bibitem{stein1967} J. Stein. Computational problems associated with Racah algebra. \emph{Journal of Computational Physics} 1(3):397--405, 1967. \href{https://doi.org/10.1016/0021-9991(67)90047-2}{doi:10.1016/0021-9991(67)90047-2}. \bibitem{vddm2004} Lou van den Dries and Yiannis N. Moschovakis. Is the Euclidean algorithm optimal among its peers? \emph{Bulletin of Symbolic Logic} 10(3):390--418, 2004. \href{https://doi.org/10.2178/bsl/1102022663}{doi:10.2178/bsl/1102022663}. \bibitem{vddm2009} Lou van den Dries and Yiannis N. Moschovakis. Arithmetic complexity. \emph{ACM Transactions on Computational Logic} 10(1), Article~2, 49~pp., 2009. \href{https://doi.org/10.1145/1459010.1459012}{doi:10.1145/1459010.1459012}. Preprint: \url{https://www.math.ucla.edu/~ynm/papers/ac.pdf}. \end{thebibliography} \end{document}