\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,j
0$ 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 j
p$ 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 n
A_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_1 Z}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}) H$, 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\log2