\documentclass[11pt,a4paper]{article} \usepackage[T1]{fontenc} \usepackage{lmodern} \usepackage{amsmath,amssymb,amsthm,booktabs} \usepackage[margin=27mm,headheight=14pt]{geometry} \usepackage{microtype} \usepackage[hidelinks]{hyperref} \usepackage{fancyhdr} \setlength{\emergencystretch}{3em} \setlength{\parskip}{4pt} \setlength{\belowcaptionskip}{6pt} \raggedbottom \pagestyle{fancy}\fancyhf{} \fancyhead[L]{\footnotesize The theta arithmetic sum} \fancyfoot[C]{\thepage} \hypersetup{pdftitle={An asymptotic formula and an explicit positivity bound for the theta arithmetic sum},pdfauthor={Robert Renneson}} \title{An asymptotic formula and an explicit positivity bound for the theta arithmetic sum} \author{Robert Renneson\thanks{I initiated and directed this project. Claude Fable 5.1 (Anthropic) assisted with the mathematical analysis, early drafts, and review. GPT-6 Astra (OpenAI) helped develop the proofs, formalized both theorems in Lean~4, and drafted this manuscript.}} \date{30 November 2026} \begin{document} \pdfbookmark[0]{An asymptotic formula and an explicit positivity bound for the theta arithmetic sum}{title} \maketitle\vspace{-1em} \begin{abstract} For an odd prime $p$, let $S(p)$ be the sum of $(-1)^{j+1+\lfloor hj/p\rfloor}$ over $1\le h,j0$ for every prime $p>5$ and proposed upper and lower bounds for its growth. We prove that $S(p)=\tfrac12 p\log p+O\bigl(p(\log p)^{3/4}(\log\log p)^2\bigr)$ as $p$ tends to infinity through primes. This proves their growth conjecture. We also prove that $S(p)>\tfrac25p\log p$ for every prime with $\log\log p\ge250$. Both proofs begin with a cotangent identity and a decomposition into digamma sums. For the explicit bound we select two prime factors from the denominator of a reciprocal exponential sum and transfer cancellation to the parity sign in the original sum. Both theorems are formalized in Lean 4. Positivity for every prime greater than five remains open. \end{abstract} \noindent\textbf{Keywords:} arithmetic sums; theta functions; Dedekind sums; asymptotic formulas; exponential sums; formal verification. \noindent\textbf{Mathematics Subject Classification (2020):} Primary 11N37; Secondary 11F20, 11L05, 68V20. \section{Statement and scope} Berndt, Bhat, Meyer, Xie and Zaharescu \cite{bbmxz} study the arithmetic sum \begin{equation*}S(k)=\sum_{h=1}^{k-1}\;\sum_{j=1}^{k-1}(-1)^{j+1+\lfloor hj/k\rfloor}.\tag{1}\end{equation*} Their Conjecture 1.1 asks whether $S(p)>0$ for every prime $p>5$. We give the leading term of $S(p)$ and a range in which it exceeds four fifths of that leading term. All logarithms are natural, and limits in $p$ are along primes. \textbf{Theorem A.} As $p$ tends to infinity through primes, \begin{equation*}S(p)=\frac12 p\log p+O\!\left(p(\log p)^{3/4}(\log\log p)^2\right).\tag{2}\end{equation*} The implied constant is absolute. \noindent\textbf{Theorem B.} For every prime $p$ with $\log\log p\ge250$, \[ S(p)>\tfrac25\,p\log p . \] In particular every possible exception to positivity above five lies below $\exp(\exp(250))$. \textbf{Corollary 1.} We have $S(p)\sim\frac12 p\log p$ and $S(p)/p\longrightarrow+\infty$. For every real $C$, the inequality $S(p)>Cp$ holds for all sufficiently large primes. \textbf{Corollary 2.} For every $C_1,C_2,\varepsilon>0$, there is a threshold beyond which every prime satisfies \begin{equation*}C_1p0$. These facts give both conclusions. Sections 2--6 prove Theorem A. Section 7 describes the proofs of its exponential-sum inputs. Section~\ref{sec:effective} proves Theorem B by keeping the common finite reduction and replacing the short reciprocal estimate with one that has explicit constants. Section~\ref{sec:verification} identifies the formal theorems and gives reproduction instructions. \subsection{Relation to earlier work} The sum is connected to classical Hardy and Dedekind sums. For an odd prime $p$ and odd $1\leq jp$ the only possible obstruction would have $s=n-1$, which implies $v\equiv p$ modulo $2n$ and is impossible in this range. At the exceptional numerator $v=p<2n$, one has $\epsilon_n(p)=1$. \subsection{The digamma row identity} Let $\psi$ be the digamma function and $\gamma$ Euler's constant. We use the elementary series and recurrence \cite{nist} \begin{equation*}\psi(y)=-\gamma-\frac1y+\theta(y),\qquad \theta(y)=\sum_{k\geq1}\frac{y}{k(k+y)},\tag{10}\end{equation*} \begin{equation*}\psi(y+1)=\psi(y)+\frac1y,\qquad \psi(1/2)=-\gamma-2\log2.\tag{11}\end{equation*} On $[0,1]$, both $\theta(y)$ and $w(y)=y\theta(y)$ are increasing from $0$ to $1$, and $\theta(y)\leq(\pi^2/6)y$. These statements follow term by term from (10). We also use $\psi(t)=\log t+O(1/t)$ as $t$ tends to infinity, uniformly after a bounded positive shift. Put $\mu=\gamma/2+\log2$ and define \begin{equation*}\Psi_n=-\frac1{2n}\sum_{\substack{1\leq v<2n\\v\ {\rm odd}}}\epsilon_n(v)\psi(v/(2n)),\qquad f_n=\frac{\Psi_n}{n},\tag{12}\end{equation*} \begin{equation*}\Phi(p)=\sum_{\substack{3\leq nA_v=\max(U,v/2)$. The decomposition (10) bounds the total variation of the weight by \begin{equation*}\frac1{vA_v}+\frac{\gamma+1}{2A_v^2}.\tag{29}\end{equation*} Summing (29) over odd $v<2p$ gives $O(\log(2U)/U)$. The exceptional numerator contributes $O(1/p)$ because $p/(2n)\in(1/2,1)$ there and $-\psi(p/(2n))\leq2\mu$. Therefore \begin{equation*}|\Phi_{\rm tail}|\ll\frac{\sqrt p(\log p)^2\log(2U)}U+\frac1p\ll\frac1x.\tag{30}\end{equation*} This use of (24) never includes a zero twist. \section{The small numerators} \subsection{Parity as a half-interval condition} For nonzero $v$ modulo $p$, put $k=v2^{-1}$ in $\mathbb F_p$. A nonzero residue is even precisely when halving it modulo $p$ gives a representative below $p/2$. Consequently, \begin{equation*}\lambda_p(vn^{-1})=2\,\mathbf{1}_{[0,1/2)}\!\left(\frac{[kn^{-1}]_p}{p}\right)-1.\tag{31}\end{equation*} We use the cubic discrepancy estimate proved in Section 5.1. For $L$ points $y_j\in[0,1)$, put $\Sigma_h=\sum_j e(hy_j)$. If $|\Sigma_h|\leq M$ for $1\leq h\leq(p-1)/2$, then \begin{equation*}\left|\sum_j(2\mathbf{1}_{[0,1/2)}(y_j)-1)\right|^3 \leq54L\left(M^2+\frac{L^2}{p}\right).\tag{32}\end{equation*} Indeed, the inverse-square spectral energy is at most $2M^2+2L^2/p$: use $\sum_{h\geq1}h^{-2}=\pi^2/6<2$ and the assumed bound below $p/2$. For the tail, put $m=(p+1)/2$ and use $|\Sigma_h|\leq L$ together with the telescoping comparison \begin{equation*}\sum_{h=m}^{\infty}\frac1{h^2} <\sum_{h=m}^{\infty}\left(\frac1{h-\frac12}-\frac1{h+\frac12}\right) =\frac1{m-\frac12}=\frac2p.\end{equation*} Cubing (37) and using $C_*<3$ now gives (32), with its stated constant 54 unchanged. This is the square-energy transfer used by the Lean proof. \subsection{A dyadic row bound} Let $N$ be a power of two, $Y\leq N$, and $2N\leq\sqrt p$. For any subinterval $(T_1,T_2]\subset(N,2N]$ and any nonzero $v$, we claim \begin{equation*}\left|\sum_{\substack{T_10$, put $F(t)=L^{-1}\#\{j:z_jr$. Fix $h,s,\sigma$ in the first part. The integer $Q=sp+\sigma h$ is positive and less than $p^2$. A divisor $n$ of $Q$ with at most $r$ distinct prime factors is determined by at most $r$ prime-power components, drawn from $\{q^e:q\ {\rm prime},\,1\leq e\leq v_q(Q)\}$. This set has $\Omega(Q)$ elements. Ordering the components and padding with ones gives an injection into tuples of length $r$, so their number is at most \begin{equation*}(1+\Omega(Q))^r\leq(1+2\log p/\log2)^r=a_x^r.\tag{45}\end{equation*} Each denominator contributes less than $1/N$. Using $\sum_{h\geq1}h^{-2}<2$ and $\sum_{s\geq1}\min(1,A^2/s^2)\leq3A$ gives the first term in (44). For the second part, fix $h,\sigma$ and interchange the $s$ and $n$ sums. A given $n\in(N,2N]$ divides $sp+\sigma h$ for at most one $s\in[1,N]$: two solutions would imply $n\mid s-s'$, which is impossible. Drop the minimum weight. The elementary identity $2^{\omega(n)}=\sum_{d\mid n}\mu_{\rm M}(d)^2$, where $\mu_{\rm M}$ is the M\"obius function, gives \begin{equation*}\sum_{n\leq T}2^{\omega(n)}\leq T(1+\log T).\tag{46}\end{equation*} It follows that $\sum_{Nr}1/n\leq2(1+\log(2N))2^{-r}$. Summing over $h$ and the two signs proves (44). The high-$\omega$ denominators are counted once for fixed $h,\sigma$, rather than separately for every integer $sp+\sigma h$. \subsection{From cells to the whole middle range} Let $D$ be any subset of the odd integers in $(N,2N]$, and for $n\in D$ let $J_n$ be any interval of odd integers in $(V,2V]$. H\"older's inequality with measure $1/n$, followed by (41), (42), and (44), gives \begin{equation*}\sum_{n\in D}\frac1n\left|\sum_{v\in J_n}\frac{\epsilon_n(v)}v\right| \leq3\left(\frac2N+\frac{12a_x^r}{V}+8(1+\log(2N))2^{-r}\right)^{1/3}.\tag{47}\end{equation*} Indeed, if $\eta_N=\sum_{NZ/2$ and $2NZ}n^{-3}\ll Z^{-2}$. The $\gamma$ term in (26) is also $O(1/Z)$ and is retained on both sides. We have proved \begin{equation*}\Phi_{\rm mid}=T_{\rm small}+O(1/x).\tag{51}\end{equation*} \section{Assembly of the asymptotic formula} Combining (28), (30), (36), and (51), we obtain \begin{equation*}|\Phi(p)|\ll\ell^4+\ell^2x^{3/4}+\ell^5x^{2/3}+\ell^3+x^{-1} \ll\ell^2x^{3/4}.\tag{52}\end{equation*} The last implication uses $\ell^3=o(x^{1/12})$ and $\ell^2=o(x^{3/4})$. The reduction (20) then gives \begin{equation*}S(p)-\frac12p\log p=\frac8{\pi^2}p\bigl(\Phi(p)+O(1)\bigr) =O(p x^{3/4}\ell^2).\tag{53}\end{equation*} This is Theorem A. Every estimate is uniform once $p$ exceeds a single sufficiently large threshold: the rounding in (25), the ordering of the cutoffs, (48), and the range (23) all hold eventually. The proof concerns a limit through primes, so no estimate for a particular small prime is required to establish (2). The main roles of the ingredients can be summarized as follows. The cotangent and digamma identities identify the coefficient $\frac12$. Weil's estimate controls the cotangent replacement and the long tail. Bourgain--Garaev controls small numerators in the useful dyadic denominator range. The discrepancy-energy argument and the $\omega$ split control all large numerators without a pointwise divisor bound. Their combination gives a two-sided error term, and therefore the asymptotic equivalence as well as eventual positivity. \section{Formal proofs of the exponential-sum inputs} The analytic proof above may read (21) and (22) as classical theorems. The Lean development also proves them, so its final conclusion is not conditional on either estimate. This section records the mathematical route and the exact restricted statement used; it is a guide to the formal dependency tree rather than a replacement for the full source of those classical arguments. \subsection{The complete Kloosterman bound} The proof of Weil's estimate \cite{weil} follows the finite-field and power-sum route described in Harcos's notes cited in Section 3.1. The external curve estimate uses the Bombieri--Stepanov polynomial method as presented in Iwaniec--Kowalski \cite[Chapter 11]{iwaniec-kowalski}. For nonzero $a,b$ and odd characteristic, use the curve \begin{equation*}y^2=(X^p-X)^2-4ab.\tag{54}\end{equation*} An attributed compatibility port of Math Inc's formal hyperelliptic point-count theorem \cite{math-inc} supplies an $O_p(p^{m/2})$ discrepancy over $\mathbb F_{p^m}$. Its hypotheses, including the non-square condition over the algebraic closure and the degree and field-size conditions, are discharged for the required extension degrees. The proof treats small cases separately. The remaining development proves the link to Kloosterman sums. It constructs the quadratic polynomial $1+K_p(a,b)T+pT^2$ and proves its coefficient identities using finite-field traces, norms, and monic irreducible polynomials. Finite truncations of the Euler product and formal logarithmic derivatives give the extension-degree power-sum identity. No convergence assertion for an infinite analytic product is needed. Write this polynomial as $(1-\alpha T)(1-\beta T)$, so that $\alpha+\beta=-K_p(a,b)$ and $\alpha\beta=p$. Applying the curve bound to the extension-degree power sums, including the nonzero character twists, gives $|\alpha|,|\beta|\leq\sqrt p$. Their product has modulus $p$, so both have modulus $\sqrt p$, and $|K_p(a,b)|\leq2\sqrt p$. These are the reciprocal roots; the roots in the variable $T$ have modulus $p^{-1/2}$. \begingroup\raggedright The entry theorem is \textit{ThetaSum.completeKloostermanBound} in the module \textit{ThetaSumKloostermanPowerIdentity}. The external curve result is proved code that is compiled with the project, not a newly declared axiom. \par\endgroup \subsection{Prime boxes and reciprocal sums} The formal proof of (22)--(23) develops the sum-product and weighted multilinear estimates behind the Bourgain--Garaev argument \cite{bourgain-garaev,bourgain}. Selective attributed ports of combinatorial lemmas from lean-bourgain and LeanAPAP \cite{command-master,dillies} support this part. The imported results are themselves checked proofs. One useful intermediate result is a uniform prime-box estimate. There are absolute constants $c>0$ and $p_0$ such that, for prime $p\geq p_0$, nonzero $a$, and sets of primes $P_i\subset[1,K_i]$, \begin{equation*}\left|\sum_{q\in P_0,\ r\in P_1,\ s\in P_2}e_p(aq^{-1}r^{-1}s^{-1})\right| \leq R\exp\!\left(-c\frac{\log K_0\log K_1\log K_2}{(\log p)^2}\right),\tag{55}\end{equation*} where $R=K_0K_1K_2$, provided $K_2\leq K_1\leq K_0$, $\log K_i\geq\sqrt{\log p}$, and $R\leq\sqrt p$. Reciprocal moment estimates, weighted trilinear cancellation, and all integer choices of moment order are included in the formal proof. For an initial interval $1\leq n\leq T$, factor each integer canonically as $n=qrs\,m$, where $q\geq r\geq s$ are its three largest prime factors with multiplicity, using $1$ when too few factors exist. Write $x=\log p$, $\ell=\log x$, and $y=\log T$, and choose \begin{equation*}\beta=C\ell x\,y^{-3/2},\quad A=\lfloor T^{1/\ell}\rfloor,\quad B_0=\lfloor T^\beta\rfloor,\quad H=\lfloor T^{1-\beta}\rfloor.\tag{56}\end{equation*} Here $C$ is a sufficiently large absolute constant and $B_0$ is local to this construction. Call $n$ good when $q\geq A$, $s\geq B_0$, and $qrs\leq H$. An elementary Rankin estimate for smooth numbers and prime-window counting give, uniformly in (23), \begin{equation*}\#\{1\leq n\leq T:n\ {\rm not\ good}\}\leq30000\beta\ell^2T.\tag{57}\end{equation*} The checked exceptional-set argument separately covers a small largest prime, an excessively large first pair, a small third prime with bounded first pair, and an excessively large first triple. The smooth-number estimate is proved using an Euler product and Rankin's method. This avoids leaving a smooth-number theorem as an additional hypothesis. \subsection{Exact separation of the remainder constraints} For a good integer, the remainder satisfies both $m\leq\lfloor T/(qrs)\rfloor$ and $P^+(m)\leq s$, with $P^+(1)=1$. The formal proof separates these two comparisons by an exact finite Fourier identity, rather than by discarding a boundary strip. For integers $0\leq u,v\leq T$, put $Q=2T+1$. Fourier inversion of the interval $[0,T]$ in $\mathbb Z/Q\mathbb Z$ yields coefficients $c_k$ such that \begin{equation*}\mathbf{1}_{v\leq u}=\sum_{k\in\mathbb Z/Q\mathbb Z}c_k e_Q(-k(T-u))e_Q(-kv),\qquad \sum_k|c_k|\leq2+\log Q.\tag{58}\end{equation*} Explicitly, $c_k=Q^{-1}\sum_{t=0}^T e_Q(kt)$. There is no wraparound: $T-u+v$ lies in $[0,2T]$ and is at most $T$ exactly when $v\leq u$. Applying (58) to the two comparisons costs at most $(2+\log(2T+1))^2$. Ordering the three primes, their lower cutoffs, and their product cutoff can all be kept in one bounded weight on the entire prime triple. Cauchy--Schwarz in that triple turns distinct remainders $m,m'k$ for $a\in\mathcal A$, $b>s$ for $b\in\mathcal B$, and $2kX^{2k-1},2sY^{2s-1}k$, these endpoints satisfy the hypotheses of \eqref{eq:bilinear}. For any orders $k,s$ in the range, $2k\log k+2s\log s\le4x^{0.31}\log(2x^{0.31})X/2$ and $b>Y/2$. There are at most $3x$ dyadic endpoints, as every endpoint is less than $p$. After division by $T$ the whole contribution is at most $2304x^4\Delta$. We record the arithmetic absorbing the two errors. For $\ell\ge250$, \[ e^{0.10\ell}>2000\ell^2(70\log\ell+50),\qquad e^{0.07\ell}>16000\ell . \] Both hold at $250$ (use $e^{25}>7\cdot10^{10}$, $e^{17.5}>3\cdot10^7$, $\log250<5.53$), and their left-to-right ratios increase by logarithmic differentiation. By \eqref{eq:mass}, $r\le32\log\ell+19$ and $\log(1+\#P)\le2x^{0.90}$. The first inequality gives $(r+1)\log(1+\#P)5\log\ell$. Thus the floor error costs at most $T/\ell^5$. The second gives $x^{0.07}/1600>10\ell>\log2304+4\ell+5\log\ell$, so the sum over boxes also costs at most $T/\ell^5$. Finally $e^{-\lambda}\le1/(7\ell^4)<1/10$, and \[ (1+\lambda)(e^{-\lambda}+e^{-2\lambda})+2\ell^{-5} \le\ell^{-4}\!\left[\frac{1.1}{7}(4\log\ell+3.01)+\frac2\ell\right] \le\frac{3(1+\log\ell)}{4\ell^4}. \] This proves \eqref{eq:recip}. \subsection{From reciprocal sums to the sign} Fix an odd $u\le B$, with $B$ as in (25). For $2T_{\min}\le T\le U$, subtraction of the even terms uses \eqref{eq:recip} at $T$ and $T/2$, both within its stated range. Thus for each nonzero twist $v$ the odd reciprocal prefix has absolute value at most $(9/8)T(1+\log\ell)/\ell^4$. For odd $n$ put $z=[u(2n)^{-1}]_p$. By (9) and (31) the sign in (27) is the negative of $F(z)=2\mathbf1_{[0,L)}(z)-1$, where $L=(p+1)/2$. Put $H=\lceil32\ell^3\rceil$, $W=\lceil p/H\rceil$. On $\mathbb Z/p\mathbb Z$ an upper bound for $F(z)$ is \[ Q(z)=\frac2W\sum_{j=0}^{W-1}\mathbf1_{[0,L+W)}(z+j)-1 . \] Indeed all the shifts of $z\in[0,L)$ stay in the enlarged interval. Also $-F(z)=F(-z)$ at nonzero residues, giving an upper bound for the opposite sign by reflection. The sampled residues are nonzero since $u\le BH$, with both frequency signs, gives at most $2+\log H$. Hence the nonconstant coefficient mass of $Q$ is at most $8(1+\log\ell)$. All nonzero frequencies give nonzero twists. The odd reciprocal prefix bound, applied also after reflection, now gives \begin{equation} \left|\sum_{\substack{1\le n\le T\\n\ {\rm odd}}}-\lambda_p(un^{-1})\right| \le \delta T,\qquad \delta=\frac1{4\ell^3}+\frac{9(1+\log\ell)^2}{\ell^4}. \label{eq:sign} \end{equation} \subsection{The error in the original normalization} Set $a=\lceil2e^g\rceil$, $b=\lfloor U\rfloor$. From (25), $\log Z\le64\ell^2+2\log210^6\ell^4$. Substitution in \eqref{eq:finite} shows that $|G-\pi^2x/16-T_{\rm small}|\le2345\ell^4+237\le0.01x$. The total error is at most $0.091x<\pi^2x/80$. Hence $G>\pi^2x/20$, or $S(p)>(2/5)p\log p$, as asserted. \hfill\rule{0.65em}{0.65em} \section{Formal statements and verification}\label{sec:verification} \subsection{The two floor-sum statements} \begingroup\raggedright The entry module for Theorem A is \path{Maths/ThetaSumAsymptoticProved.lean}. Its theorem \path{ThetaSum.theta_sum_floor_asymptotic} displays both sums in (1), the rational quotient $hj/p$ and its natural-number floor, followed by the asymptotic estimate (2). Here the quotient is nonnegative, so the natural-number floor is the usual floor. The shorter theorem \path{ThetaSum.asymptoticFormula} uses the named definition of $S$. \par\endgroup The limit along primes is implemented as the intersection of the at-infinity filter with the principal filter of prime numbers. Infinitude of primes gives its nontriviality in \path{ThetaSum.primeFilter_neBot}. The same module proves Corollary 2 as \path{ThetaSum.theta_sum_growth_conjecture}. \noindent The entry module for Theorem B is \path{Maths/ThetaSumExplicitThreshold.lean}. Its declaration \path{ThetaSum.theta_sum_floor_explicit_two_fifths} displays the same double sum. The only hypotheses are that $p$ is prime and that $250\le\log(\log p)$. The declaration \path{ThetaSum.theta_sum_explicit_two_fifths} states the result using $S$. \subsection{A map for checking the proof} \begingroup\raggedright For the reduction in Section 2, useful entry declarations are \textit{S\_\allowbreak{}eq\_\allowbreak{}cotangent\_\allowbreak{}matrix}, \textit{rpsi\_\allowbreak{}eq\_\allowbreak{}harmonicPsi}, \textit{sum\_\allowbreak{}rpsi\_\allowbreak{}grid}, \textit{poleColumn\_\allowbreak{}eq\_\allowbreak{}digamma\_\allowbreak{}and\_\allowbreak{}tail}, and \textit{normalized\_\allowbreak{}S\_\allowbreak{}fluctuation\_\allowbreak{}reduction}. The formal digamma function is linked to the derivative of the real log-gamma function and to its harmonic series; it is not an arbitrary function satisfying assumed identities. \par\endgroup \begingroup\raggedright The background Hardy--Dedekind identity in Section 1.1 is \textit{ThetaSum.F\_\allowbreak{}eq\_\allowbreak{}dedekind\_\allowbreak{}prime} in \textit{Maths/ThetaSumHardy.lean}. The main proof uses the cotangent reduction described above. \par\endgroup \begingroup\raggedright For Sections 4--5, the main declarations include \textit{half\_\allowbreak{}count\_\allowbreak{}le\_\allowbreak{}spectral\_\allowbreak{}energy}, \textit{oddInterval\_\allowbreak{}column\_\allowbreak{}bound}, \textit{cell\_\allowbreak{}oddIntervals\_\allowbreak{}bound}, \textit{largeNumerators\_\allowbreak{}bound\_\allowbreak{}of\_\allowbreak{}budget}, and \textit{OmegaCounting.prime\_\allowbreak{}divisorEnergy\_\allowbreak{}le}. The modules \textit{ThetaSumActualHead}, \textit{ThetaSumActualMiddle}, \textit{ThetaSumActualRanges}, \textit{ThetaSumActualTail}, and \textit{ThetaSumActualSmallNumerators} connect the estimates to the actual sums and rounded cutoffs. Some explicit numerical constants in the formal development are deliberately coarser than those in informal working notes; the stated error scale is the same. \par\endgroup \begingroup\raggedright For Section 7, the main entry modules are \textit{ThetaSumKloostermanPowerIdentity}, \textit{ThetaSumPrimeBoxCancellationProved}, \textit{ThetaSumIntegerComparisonFourier}, \textit{ThetaSumConstrainedPrimeBox}, \textit{ThetaSumGoodSumLogBound}, and \textit{ThetaSumBourgainGaraevProved}. Full names begin with \textit{Maths.} when used as Lean imports. The declaration audit lists the intermediate theorems in dependency order. \par\endgroup \begingroup\raggedright The modules for Section~\ref{sec:effective} have the prefix \path{Maths.ThetaSumExplicitThreshold}. The suffixes \path{Boxes}, \path{PrimeMass}, and \path{Selection} cover \eqref{eq:boxes}--\eqref{eq:mass}. The suffixes \path{Sieve}, \path{Factors}, \path{Rectangles}, \path{Pairs}, and \path{Reciprocals} lead to \eqref{eq:recip}. The remaining analytic steps use \path{Smoothing}, \path{Fourier}, \path{Prefixes}, and \path{Transfer}. In particular, the pointwise declaration \path{ThetaSum.explicit_threshold_transfer} proves the $x/100$ allowance in the original normalization. Its inputs for \eqref{eq:finite} are \path{normalized_S_fluctuation_reduction}, \path{actualDigammaHead_bound}, \path{actual_digamma_middle_transfer}, and \path{actualDigammaTail_bound_of_weil}, all in the namespace \path{ThetaSum}. \par\endgroup \subsection{Verification record} Both proofs use Lean 4.33.1 and Mathlib v4.33.1 \cite{lean}. The October 2026 verification of Theorem A included an axiom audit of 1,020 declarations, a fresh kernel replay, and an isolated rebuild of its local transitive sources. On 30 November 2026 the project build also checked Theorem B. Its separate audit covers 24 declarations, including both final statements. A kernel replay checked 17 modules against their imports, including the bilinear estimate, the finite range and Weil estimates, and the 14 explicit-threshold modules. In both audits the reported dependencies are subsets of \textit{propext}, \textit{Classical.choice}, and \textit{Quot.sound}. The companion archive \path{theta_sum_verification.zip} contains the Lean sources for both theorems, the pinned dependency versions, a source manifest, and both declaration audits. To reconstruct the external curve dependency and build the proof, run the following from the extracted archive root. \begin{quote}\footnotesize \begin{verbatim} python bootstrap_external.py lake exe cache get lake build lake env lean experiments/codex/AsymptoticFormalizationAudit.lean lake env lean experiments/codex/ExplicitThresholdAudit.lean python verify_sources.py \end{verbatim} \end{quote} The first command reconstructs nine upstream files at the pinned commit. The two Lean audits report the assumptions of the named declarations. The last command verifies file hashes. The archive README also gives the separate replay commands and a direct calculation of Table~\ref{tab:numerical}. \subsection{Attribution and external sources} The arithmetic sum and motivating conjectures are due to Berndt, Bhat, Meyer, Xie and Zaharescu \cite{bbmxz}. The exponential-sum ingredients are classical results of Weil and Bourgain--Garaev \cite{bourgain-garaev,bourgain,weil}; Harcos's notes and \cite{iwaniec-kowalski} describe the routes used for the Weil input. The present project assembles the asymptotic argument above and formalizes it, with attribution to the external formal developments used for those inputs. The Math Inc curve development \cite{math-inc} was ported from Lean/Mathlib v4.26.0-rc2 to v4.33.1. The cited upstream commit contains no licence file. The companion archive records the upstream location, file hashes and compatibility edits. Its bootstrap retrieves the files directly from upstream and reconstructs the checked versions. The selective ports from lean-bourgain and LeanAPAP retain their Apache-2.0 licences and source attribution. The bibliography and the archive identify the exact commits \cite{command-master,dillies}. \begin{thebibliography}{12} \small\raggedright \bibitem{bbmxz} B. C. Berndt, R. N. Bhat, J. L. Meyer, L. Xie and A. Zaharescu. An Arithmetic Sum Associated with the Classical Theta Function. Results in Mathematics 81 (2026), article 25. Also arXiv:2501.03234v3. \url{https://doi.org/10.1007/s00025-025-02584-2}. \bibitem{bourgain} J. Bourgain. On Exponential Sums in Finite Fields. In: I. B\'ar\'any, J. Solymosi and G. S\'agi (eds), \textit{An Irregular Mind}, Bolyai Society Mathematical Studies 21, pp. 219--242. Springer, Berlin, Heidelberg (2010). \url{https://doi.org/10.1007/978-3-642-14444-8_4}. \bibitem{bourgain-garaev} J. Bourgain and M. Z. Garaev. Sumsets of reciprocals in prime fields and multilinear Kloosterman sums. Izvestiya: Mathematics 78 (2014), 656--707. Preprint arXiv:1211.4184, Theorem 16. \url{https://arxiv.org/abs/1211.4184}. \url{https://doi.org/10.1070/IM2014v078n04ABEH002703}. \bibitem{command-master} Command-Master and contributors. lean-bourgain. Pinned snapshot {07fe8b2f\allowbreak{}eac3e72d\allowbreak{}4f0bd1c8\allowbreak{}d094e1eb\allowbreak{}d0a02ffb}. Apache-2.0. \url{https://github.com/Command-Master/lean-bourgain/tree/07fe8b2feac3e72d4f0bd1c8d094e1ebd0a02ffb}. \bibitem{dillies} Y. Dillies and contributors. LeanAPAP. Pinned snapshot {ff5ae592\allowbreak{}fc73de17\allowbreak{}9b382c49\allowbreak{}f1f6c700\allowbreak{}587f99f8}. Apache-2.0. \url{https://github.com/YaelDillies/LeanAPAP/tree/ff5ae592fc73de179b382c49f1f6c700587f99f8}. \bibitem{iwaniec-kowalski} H. Iwaniec and E. Kowalski. Analytic Number Theory. American Mathematical Society Colloquium Publications 53, 2004. Chapter 11. \url{https://doi.org/10.1090/coll/053}. \bibitem{korolev} M. A. Korolev. Vinogradov's sieve and an estimate for an incomplete Kloosterman sum. Sbornik: Mathematics 213 (2022), 216--234. \url{https://doi.org/10.1070/SM9572}. \bibitem{lean} The Lean community. Lean 4, version 4.33.1, and the Mathlib community. Mathlib, tag v4.33.1. Formal proof environment used for this snapshot. \url{https://github.com/leanprover-community/mathlib4/tree/v4.33.1}. \bibitem{math-inc} Math Inc. RiemannHypothesisCurves: a formal proof of the Riemann hypothesis for curves. Pinned snapshot {c99880df\allowbreak{}f2a087d5\allowbreak{}9147ab83\allowbreak{}2074379a\allowbreak{}c28f7e68}. \url{https://github.com/math-inc/RiemannHypothesisCurves/tree/c99880dff2a087d59147ab832074379ac28f7e68}. \bibitem{minelli} P. Minelli, A. Sourmelidis and M. Technau. Bias in the number of steps in the Euclidean algorithm and a conjecture of Ito on Dedekind sums. Mathematische Annalen 387 (2023), 291--320. Theorem 2.1. Also arXiv:2206.03214. \url{https://doi.org/10.1007/s00208-022-02452-2}. \bibitem{nist} NIST Digital Library of Mathematical Functions. Chapter 5: Gamma Function, especially Sections 5.4, 5.5, 5.7 and 5.11. \url{https://dlmf.nist.gov/5}. \bibitem{weil} A. Weil. On some exponential sums. Proceedings of the National Academy of Sciences of the United States of America 34 (1948), 204--207. \url{https://doi.org/10.1073/pnas.34.5.204}. \end{thebibliography} \end{document}