% !TeX program = pdflatex \documentclass[singlecolumn]{reinpaper} \usepackage[english]{babel} \usepackage{adjustbox} \setlength{\emergencystretch}{2em} \renewcommand{\arraystretch}{1.25} \title{Bounded Representations by Three Signed Squares and the Continued Fractions of Real Quadratic Forms} \author{Tao REN} \reinaffiliation{AI Researcher} \reinemails{\href{mailto:tempest.ren@rein-protocol.org}{tempest.ren@rein-protocol.org}} \reinshorttitle{Bounded Representations by Three Signed Squares} \reintrack{Number theory} \reinstatus{PREPRINT} \reingithub{https://github.com/tempest2023/erdos-1148} \begin{document} \maketitle \begin{abstract} We prove that every sufficiently large integer $n$ admits integers $x,y,z$ with $n=x^2+y^2-z^2$ and $\max(x^2,y^2,z^2)\le n$, as asked in Erdős Problem 1148. For every sufficiently large squarefree $d\equiv2,3\pmod4$, at least one reduced cycle of discriminant $4d$ contains two consecutive partial quotients equal to one. Such a cycle yields a bounded representation of $d$. Let $R(d)$ count all reduced states of discriminant $4d$. If every cycle avoids adjacent ones, a covering estimate and a count of pairs at fixed mixed trace give $R(d)\ll d^{1/2-\delta}$ for an absolute $\delta>0$. For every fixed $\epsilon>0$, congruence roots and a lower bound for quadratic character values at one give $R(d)\gg_\epsilon d^{1/2-\epsilon}$. A separate construction for fixed square classes extends the result to all sufficiently large integers. The proof is formalized in Lean and uses no equidistribution theorem. \end{abstract} \section*{Introduction} Chojecki [Ch] proved that every sufficiently large integer $n$ has a representation $n=x^2+y^2-z^2$ with all three squares at most $n$. For nonsquare $n$, he applies the Duke equidistribution theorem in the form of Einsiedler, Lindenstrauss, Michel and Venkatesh [ELMV] to primitive forms of discriminant $4n$. An integral point in a suitable open set, followed by a parity correction, gives the three integers. An unconditional Lean proof using packet entropy and full support is also available [Lean]. Our argument starts from the period of a reduced quadratic irrational. We prove that, for each sufficiently large squarefree $d\equiv2,3\pmod4$, some reduced cycle of discriminant $4d$ contains two consecutive digits equal to one. When these digits occur, one of three successive states gives the parity needed to construct integers $x,y,z$ (Section 16). To force a hit, we count all reduced states at the same discriminant twice. Avoidance restricts both continued-fraction endpoints, and counting close pairs by their mixed trace bounds the number of states that can fit in the surviving boxes. Counting roots of quadratic congruences gives a larger lower bound. Section 17 proves the two bounds and deduces the representation theorem. Sections 18–20 give the discrete and analytic estimates used in Lean. Sections 8–9 explain how scaling and a separate construction for each small squarefree kernel extend the result to all sufficiently large integers. The qualitative word hit itself also follows from [ELMV, Theorem 2.3 and the deduction immediately following it]. On the surface of forms of discriminant one, take a small relatively compact open neighborhood of $(X^2-XY-Y^2)/\sqrt5$. Its roots satisfy $-1<\alpha<0$ and $3/2<\beta<2$ throughout a sufficiently small neighborhood, with positive leading coefficient. These strict inequalities give reduction and force the first two regular continued-fraction digits of $\beta$ to be one: $1<1/(\beta-1)<2$. The normalized primitive forms of discriminant $4d$ eventually meet this neighborhood. Scaling preserves the roots, and the middle coefficient of the integral form is even since its discriminant is divisible by four. This gives precisely a state in the family of Section 16. The argument explains what equidistribution already implies; the proof below obtains the hit directly. Its fixed-trace count is related to the pair-counting basic lemma in [ELMV, Section 3]. Here it bounds the number of states in boxes covering a forbidden-word set. \section{Fixing one square} Call a representation \(n=x^2+y^2-z^2\) by integers bounded if \(\max\{x^2,y^2,z^2\}\le n\). \textbf{Theorem 1.} Let \(n\ge4\) be an integer and put \(k=\lfloor\sqrt n\rfloor\). With \(x=k\), a bounded representation exists if and only if \(r=n-k^2\not\equiv2\pmod4\). \textbf{Proof.} We have \(0\le r\le2k\) since \(n<(k+1)^2\). A difference of squares is congruent to 0, 1, or 3 modulo 4, which proves necessity. If \(r=2t+1\), take \(y=t+1,z=t\). Their squares differ by \(r\), and \(0\le t\le k-1\). If \(r=4t\), take \(y=t+1,z=t-1\). The difference is \(4t\) and \(0\le t\le k/2\). Since \(k\ge2\), we have \(t+1\le k\) and \(|t-1|\le k\). In both cases all three squares are at most \(k^2\). In particular, every \(n\ge4\) congruent to 0 or 1 modulo 4 is represented, since \(k^2\) also has one of these two residues. In each interval between consecutive squares, group the remainders starting at \(r=0\) into blocks of four. Exactly three remainders in each complete block qualify. At most three remainders are left over in each interval, including the last, truncated interval. Up to \(X\) the count is therefore \(3X/4+O(\sqrt X)\), with one end correction for each of at most \(1+\sqrt X\) intervals. This is the density achieved by fixing \(x=k\). \section{Varying the first square} \textbf{Theorem 2.} For a nonnegative integer \(n\), put \(k=\lfloor\sqrt n\rfloor\). A bounded representation exists if and only if there are integers \(x,u,v\) satisfying \begin{equation}\label{eq:s2-1} 0\le x\le k,\quad 0\le u\le v,\quad u\equiv v\pmod2,\quad u+v\le2k,\quad uv=n-x^2. \end{equation} \textbf{Proof.} Replace the coordinates by their absolute values. Since \(x^2\le n\), we have \(y^2-z^2\ge0\), so \(y\ge z\). Taking \(u=y-z,v=y+z\) gives \(uv=n-x^2\) and \(u+v=2y\le2k\). Conversely, put \(y=(v+u)/2,z=(v-u)/2\). The parity condition gives integers satisfying \(0\le z\le y\le k\), and \(y^2-z^2=uv\) as required. \section{Factor bounds after shifting the square} \textbf{Theorem 3.} Let \(n\ge0\) be an integer and \(k=\lfloor\sqrt n\rfloor\). Suppose \(j\ge0\) and \(k\ge2j+2\) are integers. If \(m=n-(k-j)^2=uv\) with \(u,v\ge j+2\) of the same parity, then \(n\) has a bounded representation. \textbf{Proof.} Write \(a=j+2\). The inequality \((u-a)(v-a)\ge0\) gives \(a(u+v)\le m+a^2\). Also, \begin{equation}\label{eq:s3-1} m+a^2 \le 2k(j+1)-j^2+(j+2)^2 =2k(j+1)+4j+4\le2k(j+2). \end{equation} Hence \(u+v\le2k\). Take \(x=k-j\), interchange the factors to ensure \(u\le v\), and apply Theorem 2. \textbf{Theorem 4.} Let \(n\) be an integer with \(k=\lfloor\sqrt n\rfloor\ge8\). If \(n\) has no bounded representation, all three of the following hold. \begin{enumerate} \item \(n-k^2\equiv2\pmod4\). \item \(p=n-(k-1)^2\) is prime. \item \(m=n-(k-3)^2\) is prime or three times a prime. \end{enumerate} \textbf{Proof.} The first condition follows from Theorem 1. Thus \(p,m\) are positive odd integers and \(m\ge6k-9>27\). If \(p\) were composite, both factors in a nontrivial factorization would be odd and at least 3. Theorem 3 with \(j=1\) would give a representation. This proves the second condition already for \(k\ge4\). If \(m\) is composite, Theorem 3 with \(j=3\) precludes a factorization with both factors at least 5. A nontrivial factorization must therefore have the form \(m=3q\). If \(q=cd\) were composite, take \(3\le c\le d\). Since \(m>27\), we have \(d>3\), and \(d\) is odd. Both factors in \(m=(3c)d\) would be at least 5, a contradiction. \section{Counting the exceptions} \textbf{Corollary.} Let \(E(X)\) count the integers in \([1,X]\) without a bounded representation. Then \begin{equation}\label{eq:s4-1} E(X)=O\!\left(\frac{X}{(\log X)^2}\right). \end{equation} In particular, the represented integers have natural density one. \textbf{Proof.} Write \(K=\lfloor\sqrt X\rfloor\) and discard the at most 63 integers with \(k<8\). By Theorem 4, each exception yields primes \(p,q\) and an integer \(s\in\{1,3\}\) such that \(m=sq\). Since \(n<(k+1)^2\), we have \(p<4k\) and \(q\le m<8k\). Given \((p,q,s)\), we recover both unknowns by \begin{equation}\label{eq:s4-2} 4k=sq-p+8,\qquad n=p+(k-1)^2. \end{equation} Thus each triple accounts for at most one exception. Writing \(\pi(t)\) for the number of primes up to \(t\) gives \(E(X)\le63+2\pi(4K)\pi(8K)\). Each prime in \((a,2a]\) divides \(\binom{2a}{a}\) because the numerator \((a+1)\cdots(2a)\) contains the prime and the denominator \(a!\) does not. Their product is at most \(\binom{2a}{a}\le4^a\). Set \(\vartheta(t)=\sum_{p\le t}\log p\) and sum over \(a=1,2,4,\ldots,2^{h-1}\) to obtain \(\vartheta(2^h)\le(2^h-1)\log4\). Rounding \(t\) up to a power of two gives \(\vartheta(t)\le2t\log4\). Primes at most \(\sqrt t\) number at most \(\sqrt t\), and each larger prime contributes at least \((\log t)/2\) to the logarithmic sum. Thus \(\pi(t)\le\sqrt t+2\vartheta(t)/\log t=O(t/\log t)\), as required. \section{Scope of the prime conditions} The prime conditions of Theorem 4 are necessary for an exception. For \(n=383\) both residuals are prime, \(383-18^2=59\) and \(383-16^2=127\), and \(383=14^2+14^2-3^2\). \section{Formal statements for the elementary constructions} In \texttt{Erdos1148.lean}, \texttt{floor\_\allowbreak{}construction} and \texttt{partial\_\allowbreak{}result} verify Theorem 1 and its consequence, and \texttt{factor\_\allowbreak{}criterion} verifies Theorem 2. Theorems 3 and 4 are implemented in \texttt{shifted\_\allowbreak{}factors} and \texttt{two\_\allowbreak{}prime\_\allowbreak{}obstructions}. The identities and bounds used to recover an exception are \texttt{recover\_\allowbreak{}from\_\allowbreak{}residuals} and \texttt{residual\_\allowbreak{}sizes}. Section 4 gives the combinatorial and asymptotic argument on paper. \section{Pointwise counting in a fixed real region} Write \(Q=x^2+y^2-z^2\) and \(B=\sqrt n\). By Theorem 1 it suffices to consider \(n\equiv2,3\pmod4\). Set \(X=x/B,\ T=(y-z)/B,\ V=(y+z)/B\) and take \begin{equation}\label{eq:s7-1} b(t)=\begin{cases}\exp(1-1/(1-t^2)),&|t|<1,\\0,&|t|\ge1,\end{cases} \; f(X)=b(100(X-0.75)),\; g(T)=b(100(T-0.50)). \end{equation} On the surface, \(V=(1-X^2)/T\). Where \(fg>0\), we have \(0.740 . \end{equation} The substitution gives \(dY\,dZ=\tfrac12\,dT\,dV\), and integration in \(V\) supplies \(1/T\). Dilation by \(B\) multiplies surface area by \(B^2\) and the gradient by \(B\), giving the real main-term scale \(B\). \subsection{Local densities and square factors} Every integer has a primitive representation without the real restriction. Choose \(x\in\{0,1\}\) of parity opposite to \(n\) and set \(y=(n-x^2+1)/2,\ z=y-1\). We compute the primitive local density as the limit of the number of solutions modulo \(p^a\) with at least one unit coordinate, divided by \(p^{2a}\). For an odd prime \(p\) the substitution \((x,y,z)\mapsto(x,u,v)=(x,y-z,y+z)\) is invertible modulo \(p\). Nonzero \(u\) contributes \(p(p-1)\) solutions, and \(u=0\) contributes \(p\#\{x:x^2=n\bmod p\}\). When \(p\mid n\), remove the origin. Each remaining solution has a unit partial derivative, so at the next level two digits are free and the third is fixed by a nonsingular linear equation. There are \(p^2\) lifts. With \(\chi_p\) denoting the Legendre symbol, this gives \begin{equation}\label{eq:s7-3} \alpha_p^*(n)= \begin{cases}1+\chi_p(n)/p,&p\nmid n,\\1-p^{-2},&p\mid n.\end{cases} \end{equation} At 2, every solution in the remaining classes has an odd coordinate. The squares 0, 1 and 4 modulo 8 have multiplicities 2, 4 and 2. For \(n\equiv2\pmod4\) the coordinates \(x,y\) are odd and \(n\bmod8\) determines the square of the third coordinate, giving 32 solutions. For \(n\equiv3\pmod4\) \(z\) is odd, \(x,y\) are even, and their squares add to 0 or 4 as required, again giving 32. For \(a\ge3\), pair the solutions modulo \(2^a\) by adding \(2^{a-1}\) to the first odd coordinate. This fixed-point-free involution toggles the bit of \(Q\) at position \(a\). One member of each pair has eight lifts and the other has none. The solution count quadruples at each step, so \(\alpha_2^*=32/64=1/2\). Direct enumeration gives the same counts modulo 8, 16 and 32. Write \(n=ds^2\) with \(d\) positive and squarefree. In the remaining residue classes \(d\equiv2,3\pmod4\) and \(s\) is odd. For odd primes write \(\chi(p)=(d/p)\) and set \(\chi(2)=0\). Rewriting an unramified factor as \((1-p^{-2})/(1-\chi(p)/p)\) gives the candidate primitive local product \begin{equation}\label{eq:s7-4} A(d,s)=\frac12\prod_{p>2}(1-p^{-2})\ L(1,\chi) \prod_{p\mid s}(1-\chi(p)/p). \end{equation} Here \(L(1,\chi)\) denotes the value obtained by approaching one from the right in the Euler factors at good primes. For each \(\epsilon>0\) the finite correction product is at least \(c_\epsilon s^{-\epsilon}\), since for all sufficiently large \(p\) one has \(1-1/p\ge p^{-\epsilon}\) and the remaining primes contribute a fixed positive factor. Section 17.4 supplies the lower bound for \(L(1,\chi)\) uniform in \(d\). Let \(W(n)\) and \(P(n)\) be the weighted counts of all and primitive representations, respectively. Splitting by the greatest common divisor of the three coordinates gives exactly \begin{equation}\label{eq:s7-5} W(n)=\sum_{a^2\mid n}P(n/a^2). \end{equation} Removing this divisor preserves the normalized point. A representation of \(d\) gives one in each of its square multiples. Theorem 5 treats the multiples \(ds^2\) of each fixed kernel, including kernels that lack a bounded representation. \subsection{Fourier expansion and the remaining error} Expand the count of all representations directly. The remaining classes force \(u=y-z\) to be odd and \(x\) to have parity opposite to \(n\). Conversely, for each positive odd \(u\) set \begin{equation}\label{eq:s7-6} R_u(n)=\{r\bmod 2u:r\not\equiv n\pmod2,\ r^2\equiv n\pmod u\}. \end{equation} If \(x\bmod 2u\) belongs to this set, then \(v=(n-x^2)/u\) is odd and the integers \(y,z\) are uniquely recovered. Thus in this region we have exactly \begin{equation}\label{eq:s7-7} W(n)=\sum_{u>0\ {\rm odd}}g(u/B) \sum_{r\in R_u(n)}\ \sum_{x\equiv r\ (2u)} f(x/B). \end{equation} Write \(e(t)=e^{2\pi it}\) and \(\widehat f(\xi)=\int f(t)e(-\xi t)dt\). Expand the periodic function of period \(2u\) given by \(\sum_j f((t+2uj)/B)\) into a Fourier series. Its coefficient at \(h\) is \(B\widehat f(hB/(2u))/(2u)\) by substitution. Repeated integration by parts gives absolute convergence. Thus \(W=M_0+E\), where \begin{equation}\label{eq:s7-8} M_0=B\widehat f(0)\sum_{u>0\ {\rm odd}}\frac{g(u/B)}{2u}|R_u(n)|, \quad E=B\sum_{u>0\ {\rm odd}}\frac{g(u/B)}{2u} \sum_{h\ne0}\widehat f(hB/(2u))\sum_{r\in R_u(n)}e(hr/(2u)). \end{equation} For fixed \(h\), the argument \(hB/(2u)\) stays bounded because \(u\asymp B\). Bounding the root sum by \(|R_u(n)|\) gives the same order as the zero-frequency term. The condition \(M_0>0\) detects a modulus with roots. A contribution to \(W(n)\) requires a root in the prescribed real interval. \textbf{A sufficient estimate for this approach.} For the fixed functions \(f,g\), suppose there exist \(\eta>0,c>0,C>0\) such that for every sufficiently large remaining \(n=ds^2\), \begin{equation}\label{eq:s7-9} M_0(n)\ge c B^{1-\eta/2},\qquad E(n)\ge-C B^{1-\eta}. \end{equation} Then \(W(n)>0\). A weaker sufficient estimate would give, for each such \(n\), both \(M_0>0\) and \(E\ge-(1-\delta)M_0\) for a fixed \(\delta>0\). For primitive points it would suffice to establish \(P(n)=c_w B A(d,s)+O_w(B^{1-\eta})\) and \(A(d,s)\gg_w B^{-\eta/2}\), with \(c_w>0\) and all constants independent of \(d,s\). \subsection{Pointwise computations} Direct enumeration uses the congruence sum above. Points are counted where \(fg>0\). The column \(W\) is the direct weighted sum. In \(M_0\) the integral \(\int f\) was approximated by 10,000 midpoint samples. Values are rounded to six decimal places. \begin{center}\small \begin{adjustbox}{max width=\linewidth}\begin{tabular}{@{}lrrrr@{}} \toprule \(n\) & Points in region & Primitive points & \(M_0\) (approx.) & \(W\) (approx.) \\ \midrule 30603 & 0 & 0 & 0 & 0 \\ 271803 & 0 & 0 & 0.040315 & 0 \\ 3006003 & 0 & 0 & 0.041591 & 0 \\ 27018003 & 0 & 0 & 0.196625 & 0 \\ 999983 & 0 & 0 & 0.042720 & 0 \\ 10000019 & 1 & 1 & 0.230424 & 0.521809 \\ \bottomrule \end{tabular}\end{adjustbox} \end{center} The first four inputs are \(3s^2\) with \(s=101,301,1001,3001\). The cases with positive zero-frequency term and zero weighted count exhibit complete cancellation at finite inputs. The second row can be checked with integers alone. The interval is \(386\le x\le396\) and the only odd values of \(u\) are 257, 259, 261, 263 and 265. Only 259 and 263 admit eligible roots. Modulo 518 they are 112 and 406, and modulo 526 they are 178 and 348. All miss the interval, proving \(M_0>0=W\) independently of quadrature. The last row contains the point \((2352,2202,617)\). The Lean lemmas are \texttt{square\_\allowbreak{}multiple} for closure under square multiplication, \texttt{primitive\_\allowbreak{}unbounded} for primitive solutions with adjacent coordinates, and \texttt{patch\_\allowbreak{}certificate} for the region inequalities. The two pointwise estimates for this narrow region remain conjectural. The proof of the main theorem uses the continued-fraction region in Section 16. \section{A pointwise theorem in each square class} \textbf{Theorem 5.} For every positive integer \(d\) there is an \(S(d)\) such that every integer \(s\ge S(d)\) gives a bounded representation of \(ds^2\). First consider a construction by rounding a real root. For odd \(s\) let \(h\) equal zero for odd \(d\) and one otherwise, and put \(t=\sqrt{d-1}-h\). For sufficiently large \(s\) one has \(T=s+2t\sqrt s>0\). Choose the least integer \(L\) with \(L\ge 2\sqrt T\) and \(L\equiv 1+s\pmod 4\). Then \(0\le L-2\sqrt T<4\), giving \begin{equation}\label{eq:s8-1} 0\le L^2/4-T < 2(L/2+\sqrt T)=O_d(\sqrt s) \end{equation} The smaller root of \(a(L-a)=T\) differs from \(L/2\) by \(O_d(s^{1/4})\). Round it to the nearest \(a\equiv1\pmod4\), a displacement of at most two. This changes \(a(L-a)\) by \(O_d(s^{1/4})\), since the linear coefficient is the difference of the roots and the quadratic coefficient has absolute value one. Thus \(b=L-a\equiv s\pmod4\), \(c=(ab-s)/2\) is even, \(a,b\sim\sqrt s\) and \(c=t\sqrt s+O_d(s^{1/4})\). Defining \(M=\left(\begin{smallmatrix}a&c\\2&b\end{smallmatrix}\right)\), we have \(M\equiv I\pmod2\) and \(\det M=s\). Let \(S\) have rows \((1,h)\) and \((h,h^2-d)\). Both diagonal entries are odd, so the diagonal entries of \(H=M^\mathsf{T}SM\) have the same parity. The three independent entries of \(H/s\) tend to \((1,\sqrt{d-1},-1)\). Writing \(H=\left(\begin{smallmatrix}A&Y\\Y&C\end{smallmatrix}\right)\), take \(x=(A-C)/2,\ y=Y,\ z=(A+C)/2\). Then \(x^2+y^2-z^2=-\det H=ds^2\), and \((x,y,z)/s\to(1,\sqrt{d-1},0)\). When \(d>1\) all three limiting coordinates have absolute value strictly below \(\sqrt d\). \subsection{An integral construction} If \(d=k^2\) is a square, use \((ks,0,0)\). Otherwise set \(k=\lfloor\sqrt d\rfloor\ge1\) and \begin{equation}\label{eq:s8-2} L_0=k+1,\quad R=(1+d)(2L_0+1),\quad K=1000R+k+10. \end{equation} We may take \(S(d)=\max(4,K^4)\). For even \(s\), the integer \(ds^2\) is a multiple of four and Theorem 1 applies. Suppose \(s\) is odd. Set \(m=\lfloor\sqrt s\rfloor,\ q=\lfloor\sqrt m\rfloor\), so \(q\ge K\). Choose the unique member of \(m+k+2,m+k+3\) as \(L\) satisfying \begin{equation}\label{eq:s8-3} L\equiv 1+(s-1)/2+(1-d)\pmod2. \end{equation} Put \(D=L^2-s-2km\). From \(m^2\le s<(m+1)^2\) and \((k+3)^2\le m\) we obtain \(0\le D\le 7m\). Set \(j=\lfloor\sqrt D\rfloor\) and choose \(w\in[j,j+3]\) so that \(L-w\equiv1\pmod4\). Define \begin{equation}\label{eq:s8-4} a=L-w,\quad b=L+w,\quad c=(ab-s)/2. \end{equation} Then \(a\equiv1\pmod4,\ b\equiv s+2(1-d)\pmod4\) and \(c\equiv1-d\pmod2\). For the diagonal form \(\operatorname{diag}(1,-d)\) the upper right entry of the change-of-basis matrix has precisely this parity. We have \(ab-2c=s\). Put \(E=100(q+k+10)\). Since \(j^2\le7m<7(q+1)^2\), we have \(j\le3(q+1)\), and \begin{equation}\label{eq:s8-5} -6j-9\le 2(c-km)=D-w^2\le 2j+1. \end{equation} Hence \(|a-m|,|b-m|,|c-km|\le(E-4)/2\). Since \(q\ge K\), we also have \(RE\le200Rq0>C\) and the last two give \(-2YDT^2\), a multiplier in a small class satisfies \(s\ge T\). This gives a single threshold for all integers. \section{A region for squarefree discriminants with unrestricted parity} For an integral form \(A U^2+2YUV+CV^2\) let \(Y^2-AC=d>0\). Its discriminant is \(4d\). If \(A,C\) have the same parity, the inverse coordinate transformation is integral. The following region also controls the sizes and allows all parity patterns. \textbf{Theorem 7.} If some positive rational \(\lambda\) satisfies \begin{equation}\label{eq:s10-1} |A-\lambda|,\ |Y-\lambda|,\ |C+6\lambda|\le\lambda/1000, \end{equation} then \(d\) has a bounded representation. \textbf{Proof.} Apply the indicated integral change of basis \(G\) of determinant one, replacing the coefficient matrix by \(G^\mathsf{T}HG\). Negating the whole form or the middle coefficient preserves \(Y^2-AC\). The last column gives the transformed and adjusted coefficients at the center \((1,1,-6)\). \begin{center}\small \begin{adjustbox}{max width=\linewidth}\begin{tabular}{@{}lrrr@{}} \toprule Parity & \(G\) (rows) & Sign change & Central \((A',Y',C')\) \\ \midrule \(A\) odd, \(C\) even & \((1,1);(0,1)\) & None & \((1,2,-3)\) \\ \(A\) even & \((2,1);(1,1)\) & Middle coefficient & \((2,1,-3)\) \\ \(A,C\) both odd & \((3,-2);(2,-1)\) & Whole form & \((3,1,-2)\) \\ \bottomrule \end{tabular}\end{adjustbox} \end{center} The new diagonal entries agree modulo 2. In the three rows their residues are \(A,A+C\), \(C,A+C\) and \(A,C\), respectively. Each center satisfies \(A'>0>C'\) and \(|A'+C'|<2Y'\) with margins at least one. Relative to \(\lambda\) times the center, the error in each transformed coefficient is at most \(25\lambda/1000\) because the sum of absolute coefficients in each linear expression is at most 25. The strict inequalities persist throughout the region. Take \(x=(A'-C')/2,\ y=Y',\ z=(A'+C')/2\) and apply the calculation at the end of Theorem 5. In particular, if \(d=uv\) with \(u>0\) and \(|v-7u|\le u/1000\), then \(d\) is represented. Take \((A,Y,C)=(u,u,u-v)\) and \(\lambda=u\). There is no parity restriction on \(u,v\). For example, \(7013006=1001\cdot7006=2501^2+1003^2-498^2\) is squarefree since \(1001=7\cdot11\cdot13,\ 7006=2\cdot31\cdot113\), and its square-interval remainder is 2 modulo 4. \textbf{A sufficient condition for hitting the narrow region.} To apply Theorem 7 to all remaining squarefree \(d\), it would suffice that each sufficiently large squarefree \(d\equiv2,3\pmod4\) admit a form of discriminant \(4d\) and a positive rational scale in this region. All integral bases are allowed. Equivalently, for some positive \(A\) find \(Y\) nearby such that \(A\mid Y^2-d\) and \((A,Y,(Y^2-d)/A)\) satisfies the three inequalities. Choosing \(Y=A\) gives the factor-ratio corollary, which does not cover large prime \(d\). Sections 16 and 17 use a wider region. Theorem 6 handles the square multipliers. \subsection*{Formalization of Sections 8–10} Theorem 5 is \texttt{fixed\_\allowbreak{}square\_\allowbreak{}class}. The positive-integer decomposition and both directions of Theorem 6 are \texttt{squarefree\_\allowbreak{}decomposition} and \texttt{statement\_\allowbreak{}iff\_\allowbreak{}squarefree}. Theorem 7 and its factor-ratio corollary are \texttt{unmarked\_\allowbreak{}patch} and \texttt{near\_\allowbreak{}seven\_\allowbreak{}factors}. The numerical example is \texttt{example\_\allowbreak{}271803}. These results are in \texttt{Erdos1148.lean}, which imports only Std. \section{Principal and nonprincipal forms} Section 10 allows all integral forms of the given discriminant. The principal form \(U^2-dV^2\) gives a construction for one interval of remainders. For infinitely many other squarefree kernels, every integral basis of the principal form misses the required bounds. \textbf{Theorem 8 (a principal-form construction).} Write \(d=k^2+r\) with \(r\) even and nonnegative, and set \(F(U,V)=U^2+2kUV-rV^2=(U+kV)^2-dV^2\). If an integer \(j\) satisfies \begin{equation}\label{eq:s11-1} F(1,j)\ge0,\qquad F(1,j+1)\le0,\qquad F(2,2j+1)\ge0, \end{equation} then \(d\) has a bounded representation. In particular, for \(k\ge1,\ k+1\le r,\ 9r\le12k+4\) one may take \(j=1\). This interval imposes no condition on the prime factors of \(d\). \textbf{Proof.} Use the columns \((1,j),(1,j+1)\) as a new basis for \(F\). The new coefficients are \(A=F(1,j),\ C=F(1,j+1),\ Y=1+k(2j+1)-rj(j+1)\) and the basis has determinant one, so \(Y^2-AC=d\). Both diagonal coefficients are odd and \begin{equation}\label{eq:s11-2} A+C-2Y=F(0,1)=-r\le0,\qquad A+C+2Y=F(2,2j+1)\ge0. \end{equation} Consequently \((x,y,z)=((A-C)/2,Y,(A+C)/2)\) satisfies \(|z|\le x\) and \(|z|\le y\). Taking \(j=1\) reduces the three hypotheses to \(1+2k-r\ge0,\ 1+4k-4r\le0,\ 4+12k-9r\ge0\), as claimed. \textbf{Theorem 9 (descent obstruction for the principal form).} Suppose \(k\ge2,\ d=k^2+2\). If \(d=x^2+y^2-z^2\) is a bounded representation, then \(x+z\) cannot equal \(\pm(a^2-db^2)\) for coprime \(a,b\). In particular its matrix \begin{equation}\label{eq:s11-3} H=\begin{pmatrix}z+x&y\\ y&z-x\end{pmatrix} \end{equation} cannot arise from the principal form or its negative by an integral change of basis of determinant \(\pm1\). \textbf{Proof.} First classify small odd values on primitive columns. Suppose \(A=a^2-db^2\) is odd and \(|A|\le2k\). Replace \(a,b\) by their absolute values. Among primitive nonnegative columns giving \(A\), minimize \(b\). If \(b=0\), then \(a=1\) and \(A=1\). Otherwise \(b\ge1\). Put \(h=a-kb\). If \(h\le-1\), then \(0\le a\le kb-1\) implies \(A\le-2kb+1-2b^2<-2k\). If \(h=0\), then \(A=-2b^2\) is even. Hence \(h\ge1\). Using \((k^2+1)^2-dk^2=1\), make the integral substitution \begin{equation}\label{eq:s11-4} a'=(k^2+1)a-kdb,\qquad b'=(k^2+1)b-ka=b-kh . \end{equation} Its determinant is one, so it preserves primitivity, and expansion gives \(a'^2-db'^2=A\). Minimality gives \(|b-kh|\ge b\). Since \(kh>0\), we obtain \(kh\ge2b\). Therefore \begin{equation}\label{eq:s11-5} 2k\ge A=2b(kh-b)+h^2\ge bkh+h^2 . \end{equation} For \(b\ge2\) the right side exceeds \(2k\), so \(b=1\). Substitution shows that \(h\ge2\) would imply \(A>2k\). Hence \(h=1\) and \(A=2k-1\). The only possible small odd values are \(1,2k-1\). Each coordinate in a bounded representation has absolute value at most \(k\). If \(|x|=k\) or \(|y|=k\), two squares differ by 2, impossible modulo 4. Also \(z^2\le x^2\), so all absolute values are at most \(k-1\). Checking squares modulo 4 for \(d\equiv2,3\pmod4\) shows that \(x+z\) is odd. Its absolute value is at most \(2k-2\), hence would have to be one if it came from such a column. But then \begin{equation}\label{eq:s11-6} 2k+1=k^2+2-(k-1)^2\le x^2-z^2=(x+z)(x-z)\le2k-2, \end{equation} a contradiction. The first column of a unimodular matrix is primitive, which proves the last assertion. \textbf{Infinitely many squarefree instances.} Take \(k=18t+1\) for \(1\le t\le T\). Then \(k^2+2\) is odd and is 3 modulo 9. For a prime \(p\ge5\) the congruence \((18t+1)^2\equiv-2\pmod{p^2}\) has at most two residue classes. There are at most two roots modulo \(p\), and at each the derivative \(36(18t+1)\) is a unit. Substituting \(t+pj\) gives a unique lift. The number of parameters with a square factor is therefore at most \begin{equation}\label{eq:s11-7} \sum_{5\le p\le18T+2}2(T/p^2+1) \le T/2+2\pi(18T+2). \end{equation} We used \(\sum_{m\ge5}1/m^2\le\sum_{m\ge5}1/(m(m-1))=1/4\) and the upper bound \(p^2\le k^2+2\) on the possible primes \(p\). By Section 4 at least \(T/2-O(T/\log T)\) parameters yield squarefree kernels. Each admits the explicit representation \begin{equation}\label{eq:s11-8} (18t+1)^2+2=(18t)^2+(6t+2)^2-(6t-1)^2 \end{equation} with all three squares bounded. Thus Theorem 9 rules out the principal form for infinitely many represented squarefree kernels. A prime example is \(443=21^2+2=12^2+18^2-5^2\), whose primality follows by trial division up to 21. For \(k\ge4\), if \(2k+1\) is composite then Theorem 3 with \(j=1\) represents \(k^2+2\) since \(k^2+2-(k-1)^2=2k+1\). Section 17 counts reduced states across all classes. The constructions and descent are formalized in \texttt{consecutive\_\allowbreak{}shears}, \texttt{middle\_\allowbreak{}remainders}, \texttt{small\_\allowbreak{}odd\_\allowbreak{}principal\_\allowbreak{}norm} and \texttt{principal\_\allowbreak{}obstruction}. The composite criterion is \texttt{offset\_\allowbreak{}two\_\allowbreak{}composite}; \texttt{nonprincipal\_\allowbreak{}example} verifies 443. The squarefree parameter count is proved above. \section{Congruence windows and two low frequencies} Assume \(k^22k\) then parity gives \(u+v\ge2k+2\). Thus \begin{equation}\label{eq:s12-4} d=x^2+uv\ge x^2+(k+1)^2-(u-k-1)^2\ge(k+1)^2, \end{equation} a contradiction. \textbf{Necessity.} Take absolute values in a bounded representation. Then \(x,y\ge z\) and \(x,y,z\le k\). Set \(u=y-z\). Since \(d\) is nonsquare, \(u>0\). In both residue classes \(y,z\) have opposite parity, as do \(x,d\). From \begin{equation}\label{eq:s12-5} (x+y-z)^2-d=2(x-z)(y-z)\ge0 \end{equation} and \(d>k^2\) we get \(x+u\ge k+1\). Thus the point lies in the stated window. Exhausting the full window of Theorem 11 decides representability. \textbf{Two useful moduli.} If \(u\mid k+1\) with \(10\). The polynomial \(P=(\cos\theta-1/4)(1+\cos\theta)\) is a sufficient test, and the lattice argument removes the original restriction \(u\ge13\). Another choice is \begin{equation}\label{eq:s12-7} P_0=\cos\theta(1+\cos\theta)=\tfrac12+\cos\theta+\tfrac12\cos(2\theta). \end{equation} Termwise \(P_0-P=(1+\cos\theta)/4\ge0\), and \(P_0>0\) detects a hit by an individual root. With nonnegative weights, positivity of either sum suffices. Negative terms from other roots can cancel a hit. For squarefree \(d\) and odd \(u=\prod q\), with the \(q\) pairwise coprime prime powers, the Chinese remainder theorem gives an exact root sum. Choose \(e\in\{0,1\}\) of parity opposite to \(d\). At \(q=p^a\) with \(p\nmid d\), the full set is empty if there is no local root. Otherwise the local roots are \(\pm t_q\), since there are at most two modulo \(p\) and the derivative is a unit. If \(p\mid d\), the only root for \(a=1\) is zero and for \(a\ge2\) there are none. For a nonempty set write \(b_q\) for the inverse of \(2u/q\) modulo \(q\). Expanding by local factors gives, for \(h=1,2\), \begin{equation}\label{eq:s12-8} \sum_r \cos(h\theta)=(-1)^{eh}\cos(\pi h c_u/u) \prod_{q:\,p\nmid d}2\cos(2\pi h b_qt_q/q). \end{equation} The first sign comes from the coordinate modulo 2 and is retained also for even squarefree \(d\). There is also a gap criterion. On the circle of length \(2u\), reversing a local sign gives a fixed even step. Orient the signs so that the short arcs have lengths \(a_i\) in \((0,u)\). Up to translation the roots are their subset sums. If \(\sum_i a_i>u\), take the shortest prefix whose sum exceeds \(u\). Its sum \(S<2u\). The increasing partial sums from zero to \(S\) have gaps smaller than \(u\), including the closing gap \(2u-S\), which is also smaller than \(u\). Every open half-period thus contains a root. If the total is at most \(u\), the subset sums lie in a closed half-period and a suitably placed open half-period can be empty. The actual center determined by \(k\) can still give a hit. Lean verifies the two-factor sufficient condition as \texttt{four\_\allowbreak{}root\_\allowbreak{}window}. For example, take \(u=15\). If \(d\equiv1,4\pmod{15}\), then both 3 and 5 have two nonzero roots. Flipping their signs gives short arcs of relative lengths \(1/3\) and at least \(1/5\), totaling more than \(1/2\). Hence there is a hit for every \(k\ge30\) independently of the center. Lean also checks this by an exhaustive table modulo 30. Squarefreeness of \(d\) is unnecessary here. \subsection{Pointwise experiments} The local script \texttt{python3 window\_\allowbreak{}scan.py 200000} enumerates all 40,382 squarefree integers \(676\le d\le200000\) satisfying \(d-k^2\equiv2\pmod4\). Each \(d\) is counted once. The frequency test uses all odd \(13\le u\le k/2\) with unit root weights. Root counts and hits use integer arithmetic. When there is no hit, the full geometric window and direct enumeration of \((x,y)\) give independent checks. Trigonometric sums use double precision with zero tolerance \(10^{-10}(1+\#\text{roots})\). \begin{center}\small \begin{adjustbox}{max width=\linewidth}\begin{tabular}{@{}lrrr@{}} \toprule Outcome in tested range & Sum \(P\) & Sum \(P_0\) & Count \\ \midrule Hit & Positive & Positive & 39955 \\ Hit & Negative & Positive & 269 \\ Hit & Negative & Negative & 28 \\ Roots, no hit, represented elsewhere & Negative & Negative & 44 \\ Roots, no hit, unrepresented & Negative & Negative & 19 \\ No roots, represented elsewhere & 0 & 0 & 55 \\ No roots, unrepresented & 0 & 0 & 12 \\ \bottomrule \end{tabular}\end{adjustbox} \end{center} The table gives the contributions of the first two harmonics alongside the constant term and the observed hit count. It includes the square multiple \(271803=3\cdot301^2\). The certificate for \(443\) uses 7, outside the tested range. \begin{center}\small \begin{adjustbox}{max width=\linewidth}\begin{tabular}{@{}lrrrrr@{}} \toprule \(d\) & Roots & Constant term & First harmonic & Second harmonic & Hits \\ \midrule 443 & 0 & 0 & 0 & 0 & 0 \\ 706 & 2 & 0.5 & \ensuremath{-}0.317855 & \ensuremath{-}0.502996 & 1 \\ 755 & 2 & 0.5 & \ensuremath{-}0.676829 & \ensuremath{-}0.502996 & 0 \\ 1419 & 4 & 1 & \ensuremath{-}1.815866 & 0.327515 & 1 \\ 271803 & 107 & 26.75 & 9.731740 & \ensuremath{-}0.272591 & 62 \\ 10000019 & 726 & 181.5 & \ensuremath{-}3.171258 & 10.821078 & 359 \\ \bottomrule \end{tabular}\end{adjustbox} \end{center} Even two independent sign choices can miss the window for a given modulus. For \(u=21=3\cdot7\), the roots of the odd squarefree integer \(d=5371\) modulo 42 are \(4,10,32,38\). None has a representative in \([54,73]\). The roots for \(d=5119\) are the same, but one has a representative in \([52,71]\), namely 52. The even squarefree integers \(d=2746,2578\) both have roots \(11,17,25,31\). The first has no hit and the second has one. The script checks both frequencies for these four cases independently by CRT multiplication and by direct enumeration. Fix \(k\bmod42\) and \(d\bmod84\) as in any one example, and move the interval between successive squares upwards. The roots modulo 21, the required parity and the phase of the center are all preserved. The squarefree sieve below, with modulus 84, supplies a squarefree integer in every sufficiently large such interval. Thus, for one modulus with two split prime factors, arbitrarily large squarefree integers can exhibit either four missed roots or a hit with a negative trigonometric sum. \subsection{Limitations of complementary moduli} \textbf{Theorem 12.} Fix an upper bound \(U\) for small moduli and a width \(H\) at the upper end. In each of the odd and even squarefree families there are infinitely many \(d\) with \(d-k^2\equiv2\pmod4\) having both properties below. \begin{enumerate} \item Every odd modulus \(3\le u\le U\), every odd modulus \(u\ge3\) with \(k+1-H\le u\le k+1\), and every odd divisor of \(k+1\) with \(u>1\) has no square root of \(d\). \item An odd modulus outside these sets has a hit in the window of Theorem 10. \end{enumerate} \textbf{Proof.} For odd \(d\) take \(b=2\), and for even \(d\) take \(b=3\). Choose \(a\) with \(b^a-H>2\). Include every odd prime up to \(\max(3,U)\) in a finite set \(S\). For each odd integer \(b^a-j\) with \(0\le j\le H\), also include one of its prime factors in \(S\). Choose an odd prime \(q>U\) outside \(S\) and coprime to \(b(b^a-2)\). Take infinitely many \(m\ge a\) such that, for each prime in \(S\cup\{q\}\) coprime to \(b\), say \(p\), we have \(m\equiv a\pmod{p-1}\). Set \(k=b^m-1\). By Fermat's little theorem, \(k+1-j\) retains its parity and the chosen odd prime divisor. Divisibility persists directly when that divisor divides \(b\). The integer \(k+1\) has no odd divisor greater than one when \(b=2\), and every nontrivial divisor is divisible by three when \(b=3\). Prescribe \(d\) to be a nonzero quadratic nonresidue modulo each \(p\in S\) and prescribe \(d\equiv(b^a-2)^2\pmod q\), a nonzero residue. Impose \(d\equiv3\pmod4\) in the odd case and \(d\equiv2\pmod4\) in the even case. The Chinese remainder theorem gives one class modulo the fixed integer \(L=4q\prod_{p\in S}p\). In each interval \((k^2,(k+1)^2)\) it contains \(M=2k/L+O(1)\) candidate integers. For any \(p^2\) with \(p\nmid L\), at most \(M/p^2+1\) candidates are divisible by that square, and only \(p\le k+1\) can occur. By the prime-counting estimate of Section 4 and \(\sum_{p\ge5}p^{-2}\le1/4\), at most \(M/4+O(k/\log k)\) candidates are removed. Since \(L\) is fixed, squarefree candidates remain for all sufficiently large parameters. For \(p\mid L\) the prescribed conditions already exclude \(p^2\mid d\). Each surviving \(d\) satisfies the first assertion. Moreover, \(x=k-1\) has the required parity and satisfies \(x^2\equiv d\pmod q\). For sufficiently large \(m\) we have \(2q\le k\), and \(x\) lies in the wide window for \(q\). This proves the second assertion. For example, with \(U=9,H=3\), both \(983=24^2+24^2-13^2\) and \(1202=27^2+27^2-16^2\) admit hits at \(u=11\), although all the indicated small moduli, upper-end moduli and aligned divisors are rootless. Theorem 12 rules out a shortcut of fixed width. In both examples the successful modulus lies between the two excluded ranges. The Lean equivalence \texttt{statement\_\allowbreak{}iff\_\allowbreak{}window} identifies the main theorem with a geometric-window hit at every sufficiently large squarefree kernel left by Theorem 1. The Fourier expansion, the general subset-sum argument and the sieve in Theorem 12 are paper proofs. \section{Diagonal representations and prime discriminants} Squarefree kernels can be distinguished according to whether the two positive squares can be equal. This subproblem admits an exact congruence criterion. For primes, it leaves only the residue class three modulo eight to consider. \textbf{Theorem 13.} Let \(d>0\). If \(r^2\equiv2\pmod d\) is soluble, there exist integers \(a,b\) such that \begin{equation}\label{eq:s13-1} d=2b^2-a^2,\qquad a^2,b^2\le d . \end{equation} When \(d\) is squarefree, the converse holds as well. \textbf{Proof.} For a square \(d=k^2\) take \(a=b=k\). Otherwise set \(k=\lfloor\sqrt d\rfloor\). The grid \(0\le i,j\le k\) has \((k+1)^2>d\) points. Apply the pigeonhole principle to \((i,j)\mapsto i-rj\pmod d\). The difference \((a,b)\) of two distinct points satisfies \begin{equation}\label{eq:s13-2} |a|,|b|\le k,\qquad d\mid a^2-2b^2. \end{equation} Since \(-2d0\). For \(443=21^2+2\cdot1^2\) the larger square would be \(22^2>443\). Section 11 gives \(443=12^2+18^2-5^2\). \textbf{Theorem 15.} The positive integers admitting bounded diagonal representations are closed under multiplication. \textbf{Proof.} Every solution of \(n=2y^2-z^2>0\) can be reduced to a bounded one. First take absolute values. If \(y^2\le n\), then \(z^2=2y^2-n\le n\) and the solution is bounded. Otherwise \(y0\) consider the matrix \begin{equation}\label{eq:s15-3} \begin{pmatrix}T-Yv&-Cv\\Av&T+Yv\end{pmatrix} \end{equation} Its eigenvalue on the terminal eigenline is \(T+v\sqrt d>1\), so the terminal point is attracting. The change of basis acts by \(g^{-1}(\cdot)g\), as direct multiplication of the traceless part shows. Thus changing the integral basis preserves the oriented orbit in \(X=\mathrm{PSL}_2(\mathbb Z)\backslash T^1\mathbb H\). To obtain a positive Pell solution, approximate \(\sqrt d\) by rationals. For each integer \(Q\ge1\), distribute the fractional parts of \(j\sqrt d\), for \(0\le j\le Q\), among \(Q\) equal intervals. This gives \(1\le q\le Q\) and \(|p-q\sqrt d|\le1/Q\). Irrationality of \(\sqrt d\) makes the resulting \(q\) unbounded. The nonzero integers \(p^2-dq^2\) have absolute value at most \(2\sqrt d+1\). By the infinite pigeonhole principle choose two distinct positive elements \(p_i+q_i\sqrt d\) of the same norm \(m\) whose corresponding coordinates agree modulo \(|m|\). Dividing the larger by the smaller gives an element \(T+v\sqrt d>1\) of norm one. Multiplying by the conjugate of the denominator and dividing by \(m\) shows that its two coefficients are integers. The matrix above therefore gives a closed orbit of translation length \(2\log(T+v\sqrt d)\). Indeed, conjugation to the axis from zero to infinity gives a dilation in height by \((T+v\sqrt d)^2\). Count each orbit once with its least period. A least positive period exists because bounded translation length permits only finitely many integral traces. Each axis has a representative passing through \(|\operatorname{Re}z|\le1/2,\ |z|\ge1\). For a point on the axis, first maximize the imaginary part in its modular orbit by minimizing, over coprime \(c,e\), the quantity \(|cz+e|>0\). Then translate horizontally by an integer. If \(|z|<1\), inversion would increase the imaginary part once more. In this region \(y=\operatorname{Im}z\ge\sqrt3/2\). The radius gives \(|A|\le\sqrt d/y\), the semicircle equation gives \(|Y+A\operatorname{Re}z|\le\sqrt d\), and \(AC=Y^2-d\) bounds \(C\). Thus only finitely many oriented orbits occur for each discriminant. Write \(\ell_d\) for the sum of their least periods. Summing arclength along the orbits and dividing by \(\ell_d\) defines the probability measure \(\mu_d\), with each orbit weighted by its length. \subsection{An open set certified by integer inequalities} Set \(M=100000\) and take the two disjoint open intervals \begin{equation}\label{eq:s15-4} I_-=(-364576,-364575)/M,\qquad I_+=(164575,164576)/M. \end{equation} In \(T^1\mathbb H\) take the unit tangent vectors with initial endpoint in \(I_-\), terminal endpoint in \(I_+\) and current point at hyperbolic arclength less than \(1/10\) from the apex. Denote their image by \(U\subset X\). The endpoints and arclength along the axis are continuous local coordinates, since the center and radius are the half-sum and half-difference of the endpoints. The set is open. Its closure is compact because the endpoints are bounded and separated and the arclength is bounded. The form \((1,1,-6)\) has endpoints \(-1\pm\sqrt7\) in the prescribed intervals and its apex satisfies the arclength condition. Thus \(U\) is nonempty and has positive Liouville volume. \textbf{Theorem 17.} For each such \(d\), we have \(\mu_d(U)>0\) if and only if there is an integral form \((A,Y,C)\) with \(Y^2-AC=d\) and \(A>0\) such that the values of \(F(n,M)\) at \begin{equation}\label{eq:s15-5} n=-364576,-364575,164575,164576 \end{equation} have respective signs \(+,-,-,+\). Every such hit gives a bounded representation. \textbf{Proof.} The sign conditions put one root of the upward-opening quadratic in each interval. Its oriented axis runs from left to right, and the apex supplies a hit. Conversely, lift a hit in the quotient to a tangent vector in the open set upstairs. The lifted orbit differs by an integral change of basis, so its coefficients are integral. The order of the oriented endpoints ensures \(A>0\). Continuity of the flow gives a positive interval of arclength whenever an orbit meets the open set, proving the equivalence with positive mass. To verify the coordinate bounds, the sum and product of the roots are \(-2Y/A\) and \(C/A\). The rational endpoints imply \(|Y-A|\le A/1000,\ |C+6A|\le A/1000\). For the product estimate, for instance, the intervals have width \(10^{-5}\) and the roots have absolute values less than four and two. Apply Theorem 7 of Section 10 at scale \(A\). Lean obtains the same bounds by eliminating variables in four integral linear inequalities. The three bases in Theorem 7 cover all parities, so the full modular quotient suffices. \subsection{Cusp mass for the packet and escape for one orbit} Denote the image in the quotient of the standard cusp of height \(y>H>1\) by \(\mathcal C_H\). Its lifts are disjoint cusp neighborhoods. Within the standard component only integral translations identify points, since a matrix with lower-left entry \(c\ne0\) satisfies \(\operatorname{Im}(gz)=y/|cz+e|^2\le1/y\). Put \begin{equation}\label{eq:s15-6} \rho_d(A)=\#\{r\bmod A:r^2\equiv d\pmod A\}. \end{equation} For the full set of oriented orbits we have the exact formula \begin{equation}\label{eq:s15-7} \ell_d\,\mu_d(\mathcal C_H) =4\sum_{1\le A<\sqrt d/H}\rho_d(A)\, \operatorname{arcosh}\!\left(\frac{\sqrt d}{AH}\right). \end{equation} Indeed, each rightward arc in the standard cusp is determined by \(A>0\) and \(Y\bmod A\), with \(C=(Y^2-d)/A\). An integral translation changes \(Y\) by a multiple of \(A\). The radius is \(R=\sqrt d/A\). At hyperbolic arclength \(s\) from the apex the height is \(R/\cosh s\), as follows from the parametrization \((x_0+R\tanh s,R/\cosh s)\). Hence the arc has length \(2\operatorname{arcosh}(R/H)\). Negating the form pairs the leftward and rightward arcs. A lifted tangent vector, its orientation and the discriminant determine the form uniquely. Only integral translations identify arcs within the same cusp lift, and no nonzero translation fixes a semicircle. Thus the count uses each arc exactly once per least period. By squarefreeness the root count at an odd prime power is at most two, including primes dividing \(d\), by the local root calculation in Section 12.1. At two there is one root modulo two and none modulo four. Hence \(\rho_d(A)\le\tau(A)\), where \(\tau\) counts divisors. Put \(B=\sqrt d/H\ge1\). By \(\sum_{A\le x}\tau(A)\le x(1+\log x)\) and \(\operatorname{arcosh}(B/A)\le\log(2B/A)\), partial summation bounds the right side by \(O(B\log(2B))\). For the term \(\log(B/A)\), integrate \(\int_1^B(\sum_{A\le t}\tau(A))\,dt/t\). This bounds unnormalized arclength. Escape proportions for a fixed \(H\) and large \(d\) also involve the denominator \(\ell_d\). \textbf{Complete escape for a principal orbit.} Take \(d=k^2+2\) and let \(k\to\infty\) along the infinite squarefree subsequence constructed in Section 11. The period of the principal form \((1,0,-d)\) is at most \begin{equation}\label{eq:s15-8} 2\log(k^2+1+k\sqrt d)=4\log k+O(1). \end{equation} There is a cusp arc with \(A=1\). Changing basis by the columns \((k,1),(-1,0)\) gives another arc on the same orbit with \(A=-2\). Their horizontal velocities in the standard component have opposite signs, so no integral translation identifies them. For fixed \(H>1\) their total length in the cusp is \begin{equation}\label{eq:s15-9} 2\operatorname{arcosh}(\sqrt d/H) +2\operatorname{arcosh}(\sqrt d/(2H)) =4\log k+O_H(1). \end{equation} Consequently the normalized mass of this single orbit tends to one in every fixed cusp neighborhood. The measures on these individual closed orbits thus escape to the cusp. \subsection{The distribution statement required by this approach} For the fixed \(U\), the qualitative input would be that every sufficiently large remaining fundamental discriminant \(4d\) satisfies \(\mu_d(U)>0\). For a limiting-measure contradiction, it would suffice that every bad subsequence have a vague limit point of positive mass on \(U\). A nonnegative continuous function compactly supported in \(U\) with positive integral against that limit would contradict vanishing along the subsequence. Equidistribution of the packets towards Liouville probability measure would imply the desired conclusion. Along a subsequence the normalized mass may escape to the cusp, or a nonzero invariant limit may be supported outside \(U\). For example, the closed packet of discriminant eight gives a compactly supported invariant probability measure, yet \(d=2\) cannot satisfy the four sign tests. They force \(A\ge1,C\le-5A\) and hence \(Y^2-AC\ge5\). The cusp formula retains only radii and root counts, whereas \(U\) also restricts the centers. Estimates averaged over discriminants can allow a sparse exceptional subsequence. For the intersection problem one can eliminate the zero limit by changing the normalization. Set \(K_H=X\setminus\mathcal C_H\). For \(H>1\) this set is compact, since the standard region is truncated in height and the direction fiber is a circle. Each periodic orbit spends positive arclength in \(K_H\). Indeed, the intersection of any lifted axis with each lifted cusp component is connected, so successive arcs lie in different components. Move the first component to \(y>H\). All other components lie below \(1/H\) because a nontranslation satisfies \(\operatorname{Im}(gz)\le1/\operatorname{Im}(z)\). Every connecting curve satisfies \(ds\ge |dy|/y\). Thus at least \(2\log H\) of arclength between successive visits lies in \(K_H\). This includes the gap across a period, since a hyperbolic stabilizer of the axis cannot fix a rational cusp. An orbit avoiding the cusp stays entirely in \(K_H\). Take \(H=4\). The closure of \(U\) is contained in the interior of \(K_4\). Heights in the specified lift lie between \(2\) and \(3\), and those in other nontranslation lifts are below \(1/2\). Consequently \begin{equation}\label{eq:s15-10} \nu_d=\frac{\mu_d|_{K_4}}{\mu_d(K_4)} \end{equation} is a probability measure on a compact space, and \(\nu_d(U)>0\) is equivalent to \(\mu_d(U)>0\). Uniformly positive mass stays away from the truncation boundary. Each visit to \(\mathcal C_2\) spends at most \(2\operatorname{arcosh}2\) at heights between two and four. For apex height \(R\le4\) this follows from the arc formula, and for \(R>4\) the difference \(\operatorname{arcosh}(R/2)-\operatorname{arcosh}(R/4)\) decreases with \(R\). At least \(2\log 2\) is spent in \(K_2\) between visits. Summing over each period gives \begin{equation}\label{eq:s15-11} \nu_d(K_2)\ \ge\ \frac{\log 2}{\log 2+\operatorname{arcosh}2}>0 . \end{equation} Thus any weak limit of the locally normalized measures gives positive mass to \(K_2\) by the closed-set inequality for weak convergence. To deduce a hit in \(U\subset K_4\) one would also need to locate mass inside \(U\). \textbf{Formalization.} Lean checks the identity, exact bounds, divisor certificates and Pell recurrence of Section 14. In Section 15, fundamental\_\allowbreak{}form\_\allowbreak{}primitive, integral\_\allowbreak{}basis\_\allowbreak{}discriminant, axis\_\allowbreak{}signs\_\allowbreak{}to\_\allowbreak{}patch and statement\_\allowbreak{}of\_\allowbreak{}packet\_\allowbreak{}crossing verify primitivity, the integral change of basis, the four-point certificate and the conditional implication to Statement. The geodesic correspondence, arclength formula and escape estimates are proved above on paper. \section{From two continued-fraction digits to a bounded representation} \textbf{Theorem 18 (a wide interval for the roots).} Suppose the integral form \(F(X,Y)=AX^2+2BXY+CY^2\) satisfies \(B^2-AC=d\) and \(A>0\) and has roots \(l<0\) and \(3/20,C<0,F(3,2)<00\) be nonsquare. Write a reduced form as \begin{equation}\label{eq:s16-1} F(X,Y)=AX^2-2PXY-QY^2,\qquad A,Q>0,\quad P^2+AQ=d,\quad |A-Q|<2P . \end{equation} These conditions are equivalent to \(\alpha=(P-\sqrt d)/A\in(-1,0)\) and \(\beta=(P+\sqrt d)/A>1\), as one sees from \(F(-1,1)>0>F(1,1)\). Put \(h=\lfloor\beta\rfloor\). The next complete quotient is \(1/(\beta-h)\). Applying the same transformation to the other root keeps it in \((-1,0)\). The new form is \(-F(hX+Y,X)\) and the new triple is \begin{equation}\label{eq:s16-2} (A',P',Q')=(Q+2hP-h^2A,\ hA-P,\ A). \end{equation} The change of basis has determinant \(-1\). Negation preserves the discriminant, and both operations preserve primitivity. To recover the preceding roots uniquely, put \(g=\lfloor-1/\alpha\rfloor\) and take \(g+1/\alpha\) and \(g+1/\beta\). Since \(-1/\alpha>1\) is irrational, this gives the unique reduced predecessor. There are finitely many states because \(01\). Then \(\beta-a_0=(w+1)/(2w+1)\in(1/2,2/3)\). Translating both roots using \(F(X+(a_0-1)Y,Y)\) puts the right root in the interval of Theorem 18 and leaves the left root negative. Thus adjacent ones anywhere in a cycle suffice, including across the end of the cycle. Alternatively, sample at the first of the two ones. The reduced right root then satisfies \(3/2<\beta<2\), and conversely this inequality forces its first two digits to be ones. Equivalently, the following two integer inequalities hold simultaneously: \begin{equation}\label{eq:s16-4} 4A-4P-Q>0,\qquad 4Q+12P-9A>0 . \end{equation} The first says that the present form is positive at \((2,1)\). The second says that the next form is positive at the same point. Together they define the decidable existence condition \(\mathrm{TwoOnes}(d)\). \subsection{Arithmetic consequences of missing the window} \textbf{Theorem 19 (the parity criterion).} For nonsquare \(d\equiv2,3\pmod4\), a bounded representation exists if and only if some reduced state has both \(A,Q\) odd. \textbf{Proof.} If \(A,Q\) are odd, take \((x,y,z)=(P,(A+Q)/2,(A-Q)/2)\). The reduction inequality gives \(z^20\) gives \(z^20\). If the two factors were both even, we would have \(d\equiv P^2\pmod4\), which is impossible. Take \(A=u,Q=v\). From \((u+v)^2<4d\) subtract \(4uv\) to obtain \((u-v)^2<4P^2\), the required reduction inequality. More generally, if there is no bounded representation, \(A,Q\) have opposite parity at every reduced state. If \(A,Q\) were both even, then \(d=P^2+AQ\equiv P^2\pmod4\). Since \(Q'=A\), the leading coefficients alternate in parity around each cycle. Moreover, \(A'\equiv Q-hA\pmod2\) implies that an odd digit \(h\) occurs only where \(A\) is even. An odd period length or two odd digits in positions of opposite parity therefore suffices for a representation. These restrictions concern absence of a representation. A cycle missing only the word \(11\) can violate them. If every cycle misses the word, a different exact restriction holds. For every integer \(1\le P<\sqrt d\), the integer \(d-P^2\) has no positive divisor \(A\) in \begin{equation}\label{eq:divisor-window} \max\!\left(\sqrt d-P,\frac{\sqrt d+P}{2}\right) < A < \frac{2(\sqrt d+P)}3 . \end{equation} Conversely a hit in this divisor interval for some \(P\) gives \(Q=(d-P^2)/A\) and yields the word \(11\). Solve \(-1<\alpha<0\) and \(3/2<\beta<2\) for \(A\) to obtain this interval. Nonemptiness requires \(5P>\sqrt d\). Lean uses equivalent comparisons of integer squares to eliminate square roots. \subsection{Pointwise hits from three fixed split primes} \textbf{Theorem 20.} Fix three distinct odd primes \(p,r,q\). There exists a threshold \(D\) depending only on them such that every nonsquare positive integer \(d>D\) that is a nonzero quadratic residue at all three primes satisfies \(\mathrm{TwoOnes}(d)\). The integer \(d\) may have square factors. We first prove a scaled integer lemma. Let \(A=qt\) with \(t>0,\ q\nmid t\). Suppose there is a square root modulo \(t\) and two distinct roots modulo \(q\), denoted by \(\pm c\). If \begin{equation}\label{eq:split-scale} A<\sqrt dX\). It contains a term with \(t\le X<(U/V)t\). Put \(X=\sqrt d/q\). Irrationality gives \(tp\) by the binomial theorem. Thus for \(d>(B W^{BW})^2\) the word occurs whenever three suitable primes exist below or at \(B\). Another interval works independently of small split primes. Write \(k=\lfloor\sqrt d\rfloor\ge1\) and \(t=d-k^2>0\). The reduced state \((A,P,Q)=(t,k,1)\) exhibits the word precisely when \(4k+1<4t\) and \(9t<12k+4\), equivalently \begin{equation}\label{eq:s16-9} 1/2<\sqrt d-k<2/3 . \end{equation} Any reduced state with \(Q=1\) must satisfy \(P^2B\) with \(p^2\mid d\). Counting modulo \(Mp^2\) bounds the number to discard by \begin{equation}\label{eq:s16-11} (5K^2/M)\sum_{n>B}n^{-2}+(2K+1) \le 5K^2/(MB)+2K+1 . \end{equation} This is smaller than the preceding lower bound. Both ranges therefore contain difficult squarefree parameters that are nonresidues at every odd prime up to \(B\). The first range has a hit with \(Q=1\). In the second range the unique candidate with \(Q=1\) misses the word. \subsection{Enumeration of reduced cycles} For \(2\le d\le10000\) and each squarefree \(d\equiv2,3\pmod4\), take successively \(1\le P\le\lfloor\sqrt d\rfloor\), enumerate the positive divisors of \(d-P^2\) as \(A\) and retain \(|A-Q|<2P\). Section 15 implies primitivity. At each state compute \(h=(\lfloor\sqrt d\rfloor+P)\mathbin{\mathrm{div}} A\) and the next state. Verify that the map is a permutation and traverse every cycle, checking adjacent digits across its boundary as well. Each row assigns \(d\) to the first applicable column from the left. The second row restricts the count to the residue class missed by Theorem 1. For each \(d\) missing the word, independently enumerate \(0\le x\le y\le\lfloor\sqrt d\rfloor\) and test whether \(x^2+y^2-d\) is a nonnegative square. The answers agree individually with the parity criterion. \begin{center}\small \begin{tabularx}{\linewidth}{@{}>{\raggedright\arraybackslash}p{0.24\linewidth}>{\raggedright\arraybackslash}p{0.12\linewidth}>{\raggedright\arraybackslash}X>{\raggedright\arraybackslash}p{0.17\linewidth}>{\raggedright\arraybackslash}p{0.17\linewidth}@{}} \toprule Parameter range & Contains 11 & Odd cycle or odd digits in opposite parities & Other bounded representation & No bounded representation \\ \midrule All 4,057 parameters & 3855 & 102 & 27 & 73 \\ \(d-\lfloor\sqrt d\rfloor^2\equiv2\pmod4\) (2,021 parameters) & 1875 & 59 & 14 & 73 \\ \bottomrule \end{tabularx} \end{center} For \(d=70\) all cycles, up to rotation, are \((1,2,1,2,16,2)\) and \((2,5,8,5)\). Both miss the word, although \(70=5^2+7^2-2^2\). The integer \(6683=44^2+74^2-27^2\) also misses the word. Each of these exclusions has a separate finite Lean proof. The example \(9443=48^2+90^2-31^2\) misses the word but is detected by odd digits of opposite position parity. The finite range includes unrepresented values such as \(6563\). In Lean, \texttt{three\_\allowbreak{}split\_\allowbreak{}primes\_\allowbreak{}word} proves Theorem 20 with a threshold depending on the three primes. The density corollary, the common bound in terms of \(B\), and the interval count are deductions on paper. The script \texttt{cf\_\allowbreak{}scan.py} reproduces the table. \section{Pointwise hits from upper and lower bounds for reduced states} Assume \(d\equiv2,3\pmod4\) is squarefree and \(d>1\). Let \(R(d)\) count all reduced triples of Section 16, each distinct triple once. Normalize the integral coefficients by \(\sqrt d\), then cover the endpoint parameters with squares of side \(d^{-1/4}\). \subsection{Covering numbers for a forbidden word} Let \(K\subset(0,1)\) consist of the irrational regular continued fractions \([0;b_1,b_2,\ldots]\) without adjacent ones. There is an absolute \(1/20\) of its parent. Distinct words of equal length have disjoint interiors. The total length of the allowed words of length \(2m\) is therefore at most \((1-|I_{11}|/4)^m\). Choose an even \(L\) so that the allowed words of length \(L\) satisfy \(\sum D_w<1\). For any fixed \(s_0\in(1/2,1)\) we have \(D_w^{s_0}\le\prod_{b\in w} b^{-2s_0}\), summable at fixed word length. Dominated convergence gives \(s\in(s_0,1)\) with \(\sum_{|w|=L}D_w^s<1\) over allowed words. Split each prefix into blocks of length \(L\) and a shorter tail. Multiplying the derivative bounds and summing the geometric series over all numbers of blocks yields \(\sum_w l_w^s<\infty\) over allowed prefixes of all lengths. One may take \(s=255/256\) explicitly. A parent interval with denominators \(q,q'\) has length \(1/(q(q+q'))\). Appending two ones gives length \(1/((2q+q')(3q+2q'))\). Since \(0\le q'\le q\), the latter is at least the proportion \(1/8\) of the former. Thus the allowed words of length 64 satisfy \(\sum D_w\le4(7/8)^{32}<1/8\). Also \(\sum D_w^{3/4}\le(\sum_{n\ge1}n^{-3/2})^{64}\le3^{64}\) by the integral bound for the tail. Hölder interpolation with weights \(63/64,1/64\) gives \(\sum D_w^{255/256}\le(1/8)^{63/64}3<1\). Along each allowed infinite string take the last prefix with \(l_w\ge e\), permitting the empty prefix. Denominators grow at least at the Fibonacci rate, so the stopping position exists. If the next digit \(b\) satisfies \(l_{wb}0\) such that a packet missing the word satisfies \(R(d)\ll d^{1/2-\delta}\). For example, take \(\epsilon=(1-s)/4,\ \delta=(1-s)/8\). \subsection{A lower count from roots at arbitrarily large moduli} Write \(\rho(a)=\#\{b\bmod a:b^2\equiv d\pmod a\}\) and \(S(X)=\sum_{a\le X}\rho(a)\). For each fixed \(d\) we prove \begin{equation}\label{eq:root-limsup} \limsup_{X\to\infty}S(X)/X\ \ll\ R(d)\,\log(2d)/\sqrt d, \end{equation} with an absolute implied constant. The limit is taken at fixed \(d\). Associate to each \((a,b\bmod a)\) the form \(aX_1^2-2bX_1Y_1+((b^2-d)/a)Y_1^2\) together with its marked first column \((1,0)\). By the basis changes in Section 16.1, allowing an overall sign, we reach a reduced form \(F\) with a marked vector \((u,v)\) satisfying \(|F(u,v)|=a\). Further complete-quotient steps change the vector by the inverse basis transformation. Put \begin{equation}\label{eq:s17-7} T_F(u,v)=\log\left|\frac{u-\alpha v}{u-\beta v}\right|. \end{equation} Both roots are irrational and the marked vector is nonzero. If \((u,v)=(h u'+v',u')\), then \begin{equation}\label{eq:s17-8} T_F(u,v)=T_{F'}(u',v')+\lambda_F,qquad \lambda_F=\log((h-\alpha)/|h-\beta|)>0 . \end{equation} Since \((\beta-h)^{-1}=\beta'\le2\sqrt d\) we also have \(\lambda_F\le\log(6d)\). Accumulating these positive step lengths around the cycle in both directions gives unbounded sums of either sign. We can therefore choose a state with \(0\le T_F(u,v)\le\lambda_F\). Conversely, given \(F,u,v\) we recover \(a\), and the middle coefficient gives at most a constant number of values of \(b\bmod a\). For a fixed determinant sign, complements of the primitive column \((u,v)\) differ by integral multiples of it. Thus the half-middle coefficient changes by a multiple of \(F(u,v)\). Only the determinant and overall signs remain. For one reduced state count the lattice points satisfying \(0<|F(u,v)|\le X\) and \(0\le T_F(u,v)\le\log(6d)\). Put \(U=u-\alpha v,V=u-\beta v\), so \(F=AUV\) and the absolute Jacobian of the linear change is \(2\sqrt d/A\). In each quadrant the absolute Jacobian from \((|UV|,\log|U/V|)\) to \((U,V)\) is \(1/2\). Consequently the area in the original plane is \(X\log(6d)/\sqrt d\). For fixed \(d,F\) the region is the dilation of the bounded Jordan-measurable region for \(X=1\) by \(\sqrt X\). The ratio bounds imply boundedness, and the boundary consists of radial segments and hyperbolic arcs. Scaling the grid to mesh \(1/\sqrt X\) gives Riemann sums. The count divided by \(X\) tends to the unit-scale area. There are finitely many states for each \(d\), proving \eqref{eq:root-limsup}. Put \(q=4d\), and on integers not coprime to \(q\) set \(\chi_d=0\). Write \(d=2^e m\) with \(m\) odd and \(e=0,1\). On positive integers \(n\) coprime to the modulus define \begin{equation}\label{eq:s17-9} \chi_d(n)=(-1)^{e(n^2-1)/8+((m-1)/2)((n-1)/2)} \prod_{p\mid m}(n/p), \end{equation} Here \((n/p)\) takes the value one on nonzero squares and \(-1\) on the other units. The squares form a subgroup of index two, so these factors are multiplicative characters. The sign factors are also multiplicative, as one checks modulo eight. The resulting function has period \(q\). At an odd prime \(l\nmid d\) its value equals \((d/l)\). To see the reciprocity calculation, the absolute values of the least absolute residues of \(a,2a,\ldots,((l-1)/2)a\) modulo \(l\) permute \(1,\ldots,(l-1)/2\). Multiplication gives \((a/l)=(-1)^N\), where \(N\) counts negative signs. Euler's criterion follows from Fermat's little theorem because \(X^{(l-1)/2}-1\) already has all nonzero squares as roots. For \(a=2\), counting \(j>l/4\) gives \((2/l)=(-1)^{(l^2-1)/8}\). For positive odd \(a\), sum \(aj=l\lfloor aj/l\rfloor+(aj\bmod l)\) modulo two and replace residues greater than half the modulus by their least absolute values. This gives \(N\equiv\sum_{1\le j\le(l-1)/2}\lfloor aj/l\rfloor\pmod2\). Take \(a=p\) to be a different odd prime and interchange \(p,l\). The two floor sums count the lattice points on opposite sides of the diagonal in a rectangle containing \((p-1)(l-1)/4\) points. Multiplication over prime factors gives the formula. These characters are nonprincipal, and the product of two belonging to distinct \(d\) is nonprincipal. At every odd prime factor the local factor is a nonprincipal quadratic character whose sign can be changed independently by CRT. If their odd prime supports agree, squarefreeness forces the two distinct \(d\) to differ by a factor of two. Their quotient on units modulo eight is \((2/n)\), also nonprincipal. If the odd support is empty only \(d=2\) requires checking. In particular every nonprincipal character sums to zero on a period, by multiplication by a unit of value \(-1\). Comparing Euler factors in the half-plane of absolute convergence \(\Re z>1\) gives \begin{equation}\label{eq:s17-10} \sum_{a\ge1}\rho(a)a^{-z}=\frac{\zeta(z)L(z,\chi_d)}{\zeta(2z)},\qquad L(z,\chi)=\sum_{n\ge1}\chi(n)n^{-z}. \end{equation} Each positive power of a split prime has two roots, each positive power of an inert prime has none, and a ramified prime has one root only at the first power. These give the three local factors, with CRT for general moduli. For real \(z\downarrow1\) partial summation expresses the left side as \(z\int_1^\infty S(t)t^{-1-z}\,dt\). After multiplication by \(z-1\) the contribution of any fixed bounded initial interval tends to zero. By \eqref{eq:root-limsup} and the residue one of \(\zeta\) at one, we obtain \begin{equation}\label{eq:state-lower} R(d)\gg \frac{\sqrt d}{\log(2d)}L(1,\chi_d). \end{equation} \subsection{A pointwise lower bound for character values at one} To compare \eqref{eq:state-lower} with the power saving in Section 17.2, we prove that for every \(\eta>0\) there is a constant \(c_\eta>0\) such that every \(d\) in this family satisfies \(L(1,\chi_d)\ge c_\eta(4d)^{-\eta}\). For a nonprincipal character \(\chi\) of period \(q\) the absolute partial sums are bounded by \(q\). Consequently \begin{equation}\label{eq:s17-12} L(z,\chi)=z\int_1^\infty\Big(\sum_{n\le t}\chi(n)\Big)t^{-z-1}\,dt \end{equation} is holomorphic on \(\Re z>0\) and bounded on \(\Re z\ge1/2\) by \(O(q(1+|z|))\). Splitting the series at \(q\) likewise gives \(|L(1,\chi)|\le \log q+O(1)\). Substituting \(\lfloor t\rfloor=t-\{t\}\) for the partial sum gives \(\zeta(z)=z/(z-1)-z\int_1^\infty\{t\}t^{-z-1}\,dt\). In particular zeta is negative on \((0,1)\). Every real nonprincipal character satisfies \(L(1,\chi)>0\). Its Euler product is positive to the right of one on the real axis. If it vanished at one, then \(G(z)=\zeta(z)L(z,\chi)\) would be holomorphic throughout \(\Re z>0\). Its Dirichlet coefficients \(a_n\) are nonnegative and satisfy \(a_{j^2}\ge1\) by the Euler factors. Taylor-expand about two and evaluate at \(2-3/2\), within the disk of convergence. All terms \((3/2)^k\sum_n a_n n^{-2}(\log n)^k/k!\) are nonnegative. Interchanging summations gives \(\sum_n a_n n^{-1/2}<\infty\), contradicted by the harmonic subseries at squares. Take \(0<\theta<\min(1/4,\eta/32)\). If some character \(\chi_0\) of the family has a real zero in \((1-\theta,1)\), fix this character and one such zero \(\beta\). For each remaining \(\chi=\chi_d\) take \begin{equation}\label{eq:s17-13} F(z)=\zeta(z)L(z,\chi_0)L(z,\chi)L(z,\chi_0\chi). \end{equation} The product character is nonprincipal with period dividing \(q_0q\). Here \(F(\beta)=0\). If there is no such character, fix \(\beta=1-\theta/2\) and for all \(\chi\) take \(F(z)=\zeta(z)L(z,\chi)\). Positivity at one and the absence of real zeros give \(F(\beta)<0\). In either case the only possible pole of \(F\) on \(\Re z>0\) is simple at one. Denote its residue by \(H\). The coefficients satisfy \(a_n\ge0,a_1=1\). In the four-factor case the unramified local factors are \((1-t)^{-4}\) or \((1-t^2)^{-2}\). At a ramified prime, deleting factors with character value zero leaves \((1-t)^{-1}\), \((1-t)^{-2}\) or \((1-t^2)^{-1}\), where \(t=p^{-z}\). Take \(k=8\). For real \(X>2\) we have \begin{equation}\label{eq:s17-14} \sum_{n1\), closing to the left gives the binomial expansion from the residues at \(0,-1,\ldots,-k\). For \(X/n<1\), closing to the right gives zero. At \(X=n\) the same value follows by continuity. Move the original line to \(\Re w=1/2-\beta\), crossing only \(0,1-\beta\). The integral representations above bound \(|F|\ll_{\chi_0} q^2(1+|\Im w|)^4\) on the new line and at large imaginary part throughout the intervening strip. The denominator has degree nine, so the horizontal integrals vanish and the stated error follows. The same bound in the two-factor case needs no \(\chi_0\). Take \(X=q^{16}\). The error tends to zero since \(\beta>3/4\). The left side is at least \((1-1/X)^8\), while \(F(\beta)\le0\). Hence \(H\gg_{\chi_0,\beta}q^{-16(1-\beta)}\). In the four-factor case \(H=L(1,\chi)L(1,\chi_0)L(1,\chi_0\chi)\) and the last two factors have product \(O_{\chi_0}(\log(2q))\). In the two-factor case \(H=L(1,\chi)\). This gives the required \(q^{-\eta}\) lower bound. Positivity for the fixed \(\chi_0\) and the finitely many initial characters absorbs these into the constant. \subsection{Occurrence of adjacent ones} \textbf{Theorem 21.} Every sufficiently large squarefree \(d\equiv2,3\pmod4\) admits a reduced state whose continued-fraction period contains adjacent ones. Consequently there exists an integer \(N\) such that every \(n\ge N\) admits integers \(x,y,z\) with \(n=x^2+y^2-z^2\) and all three squares at most \(n\). Apply the bound of Section 17.4 with \(\eta=\delta/2\) in \eqref{eq:state-lower}. The ratio of the lower bound to the upper bound for missing the word in Section 17.2 is at least a constant times \(d^{\delta/2}/\log(2d)\), which tends to infinity. Thus every sufficiently large discriminant in this family has a hit, and Section 16 gives a bounded representation. Section 1 handles the other residue classes modulo four of squarefree integers. The fixed square-class theorem and squarefree reduction in Sections 8 and 9 give representations for every sufficiently large integer. With \(s=255/256\), Section 17.2 gives \(R(d)\ll d^{1/2-1/2048}\) when the word is absent. Absorbing the implied constant using \(1/2048>1/4096\), we find that all sufficiently large discriminants missing the word satisfy \(R(d)^{4096}\le d^{2047}\), while the strict reverse inequality holds for every sufficiently large remaining discriminant. Both thresholds are independent of \(d\). \textbf{Formal verification.} Lean defines \(R(d)\) as the length of a finite list without duplicates. Its membership theorem and, for \(A>0\), the uniqueness of \(Q=(d-P^2)/A\) show that it counts exactly the reduced states. For \(1\le A\le k=\lfloor\sqrt d\rfloor\) every congruence root \(b\) also has a unique center \(P=k-((k-b)\bmod A)\). The admissible centers are precisely the roots in \(k-Ak\), put \(Q=(d-P^2)/A\). Then \(0<|Q|0\) and \(u>hv\), the complete-quotient step replaces the vector by \((v,u-hv)\), decreasing its coordinate sum. Eventually \(v=0\) or \(0\le u\le hv\). All steps preserve \(|F(u,v)|=n\). For fixed form, vector and sign the root is unique. Two complements completing the first column to a basis of the same orientation differ by an integral multiple of it, so the half-middle coefficient is unique modulo \(n\). Changing signs allows at most one further root. On the axis there is only \((1,0)\). In every other row \(-F(u,v)\ge v^2\). Indeed, the concave quadratic in \(u\) given by \(-F\) is at least \(v^2\) at both endpoints \(0,hv\). When \(v^2\le4AT^2\), encode by the integer \(hv^2+u\). The bounds \(0\le u\le hv\) allow unique decoding, and \(Ah\le2k\). When \(v^2>4AT^2\), group by \(V=T2^j\le v<2V\) and record the sign of \(Au-Pv\). The identity \begin{equation}\label{eq:s18-2} (Au-Pv)^2=dv^2-An \end{equation} gives \(2|Au-Pv|\ge kv\). For fixed \(v\) and sign, distinct values of \(u\) give values of \(n\) spaced by at least \(kv\). Thus the integer \(v-V+V\lfloor n/(kV)\rfloor\) also decodes uniquely. Both codes lie in \([0,32kT^2)\), and \(v^2\le dT^2\) gives \(j\le\lfloor\log_2 k\rfloor\). Combining the two signs, separate codes for the axis and small rows, and the choice of reduced state gives the bound. Lean calls the remaining arithmetic lower bound \texttt{RootDensityLower}. For each integer \(m\ge1\) it requires a common threshold such that every squarefree \(d\equiv2,3\pmod4\) above it has some integer \(T\ge1\) satisfying \begin{equation}\label{eq:s18-3} (dT^2)^m\le d\,S(dT^2)^m . \end{equation} From this input \texttt{reduced\_\allowbreak{}lower\_\allowbreak{}of\_\allowbreak{}root\_\allowbreak{}density} proves \texttt{ReducedSizeLower}, including the absorption of the logarithm and the choice of threshold. \subsection{Exact coefficients at prime powers} Let \(\rho_d(n)\) count square roots of the discriminant parameter modulo \(n\). For our fundamental discriminants, if \(p=2\) or \(p\mid d\), put \(c_p=0\). At other primes, according as \(d\) is or is not a square in the units modulo \(p\), take \(c_p=1,-1\). Lean verifies for every prime and \(j\ge0\) that \begin{equation}\label{eq:s18-4} \rho_d(p^{j+1})=c_p^j(1+c_p),\qquad \rho_d(uv)=\rho_d(u)\rho_d(v)\quad ((u,v)=1,\ u,v>0). \end{equation} At an odd split prime, roots lift at every level. If \(x,y\) are roots, then \(p^{j+1}\mid(x-y)(x+y)\). The two factors cannot both be divisible by \(p\), so \(x\equiv y\) or \(-y\pmod{p^{j+1}}\). The two roots are distinct. For odd \(p\mid d\) the only root modulo \(p\) is zero, and a root modulo \(p^2\) would imply \(p^2\mid d\). At two there is one root modulo two and none modulo four. For coprime moduli Bézout's identity constructs a bijection between the root lists. The theorems \texttt{prime\_\allowbreak{}power\_\allowbreak{}root\_\allowbreak{}coefficient}, \texttt{localRoots\_\allowbreak{}multiplicative} and \texttt{rootTable\_\allowbreak{}length\_\allowbreak{}sum} verify the local formulas, multiplicativity and \(S(X)=\sum_{n\le X}\rho_d(n)\), respectively. \subsection{Reduced representatives in an integral conjugacy class} Let \(F,G\) be two reduced forms for the same \(d\) with mixed trace \(m\) and \(m^2\ne4d^2\). Write them as \(AX^2+BXY+CY^2\) and \(aX^2+bXY+cY^2\) and put \begin{equation}\label{eq:s18-5} r=Ab-aB,\quad s=Ac-aC,\quad t=Bc-bC. \end{equation} The resultant \(s^2-rt=m^2-4d^2\) is a nonzero integer. Eliminating the leading term gives \begin{equation}\label{eq:s18-6} (s^2-rt)y^3=(arx+(br-as)y)F(x,y)-(Arx+(Br-As)y)G(x,y). \end{equation} Interchanging \(x,y\) gives the other coordinate bound. If all coefficients and the two form values at the vector have absolute value at most \(K\), then \(H=\max(|x|,|y|)\) satisfies \(H^3\le12 K^4H\). The source uses the looser integer bound \(H\le12K^4\). For each column of an integral basis change one may take \(K=3k\) since both initial and final forms are reduced. Consider two candidate columns \((x,y),(X,Y)\) with positive denominators in the same dyadic interval and with \(Ax-Py,AX-PY\) of the same sign. The identity \begin{equation}\label{eq:s18-7} ((Ax-Py)Y)^2-d(yY)^2=A Y^2F(x,y) \end{equation} and \(|F|\le3k\) place the nonnegative quantities \(|Ax-Py|Y\) and \(|AX-PY|y\) at distance from \(\lfloor\sqrt{d(yY)^2}\rfloor\) at most \(8A\). Subtracting gives \(|xY-Xy|\le16\). Fix one column. The determinant with a second column takes at most 33 values. Columns with equal determinant differ by an integral multiple of the fixed primitive column. Their denominator difference is strictly smaller than its denominator, so they coincide. Including signs and the horizontal column yields at most \(134(1+\lfloor\log_2 H_0\rfloor)\) choices, where \(H_0=12(3k)^4\). Taking two columns gives \begin{equation}\label{eq:s18-8} \#\{\text{reduced ordered pairs in one integral conjugacy class}\} \le [134(1+\lfloor\log_2 H_0\rfloor)]^2. \end{equation} This proves \texttt{reduced\_\allowbreak{}orbit\_\allowbreak{}multiplicity} using only integers. The squared logarithm is \(o(d^\epsilon)\) for every \(\epsilon>0\). For the continued-fraction covering, \texttt{surviving\_\allowbreak{}mass\_\allowbreak{}bound} checks a two-digit recurrence on the finite alphabet \(1,\ldots,M\). With initial denominators \(q>0,\ 0\le r\le q\), the first digit \(i\) gives denominators \(iq+r,q\) and interval length \(1/((iq+r)(iq+r+q))\). The sum over \(i\) telescopes, and the subcylinder of two ones occupies at least \(1/8\) of the parent. In \(m\) disjoint pairs of positions exclude the word \(11\). The remaining total length is at most \((7/8)^m/(q(q+r))\), uniformly for all finite \(M\ge1\). \subsection{All integral conjugacy classes at fixed mixed trace} For \(D=|4d^2-m^2|>0\) put \(J_d(D)=\sum_{t\mid D}\rho_d(t)\), with \(t\) running over positive divisors. The Lean theorem \texttt{fixed\_\allowbreak{}trace\_\allowbreak{}count} bounds the number of all reduced ordered pairs of mixed trace exactly \(m\) by \begin{equation}\label{eq:s18-9} 2J_d(D)\,[134(1+\lfloor\log_2(12(3k)^4)\rfloor)]^2 . \end{equation} More precisely, it applies to any list of such pairs without repetitions. Fix a reduced pair \((M,N)\). By simultaneous rational conjugacy, for another pair \((M',N')\) of the same mixed trace choose a nonsingular integral matrix \(H\) with \(MH=HM', NH=HN'\). After dividing out the common factor of the four entries there are four integer weights such that the weighted sum of the entries of \(H\) is one. Write \(t=\det H\), retaining its sign. Each column of \(B=MH\) is an integer combination of the columns of \(H\), and each row is an integer combination of the rows of \(H\). Thus \begin{equation}\label{eq:s18-10} H_{ij} B_{kl}-B_{ij}H_{kl}\equiv0\pmod t. \end{equation} First replace the first term by \(H_{kj}B_{il}\). The difference is an integral combination of column determinants. A second replacement gives the second term, with difference an integral combination of row determinants. Sum over \(i,j\) with the indicated weights. This gives an integer \(z\) such that \(MH\equiv zH\pmod t\), and likewise \(NH\equiv wH\pmod t\). From \(M^2=dI\) we get \((d-z^2)H\equiv0\). Multiplying \((MN-NM)H\equiv0\) on the left by the adjugate of the commutator gives \(\det(MN-NM)H\equiv0\). Taking weighted sums again gives \(t\mid D\) and \(z^2\equiv d\pmod{|t|}\). Use as label the signed integer \(t\) and the canonical representative \(0\le z<|t|\). Each label gives at most one simultaneous integral conjugacy class. Write \(M=(P,Q;A,-P)\). The entries of \(M-zI\) are coprime. A common even divisor would make \(A,Q\) even, contrary to the impossibility of \(d\equiv P^2\pmod4\). For an odd common divisor \(s>1\) we get from \(s\mid2P\) that \(s\mid P\), forcing \(s^2\mid d\). Suppose \(H,K\) have the same label. Form \(V\) from one column of each. Then \((M-zI)V\equiv0\pmod t\). Multiply on the right by \(\operatorname{adj}(V)\). Coprimality of the entries of \(M-zI\) gives \(t\mid\det V\). Thus each entry of \(\operatorname{adj}(H)K\) is divisible by \(t\) and \(H^{-1}K\) is integral. It has determinant one and simultaneously intertwines the two target pairs. Apply Section 18.3 to each label. There are \(2J_d(D)\) labels, as claimed. Furthermore \(J_d(D)\) satisfies a uniform subpower bound for all relevant \(d\). For coprime \(u,v\) every divisor of \(uv\) has the form \(ab\) with \(a\mid u,b\mid v\). Summing \(\rho_d(ab)=\rho_d(a)\rho_d(b)\) gives \(J_d(uv)\le J_d(u)J_d(v)\). At prime powers \(J_d(p^a)\le 2(a+1)\). Fix \(e\ge1\) and choose \(C\ge1\) such that for every \(a\ge1\) we have \([2(a+1)]^e\le C2^a\). For \(p>4^e\) the inequality \(2(a+1)\le4^a\) bounds the left side directly by \(p^a\). Remove one whole prime power at a time. Each \(p\le4^e\) contributes the factor \(C\) at most once, giving \(J_d(D)^e\le B_eD\) with constant independent of \(d,D\). Combining this with the exact count and absorbing logarithms, Lean's \texttt{fixed\_trace\_subpower} gives the following. For each \(e\ge1\) there is one threshold beyond which, for all \(|m|\le3d,\ m^2\ne4d^2\), the \(e\)th power of the fixed-trace reduced-pair count is at most \(d\). Suppose the boxes together contain distinct reduced states and have diameter at most \(H\) in each coefficient, with \(H^2\le d\). Same-box traces lie in \([2d-2H^2,2d+H^2]\). Only diagonal pairs have trace \(2d\), and the previous theorem covers the other traces. Suppose the boxes contain all \(R(d)\) states, with \(B\) boxes. For each fixed \(e\ge1\) and every sufficiently large \(d\) the theorem \texttt{coefficient\_box\_second\_moment} gives an integer \(W\) with \(W^e\le d\) such that \begin{equation}\label{eq:s18-11} R(d)^2\le B\big(R(d)+(3H^2+1)W\big). \end{equation} This counts the ordered pairs directly, with Cauchy's inequality for the lower bound. The source also checks the exponent comparison. Suppose a packet missing the word has a cover with \(1\le H,\ H^4\le Cd,\ B^{2h}\le d^{h-1}\) for absolute constants \(h\ge2,C\). Taking \(q=8h\) gives, for sufficiently large such \(d\), the inequality \(R(d)^{2q}\le d^{q-1}\). This is \texttt{missed\_upper\_of\_coefficient\_cover}. \subsection{Rational endpoints and a grid cover uniform in the digits} Lean uses a finite cover. For a reduced state \(F=(A,P,Q)\) put \(x=A/(k+P),\ y=Q/(k+P)\). Both belong to \([0,1]\), and \(y\) is the first projection with \(A,Q\) interchanged. The reduction inequality is symmetric in \(A,Q\). Write the next state as \((A',P',Q')\) with digit \(a\). The identities \(AA'=d-P'^2,\ aA=P+P'\) give \begin{equation}\label{eq:s18-12} \left(x-\frac{1}{a+A'/(k+P')}\right)(k+P)\big(a(k+P')+A'\big)=d-k^2. \end{equation} The right side lies between zero and \(2k\), and the product of the two denominator factors on the left is at least \(k^2\). Thus the one-step error is at most \(2/k\). On \([0,1]\) the map \(u\mapsto1/(a+u)\) is 1-Lipschitz. For each \(m\) the first projection of every reduced state missing the word is therefore within \(4m/k\) of an allowed cylinder of length \(2m\). Applying the same result to the interchanged form treats the second projection. It suffices to group successive digits into disjoint pairs and exclude \((1,1)\) in each pair. The reverse estimate is also uniform. From \(AQ=d-P^2\) we have \begin{equation}\label{eq:s18-13} 0\le P+(k+P)xy-k=(d-k^2)/(k+P)\le2. \end{equation} Let \(u,v,P'\) be the corresponding data for a second state. If \(k|x-u|,k|y-v|\le E\), then \(k|xy-uv|\le2E\). Subtract the two remainder identities and use \(1+uv\ge1\) and \(P\le k\) to obtain \(|P-P'|\le4E+2\). Since \(A=(k+P)x,\ Q=(k+P)y\), all three coefficient differences are at most \(6E+2\). The two estimates are \texttt{missed\_\allowbreak{}cylinder\_\allowbreak{}approximation} and \texttt{coefficients\_\allowbreak{}close\_\allowbreak{}of\_\allowbreak{}projections}. Take arbitrary integers \(K,M\ge1\) and grid scale \(N=K^4\). Label a one-dimensional cell by \(\lfloor Nv\rfloor\). The theorem \texttt{surviving\_grid\_cover} supplies one list containing the labels for all allowed words of length \(2m\) on \(1,\ldots,M\) and all tails \(v\in[0,1]\). Its length is at most \begin{equation}\label{eq:grid-cover} 14K^4(7/8)^m+9\,7^{2m}K^3. \end{equation} Write the prefix map as \((p+u v)/(q+r v)\) with \(q\ge1,0\le r\le q,|pr-uq|=1\). If the terminal denominator satisfies \(q\le K^2\), all its values are within \(1/q^2\) of \(p/q\), using at most \(2N/q^2+5\) grid labels. Since \(q^2\le N\) and the cylinder length is \(1/(q(q+r))\), this count is at most \(14N\) times the cylinder length. Summing over allowed terminal states and using the contraction from Section 18.3 gives the first term. For the remaining words, stop when the denominator first exceeds \(K^2\). If the preceding denominator is \(q\le K^2\), then the next digit \(a\) satisfies \(aq+r>K^2\) and hence \(1/(a+v)\le2q/K^2\). All crossing subcylinders of this prefix lie within \(2/(K^2 q)\) of \(p/q\). Together they use at most \(4K^2/q+5\) grid labels. Give each digit \(i\) weight \(w_i=8^{\lfloor\log_4 i\rfloor}\). Then \(w_i^2\le i^3\) and \(\sum_{i=1}^M1/w_i\le6\), since a full block \([4^j,4^{j+1})\) contributes \(3/2^j\). The prefix weight product \(W\) satisfies \(W^2\le q^3\), so when \(q\le K^2\) we have \(W\le Kq\). Multiplying the label count by \(W\) gives at most \(9K^3\). Induct on the remaining length \(L\) and sum over children with weights \(1/w_i\). The number of possible crossing-prefix labels times \(W\) is at most \(9\cdot7^L K^3\). The empty prefix has weight one, so putting \(L=2m\) proves \eqref{eq:grid-cover}, uniformly in the alphabet cutoff and the last partial quotient. Set \(j=\lfloor\log_2 k/512\rfloor,\ n_0=2^j,\ K=n_0^{64},\ N=n_0^{256},\ m=8j\). Then \(N^2\le k<2^{512}N^2\). By \(2(7/8)^8\le1\) and \(7^{16j}\le n_0^{48}\) the right side of \eqref{eq:grid-cover} is at most \(23n_0^{255}\). Group states by one grid label for each projection. The difference in either projection for two members of a group, multiplied by \(k\), is at most \(8m+k/N\le(2^{512}+64)N\). We may therefore take \(H=6(2^{512}+64)N+2\) with \(H^4\le C d\), where \(C=(6(2^{512}+64)+2)^4\). The number of boxes satisfies \(B\le529n_0^{510}\). When \(n_0\ge529\), we have \(B^{1024}\le(n_0^{1024})^{511}\le d^{511}\). The theorem \texttt{missed\_\allowbreak{}coefficient\_\allowbreak{}cover} checks this construction, giving \texttt{missed\_\allowbreak{}size\_\allowbreak{}upper} unconditionally. The exponent comparison of Section 18.4 takes \(h=512, q=4096\) and yields, for sufficiently large discriminants missing the word, \(R(d)^{8192}\le d^{4095}\). The paper argument in Section 17.5 uses different constants. Both power savings suffice for Theorem 21. \subsection{Reduction to a congruence-root density} Keeping the explicit exponents, the only hypothesis of \texttt{statement\_\allowbreak{}of\_\allowbreak{}single\_\allowbreak{}density} is \texttt{RootDensityAt 16384}. In real inequalities it asks for one threshold such that every squarefree \(d\equiv2,3\pmod4\) above it has an integer \(T\ge1\) with \begin{equation}\label{eq:s18-15} \frac{S_d(dT^2)}{dT^2}\ \ge\ d^{-1/16384}. \end{equation} The definition uses the equivalent integer-power inequality. One may also start at an arbitrary scale. If \(X\ge d>0\), take \(T=1+\lfloor\sqrt{\lfloor X/d\rfloor}\rfloor\). Then \(X\le dT^2\le4X\). Thus it suffices for each large \(d\) to find some \(X\ge d\) satisfying \(X^{32768}\le d S_d(X)^{32768}\). Monotonicity of the root table and \(4^{32768}\le d\) imply the preceding fixed-exponent inequality. These steps are \texttt{round\_\allowbreak{}root\_\allowbreak{}density\_\allowbreak{}scale} and \texttt{statement\_\allowbreak{}of\_\allowbreak{}arbitrary\_\allowbreak{}scale\_\allowbreak{}density}. The sufficient exponents at square and arbitrary scales are 16384 and 32768, respectively. The scale \(X\) may depend on \(d\). The threshold for \(d\) must be common to the family. \section{Periodic characters, square factors and the fixed-discriminant mean} To prove the density condition in Section 18.6, define \(\chi_d(n)=0\) when \(n\) is even, and otherwise take the Jacobi symbol \((d/n)\). Quadratic reciprocity gives period \(4d\). At an odd prime use the quadratic-residue characterization of the Legendre symbol, and at two use the definition. Thus \(\chi_d(p)\) equals the local sign of Section 18.2. For \(d\equiv3\pmod4\) take \(n=2d-1\), so \(n\equiv1\pmod4\) and \((d/n)=(n/d)=(-1/d)=-1\). For \(d=2m\equiv2\pmod4\) take \(n=4m+1\equiv5\pmod8\), giving \((2/n)=-1,(m/n)=(n/m)=1\). This negative value occurs on a unit modulo \(4d\). Multiplication by it permutes a complete period, forcing the period sum to vanish. Hence partial sums from one to any upper endpoint have absolute value at most \(4d\). Put \(D_2 f(k^2)=f(k)\) and on positive nonsquares set \(D_2 f=0\). Let \(*\) denote Dirichlet convolution and let \(\mathbf1\) be the constant one function on positive integers. For every positive modulus Lean verifies \begin{equation}\label{eq:s19-1} \rho_d=\mu^2*\chi_d=(D_2\mu)*\mathbf1*\chi_d,\qquad (D_2\mathbf1)*\rho_d=\mathbf1*\chi_d . \end{equation} Here \(\mu^2\) denotes the pointwise square. At \(p^{j+1}\) the right side of the first identity, \(\mu^2*\chi_d\), has two potentially nonzero summands. Their sum is \(\chi_d(p)^j(1+\chi_d(p))\), exactly the verified root count. Coprime multiplicativity extends the equality to every positive modulus. If \(n=v^2u\) with \(u\) squarefree, the prime exponents give \(k^2\mid n\iff k\mid v\). Hence the square-supported Möbius weights sum to \(\sum_{k\mid v}\mu(k)=[v=1]\). Uniqueness of the squarefree part likewise gives \((D_2\mathbf1)*\mu^2=\mathbf1\). Put \(A_d(X)=\sum_{k=1}^{\lfloor\sqrt X\rfloor}S_d(\lfloor X/k^2\rfloor)\). Rearranging the convolution over the hyperbola \(ab\le X\) gives \(A_d(X)=\sum_{b\le X}\chi_d(b)\lfloor X/b\rfloor\). Write \(H_d(V)=\sum_{b\le V}\chi_d(b)/b\). For \(1\le V\le X\) we have \begin{equation}\label{eq:s19-2} \left|A_d(X)/X-H_d(V)\right|\le V/X+8d/(V+1). \end{equation} Each of the first \(V\) terms has rounding error at most one. In the tail, first fix \(a\). The inner character sum ranges over \(V0\) such that \(L_d d^{1/65536}\ge c\). Take \(b=\lceil 2d^{1/65536}/c\rceil\). Then \(bL_d\ge2\) and \(b^{65536}\le C d\) with \(C=\lceil 2/c+1\rceil^{65536}\). When \(4^{65536}C\le d\) we have \((4b)^{32768}\le d\), giving the arbitrary-scale inequality of Section 18.6. Lean verifies the limits, integer rounding and common threshold in this deduction. In the exceptional-character branch of Section 17.4, after fixing \(e>0\) we need only consider \(d>2e\). The squarefree integer \(d\) has an odd prime factor \(p\nmid 2e\), since otherwise \(d\mid2e\). Write \(de=2^jpm\) with \(m\) odd and \(p\nmid m\). By CRT choose \(n\equiv1\pmod{8m}\) with \(n\bmod p\) a nonzero quadratic nonresidue. Reciprocity gives \(\chi_d(n)\chi_e(n)=-1\). Thus the absolute partial sums of the product character are bounded by \(4de\). For the four-factor convolution \(\mathbf1*\chi_d*\chi_e*\chi_{de}\), suppose a prime has one character value equal to \(-1\). The four local values can then be paired into opposites. For a pair \((-b,b)\) the convolution coefficient of degree \(j\) is \(b^j\sum_{i=0}^j(-1)^i\). For odd \(j\) it vanishes, and for even \(j\) it is nonnegative. If both character values are nonnegative, every term is nonnegative. Multiplicativity gives nonnegative coefficients at every integer. \section{A disk estimate uniform in the discriminant} Put \(\varepsilon=1/131072\) and let \(d\) range over positive squarefree integers congruent to two or three modulo four. We prove the existence, independently of \(d\), of constants \(c>0,D\) such that \begin{equation}\label{eq:s20-1} d\ge D\quad\Longrightarrow\quad L_d\,d^{2\varepsilon}\ge c. \end{equation} This gives the exponent needed in Section 19. The argument uses a disk centered at two with radius \(3/2\) and one fixed real point near one. \subsection{Identifying the ordered limit with an analytic value} Write \(B_\chi(x)=\sum_{n\le x}\chi(n)\). For a nonprincipal real character of period \(q\) we have \(|B_\chi(x)|\le\min(x,q)\). Partial summation gives \begin{equation}\label{eq:s20-2} L_\chi(s)=s\int_1^\infty B_\chi(x)x^{-s-1}\,dx . \end{equation} The integral converges uniformly on compact subsets of \(\Re s>0\), defines a holomorphic function there, and agrees with the Dirichlet series on \(\Re s>1\). At \(s=1\) the boundary term in partial summation is \(B_\chi(X)/X\to0\), so \(L_{\chi_d}(1)=L_d\). The formal proof verifies the identity by an equivalent residue comparison. Put \(A(X)=\sum_{n\le X}(\mathbf1*\chi)(n)\). Section 19 gives \(A(X)/X\to L_d\). For \(s>1\) multiply \(s\int_1^\infty A(x)x^{-s-1}dx=\zeta(s)L_\chi(s)\) by \(s-1\). Write \(A(x)=x(L_d+o(1))\), discard a bounded initial interval, and bound the remaining integral by the supremum of the tail error. The left side tends to \(L_d\). The right side tends to \(L_\chi(1)\) since \(\zeta\) has residue one at one. This also applies to the nonprincipal product character below. On the positive real axis the integral is real. On \(\Re s\ge1/2,\ |s|\le4\) it gives \(|L_\chi(s)|\le 8q\). Furthermore, using \(\min(x,q)\le q^\varepsilon x^{1-\varepsilon}\) at \(s=1\) gives \begin{equation}\label{eq:s20-3} |L_\chi(1)|\le q^\varepsilon\int_1^\infty x^{-1-\varepsilon}dx =q^\varepsilon/\varepsilon . \end{equation} The nonnegative coefficients and the square subseries in Section 17.4 imply \(L_d>0\). Lean uses mathlib's nonvanishing theorem at one for general nonprincipal Dirichlet characters and the nonnegative-mean limit of Section 19 to establish the sign. \subsection{Estimating the residue using nonnegative Taylor coefficients} Let \(F(s)=\sum a_n n^{-s}\) converge absolutely for \(\Re s>1\) with \(a_n\ge0,\ a_1=1\). Suppose \(P(s)=(s-1)F(s)\) extends holomorphically to a neighborhood of the closed disk above, with \(P(1)=H\in\mathbb R\). Assume \(|P|\le M\) both on the boundary circle and at one. The function \begin{equation}\label{eq:s20-4} G(s)=\frac{P(s)-P(1)}{s-1},\qquad G(1)=P'(1) \end{equation} is holomorphic in that neighborhood. The boundary circle has minimum distance \(1/2\) from one, so \(|G|\le4M\) on the circle. Put \(b_j=\Re((-1)^jG^{(j)}(2)/j!)\). Cauchy's estimate gives \(|b_j|\le4M/(3/2)^j\). Near two we have \(F=G+H/(s-1)\), so \begin{equation}\label{eq:s20-5} b_j+H=\frac{1}{j!}\sum_{n\ge1}a_n n^{-2}(\log n)^j\ge0, \qquad b_0+H\ge1 . \end{equation} Absolute convergence on smaller half-planes within \(\Re s>1\) justifies termwise differentiation. If \(10\), which also proves positivity of the residue. Suppose \(M=Cd^2\) with fixed \(C>0\) and take \(j=\lfloor\log_2d\rfloor,\ u=2^j,\ K=32j\). We have \(u\le d<2u\) and \((3/4)^{32}\le1/8\), so \(16M(3/4)^K\le64C/u\). For \(d\ge\max(2,\lceil256C\rceil)\) this is at most \(1/2\). If also \(t^{32\cdot131072}\le2\), then \((t^K)^{131072}\le u\le d\). The following estimate therefore applies to both character branches: \begin{equation}\label{eq:residue-bound} H\,d^\varepsilon\ \ge\ (t-1)/2 . \end{equation} \subsection{Fixing a possible exception before varying the discriminant} Define \(Z(s)=(s-1)\zeta(s)\) to have value one at one. By the integral representation in Section 17.4, \(Z\) is holomorphic on a neighborhood of the closed disk, so one constant \(Z_0\ge1\) bounds it on the boundary and at one. Since \(Z(1)=1\), continuity gives a fixed \(10\). If no character in this family has a real zero in \(2-T\le s<1\), fix \(t=T\). By \(L_d>0\), real-valuedness and the intermediate value theorem, \(L_{\chi_d}(2-T)>0\). Take \(P=ZL_{\chi_d}\), giving \(\Re P(2-T)\ge0\). The identity \(\mathbf1*\chi_d=(D_2\mathbf1)*\rho_d\) of Section 19 shows that \(F\) has nonnegative coefficients and first coefficient one. By Section 20.1 it suffices to take \(M=32Z_0d^2\). In \eqref{eq:residue-bound}, \(H=L_d\), so every sufficiently large \(d\) satisfies \(L_d d^{2\varepsilon}\ge(T-1)/2\). If there is a zero, fix one parameter \(e\) and one \(12e\). By Section 19, \(\chi_{de}=\chi_d\chi_e\) is nonprincipal and real with period dividing \(4de\), even when \(de\) has square factors. Put \begin{equation}\label{eq:s20-9} P=ZL_{\chi_d}L_{\chi_e}L_{\chi_{de}} . \end{equation} The four-factor Dirichlet convolution is nonnegative by Section 19, and \(P(2-t)=0\). The three character functions have absolute values at most \(32d,32e,32de\), respectively, on the boundary and at one. Thus in \eqref{eq:residue-bound} we may take \(M=Cd^2,\ C=32^3Z_0e^2\), obtaining \begin{equation}\label{eq:s20-10} (t-1)/2\le L_d L_e L_{\chi_{de}}(1)d^\varepsilon. \end{equation} On the other hand \(|L_{\chi_{de}}(1)|\le B d^\varepsilon\), where \(B=(4e)^\varepsilon/\varepsilon\). Consequently \begin{equation}\label{eq:s20-11} L_d d^{2\varepsilon}\ge \frac{t-1}{2L_eB}>0 . \end{equation} Here \(e,t,L_e,B,C\) are all fixed before the universal quantifier on \(d\). Raising the threshold to the maximum of \(2e+1\) and the threshold of \eqref{eq:residue-bound} gives one constant and one threshold for the family. \subsection{Bounded representations for all sufficiently large integers} Since \(2\varepsilon=1/65536\), substituting these \(c,D\) in Section 19 gives, for every sufficiently large relevant \(d\), some \(X\ge d\) with \(X^{32768}\le d\,S_d(X)^{32768}\). In the source this is the theorem \textbf{arbitrary\_\allowbreak{}scale\_\allowbreak{}density}. Section 18.6 rounds the scale up to \(dT^2\). Section 18.1 gives a lower bound for the number of reduced states incompatible with the missed-word upper bound in Section 18.5. Section 16 constructs an integral representation from the hit, and Sections 8 and 9 cover square multiples and the finitely many small squarefree kernels. This proves \begin{equation}\label{eq:s20-12} \exists N\in\mathbb Z\quad \forall n\in\mathbb Z,\quad n\ge N \ \Longrightarrow\ \exists x,y,z\in\mathbb Z,\quad n=x^2+y^2-z^2,\qquad \max\{x^2,y^2,z^2\}\le n . \end{equation} The Lean theorem \texttt{Erdos1148.erdos1148} has this type after unfolding \texttt{Statement} and \texttt{Represented}. \reinacknowledgments{The author used GPT-6.2 Astra to explore proof strategies, develop the Lean formalization, and prepare the manuscript.} \section*{References} \noindent\textbf{[Ch]} P. Chojecki, Bounded Representations by $x^2+y^2-z^2$ (March 16, 2026). \href{https://www.ulam.ai/research/erdos1148-full.pdf}{Source.} \noindent\textbf{[ELMV]} M. Einsiedler, E. Lindenstrauss, P. Michel and A. Venkatesh, The distribution of closed geodesics on the modular surface, and Duke’s theorem, Enseign. Math. 58 (2012), 249–313. \href{https://doi.org/10.4171/LEM/58-3-2}{Source.} \noindent\textbf{[Lean]} B. Alexeev, lean-proofs, unconditional Lean formalization of Erdős Problem 1148, commit 1268917. \href{https://github.com/plby/lean-proofs/blob/1268917deaaaa0d674f651287027baa26cea9920/src/latest/ErdosProblems/Erdos1148.lean\#L238}{Source.} \end{document}