5 A full quantitative counting argument from Hales–Jewett
The quantitative colouring input to Section 5 can be proved from the Hales–Jewett theorem already in mathlib. This chapter gives the single-equation argument, including the finite Deuber construction used to obtain the right number of independent parameters. The starting point is the proof strategy of Frankl, Graham and Rödl, Quantitative Theorems for Regular Systems of Equations, Journal of Combinatorial Theory A 47 (1988), 246–261, Theorem 1. Their Deuber variant is attributed to an unpublished manuscript. We instead expand the Hales–Jewett row-focusing argument attributed to Leeb and Prömel, as presented by Joel Moreira in his 2014 exposition A proof of Deuber’s theorem using Hales–Jewett’s theorem. Keeping track of finitely many disjoint-support embeddings replaces the original residue encoding. A separated generator box makes positivity and containment in \([N]\) explicit.
The only Ramsey theorem invoked without a new proof here is the existing mathlib theorem Combinatorics.Line.exists_mono_in_high_dimension. It states that every colouring of words over a fixed finite alphabet, in a sufficiently high finite dimension, has a monochromatic combinatorial line. A line has a nonempty set of variable positions, all of which are replaced by the same letter; the remaining positions have fixed letters. Reindexing its finite coordinate type by \(\{ 0,\ldots ,h-1\} \) gives the numerical form used below. Taking any constant colouring shows that the resulting \(h\) is positive, because a line has a variable position. The finite pattern definitions, block-embedding algebra, focused-row construction, full containment recursion, integral kernel parametrization, and multiplicity bound are checked in Lean. Their quantitative counting and bounded-weight consequences are checked as well.
5.1 Finite patterns and their embeddings
For integers \(m\geq 0\), \(p,c\geq 1\) and \(z=(z_0,\ldots ,z_m)\in \mathbb Z^{m+1}\), write \(F_p=\{ -p,\ldots ,p\} \) and put
In particular \(L(0,p,c;z)=\{ cz_0\} \) is a singleton. We will only colour numerical patterns contained in the positive integers. This condition implies \(z_j{\gt}0\) for every \(j\), because \(cz_j\) belongs to the pattern and \(c{\gt}0\). A colouring is \(k\)-regular, for \(0\leq k\leq m\), if each row with \(m-k{\lt}j\leq m\) is monochromatic. The colours of different rows may differ. Every colouring is \(0\)-regular; an \(m\)-regular colouring has all its rows monochromatic, since row zero is a singleton.
An integer matrix \(T\) with \(q\) rows and \(M\) columns is a block embedding if each row has a nonempty support and the supports of distinct rows are disjoint. For a seed vector \(Y\in \mathbb Z^M\), its new generators are \(y=TY\). A finite family of such matrices can depend on the pattern parameters and the number of colours, but is chosen before the seed values and their colouring.
If \(T\) and \(U\) are block embeddings and their matrix product is defined, then \(TU\) is a block embedding. Selecting distinct rows of a block embedding also gives a block embedding.
For a fixed source coordinate \(b\), at most one row \(a\) of \(U\) has \(U_{ab}\ne 0\), because its row supports are disjoint. Thus \((TU)_{ib}=\sum _aT_{ia}U_{ab}\) has at most one nonzero summand. It is nonzero exactly when \(b\) belongs to the support of some row \(a\) of \(U\) for which \(T_{ia}\ne 0\); there can be no cancellation. Consequently the support of row \(i\) of \(TU\) is the union of those row supports of \(U\) selected by the support of row \(i\) of \(T\). This union is nonempty, since both matrices have nonempty row supports. For different \(i\) these unions use disjoint sets of rows of \(U\), and are therefore disjoint. Row selection preserves the property directly.
Let \(\delta \) and \(\beta \) be finite index sets, let \(p,r\geq 1\), and let \(c\in \mathbb Z\setminus \{ 0\} \). There are \(h\geq 1\) and a finite family of block matrices whose target coordinates are the early indices \(\delta \), one middle index \(*\), and late indices \(\beta \), and whose source coordinates are \((\{ 0,\ldots ,h-1\} \times \delta )\), \(*\), and \(\beta \), such that the following holds. For every integer source vector \(S\) and every \(r\)-colouring of \(\mathbb Z\), some matrix \(T\) in the family makes
monochromatic.
Use the checked positive numerical version of Hales–Jewett for alphabet \(F_p^\delta \). For each variable word, assign its variable source coordinates to their corresponding early target indices, its fixed source coordinates to the middle index, and its extra coordinates to the corresponding middle or late target indices. The coefficients are \(c\) for variable and extra coordinates and the fixed letters for fixed coordinates. Each source coordinate feeds at most one target, so supports are disjoint. Every early target has a source coordinate because the variable set is nonempty; each middle or late target has its own extra coordinate with coefficient \(c\ne 0\). Thus the matrix is a block embedding. There are finitely many variable words, giving a fixed finite family. The focused-row expression is exactly the evaluation of the corresponding combinatorial line, as proved by Sidon.Deuber.focusedRow_eq_wordEvaluation. Its monochromaticity is therefore the Hales–Jewett conclusion. The next lemma additionally proves all row containments needed to iterate this construction; those containments are not asserted by the present checked lemma.
Fix \(m\geq 1\), \(p,c,r\geq 1\) and \(0\leq k{\lt}m\). There are integers \(M\geq m\), \(P,C\geq 1\) and a finite family of block embeddings from \(M+1\) generators to \(m+1\) generators with the following property. If \(D(M,P,C;S)\) is positive and its \(r\)-colouring is \(k\)-regular, some matrix in this family produces generators \(s\) for which \(D(m,p,c;s)\) is a subset of \(D(M,P,C;S)\) and is \((k+1)\)-regular.
Put \(d=m-k\geq 1\). Apply Hales–Jewett to the alphabet \(F_p^d\) and \(r\) colours and choose a positive word length \(h\) with its conclusion. Set
Since \(h\geq 1\), \(M\geq d+k=m\). For a word \(a=(a_0,\ldots ,a_{h-1})\), with each \(a_i=(a_{i,0},\ldots ,a_{i,d-1})\in F_p^d\), define its colour to be the colour of
This integer lies in row \(b\) of the source pattern, since its earlier coefficients have absolute value at most \(cp\leq P\) and its leading coefficient is \(C\). The induced word colouring is therefore well-defined.
Choose a monochromatic line. Let \(A\subset \{ 0,\ldots ,h-1\} \) be its nonempty set of variable positions and let \(B\) be the complement. For \(i\in B\) write \(w_i\in F_p^d\) for its fixed letter. Define the new generators by
These are integer linear combinations of the source generators. For each early row \(t{\lt}d\), its support is \(\{ id+t:i\in A\} \) and is nonempty. These early supports are mutually disjoint. The middle generator uses only the complementary \(B\)-blocks and the new coordinate \(b\), where its coefficient is \(c\ne 0\). The last \(k\) generators use respectively the single coordinates \(b+1,\ldots ,b+k\). All these supports are disjoint. Thus (2) defines a block embedding. There are only finitely many choices of the nonempty set \(A\) and fixed letters \(w_i\), so all resulting embeddings form a fixed finite family.
We verify every row inclusion, not only the row made monochromatic. For \(d{\lt}j\leq m\), a point of row \(j\) of the new pattern has leading term \(cs_j=c^2S_{b+j-d}\). Every generator \(s_t\) with \(t{\lt}j\) uses source indices strictly below \(b+j-d\). Because the generator supports are disjoint, their coefficients do not add at any coordinate; each earlier coefficient has modulus at most \(p\max (p,c)\leq P\). Hence
These are the last \(k\) rows of the source pattern, so they are monochromatic by its \(k\)-regularity.
For row \(j=d\), expand using (2): its points are
These are exactly the integers (1) associated with the chosen combinatorial line. They are monochromatic and lie in source row \(b\).
Finally let \(0\leq j{\lt}d\), and let \(a=\max A\), which exists because \(A\) is finite and nonempty. A point of new row \(j\) is
Its largest source index is \(ad+j\), with coefficient \(c^2=C\). All other nonzero coefficients have earlier indices and modulus at most \(\max (cp,c^2)\leq P\). It therefore belongs to source row \(ad+j\). This proves containment for every remaining row. Every new row is consequently positive, as it is contained in the positive source pattern; in particular the new generators are positive. The last \(k\) new rows are monochromatic by (3), and the next row \(d\) is monochromatic by Hales–Jewett. The new colouring is \((k+1)\)-regular.
For every number of generators \(q\geq 1\) and integers \(p,c,r\geq 1\), there are \(M\geq q\), \(P,C\geq 1\), and a finite nonempty family \(\mathcal F\) of \(q\)-by-\(M\) block embeddings such that every \(r\)-colouring of a positive pattern \(D(M-1,P,C;Y)\) contains a monochromatic pattern
for some \(T\in \mathcal F\).
If \(q=1\), take \(M=1\), \(P=p\), \(C=c\), and the identity embedding. The target is its single row \(\{ cY_0\} \), which is monochromatic. Assume \(q\geq 2\) and set \(n=r(q-1)\geq 1\). Start with \((m_0,p_0,c_0)=(n,p,c)\). For \(j=1,\ldots ,n\), apply Lemma 69 with target parameters \((m_{j-1},p_{j-1},c_{j-1})\) and \(k=n-j\), and let its source parameters be \((m_j,p_j,c_j)\). This recursion is legitimate: \(m_j\geq m_{j-1}\geq n\) and \(0\leq n-j{\lt}n\leq m_{j-1}\). All parameters and finite embedding families have now been chosen solely from \(q,p,c,r\).
Take a colouring of a positive \(D(m_n,p_n,c_n;Y)\). It is \(0\)-regular. Use the step with \(j=n\) to obtain a \(1\)-regular \((m_{n-1},p_{n-1},c_{n-1})\) pattern inside it. Use the step with \(j=n-1\) to obtain a \(2\)-regular pattern inside that one. Continuing for all \(n\) steps produces an \(n\)-regular \(D(n,p,c;z)\) in the original source pattern. Every one of its \(n+1\) rows is monochromatic, including the singleton row zero. Since \(n+1=r(q-1)+1\), the pigeonhole principle supplies \(q\) distinct rows of the same colour, with indices \(0\leq j_0{\lt}\cdots {\lt}j_{q-1}\leq n\). Put \(y_i=z_{j_i}\). For each target row \(i\), a combination \(cy_i+\sum _{t{\lt}i}\lambda _t y_t\) belongs to source row \(j_i\): set the coefficients of every unselected earlier generator to zero. Thus \(D(q-1,p,c;y)\) is monochromatic and lies in \(D(n,p,c;z)\).
Every generator change was a matrix from a fixed finite family of block embeddings. Composition and the final row selection preserve that property by Lemma 67. There are finitely many compositions and finitely many row selections. Let \(\mathcal F\) be their set of resulting matrices, and put \(M=m_n+1\), \(P=p_n\), \(C=c_n\). This family is nonempty, since each Hales–Jewett step has at least one possible line and the indicated row selections exist for the constructed colourings. Each matrix in it has \(q\) nonempty disjoint row supports, so choosing one coordinate in each support injects \(q\) rows into \(M\) columns; hence \(M\geq q\). The preceding construction proves the claimed extraction for every seed and every colouring.
5.2 A full-dimensional first-entry kernel parametrization
Let \(a_1,\ldots ,a_s\in \mathbb Z\setminus \{ 0\} \), and suppose \(\sum _{i\in I}a_i=0\) for some nonempty \(I\subset \{ 1,\ldots ,s\} \). Then \(s\geq 2\), and for \(q=s-1\) there are \(p,c\geq 1\) and an integer matrix \(B\) with \(s\) rows and \(q\) columns such that:
\(a^{\mathsf T}B=0\);
the map \(B:\mathbb Z^q\to \mathbb Z^s\) is injective;
each row of \(B\) has last nonzero entry \(c\), and every earlier entry has absolute value at most \(p\).
Consequently each coordinate of \(By\) belongs to \(D(q-1,p,c;y)\).
A singleton \(I\) cannot have zero sum because every \(a_i\) is nonzero. Choose a pivot \(i_0\in I\) and a second index \(j_0\in I\setminus \{ i_0\} \). Put \(c=|a_{i_0}|{\gt}0\), \(\sigma =\operatorname {sign}(a_{i_0})\), and \(J=\{ 1,\ldots ,s\} \setminus \{ i_0\} \). Thus \(|J|=q=s-1\) and \(a_{i_0}\sigma =c\). For \(j\in J\) define the integer column
Its weighted coordinate sum is \(c a_j-a_{i_0}\sigma a_j=0\). Let \(u_0=c1_I\); its weighted sum is zero by the hypothesis on \(I\). If \(I\) is proper, choose \(j_1\notin I\) and put
Its weighted sum is again zero because \(a_{i_0}\sigma =c\). The pivot belongs to \(I\), so \(j_1\in J\) and \(j_1\ne j_0\).
Start with the columns \((v_j)_{j\in J}\), replace column \(j_0\) by \(u_0\), and, when \(I\) is proper, replace column \(j_1\) by \(u_1\). Call the resulting matrix \(C\). Every column lies in the required kernel. The row at \(j_0\) has value \(c\) at column \(j_0\) and zero elsewhere. In the proper case the same holds for row \(j_1\) at column \(j_1\): \(u_0(j_1)=0\), \(u_1(j_1)=c\), and all remaining compensated columns vanish there. Therefore equality \(Cy=Cz\) first gives \(y_{j_0}=z_{j_0}\) and, when present, \(y_{j_1}=z_{j_1}\), by cancellation of the nonzero integer \(c\). At any other row \(j\in J\), all unreplaced columns vanish except column \(j\), whose entry is \(c\). The replaced-column contributions already agree, so this row gives \(y_j=z_j\). Hence \(C\) is injective on integer vectors.
Reindex \(J\) by \(\{ 0,\ldots ,q-1\} \), placing \(j_0\) last and, in the proper case, \(j_1\) immediately before it. Such a bijection is obtained from any finite enumeration by one or two swaps; two distinct chosen indices ensure \(q\geq 2\) in the proper case. Let \(B\) be the reindexed matrix. Every row in \(I\) has last entry \(u_0(i)=c\). Every row outside \(I\) has last entry zero and penultimate entry \(u_1(i)=c\), so its last nonzero entry is also \(c\). In the full case all rows have last entry \(c\). Column reindexing preserves both the kernel identity and injectivity. Choose \(p\) to be the maximum of one and the finitely many absolute entry values of \(B\). The preceding coefficients then lie in \(F_p\) and all coefficients after the chosen leader are zero. Expanding a matrix-vector coordinate is exactly the coefficient form of a Deuber row, proving the last assertion. This construction is integral throughout and requires neither basis extension nor a separate denominator-clearing argument.
5.3 Many independent seed generators and bounded multiplicity
Let \(M,P,C\geq 1\), put
and let \(N\geq 2H\) be an integer. There is a set \(\mathcal Y_N\) of at least \((N/(2H))^M\) integer vectors \(Y\in [N]^M\) such that \(D(M-1,P,C;Y)\subset [N]\) for every \(Y\in \mathcal Y_N\).
Let \(L=\lfloor N/H\rfloor \geq N/(2H)\geq 1\). Independently choose each generator \(Y_j\) in the integer interval \([LR^j,2LR^j]\), for \(j=0,\ldots ,M-1\). Each interval has at least \(L\) choices, so there are at least \(L^M\geq (N/(2H))^M\) vectors. The lower endpoint is positive. The upper endpoint is at most \(N\), since \(2LR^{M-1}\leq 2NR^{M-1}/H\leq N\).
For a point of pattern row \(j\), the absolute contribution of all earlier terms is at most
because \(R-1=4P+1{\gt}4P\). For \(j=0\) the earlier sum is zero and the strict bound is still true. The leading term \(CY_j\) is at least \(CLR^j\), so the whole expression is positive. Its upper bound is
Every pattern entry is an integer between one and \(N\), as required.
Let \(B:\mathbb Q^q\to \mathbb Q^s\) be injective, and let \(\mathcal F\) be a finite family of \(q\)-by-\(M\) integer block embeddings. For any fixed \(x\in \mathbb Z^s\) and integer \(N\geq 1\), the number of \(Y\in [N]^M\) for which \(BTY=x\) for some \(T\in \mathcal F\) is at most
Fix \(T\). If it has any such preimages, injectivity of \(B\) implies that their intermediate values \(TY\) are all the same vector \(y\). Choose a pivot coordinate \(j_i\) in the nonempty support of row \(i\) of \(T\). Disjointness makes these \(q\) coordinates distinct and makes the coefficient at \(j_i\) zero in every other row. Once the remaining \(M-q\) coordinates of \(Y\) are prescribed, the equation \(\sum _jT_{ij}Y_j=y_i\) determines \(Y_{j_i}\) uniquely, if it has any integer solution at all: its coefficient \(T_{i,j_i}\) is nonzero, and the other pivot coordinates have coefficient zero in that equation. Equivalently, two solutions agreeing off the pivots have \(T_{i,j_i}(Y_{j_i}-Y'_{j_i})=0\), and cancellation in \(\mathbb Z\) gives equality at the pivot as well. Restriction to nonpivot coordinates is therefore injective on the fiber. There are \(N^{M-q}\) such restrictions. Finally take the union over the finite family \(\mathcal F\); its cardinality is at most the sum of these bounds. Duplicate preimages only make the union smaller, so no uniqueness of \(T\) is needed.
Let \(a_1,\ldots ,a_s\in \mathbb Z\setminus \{ 0\} \) have a nonempty zero-sum subcollection, and let \(r\geq 1\). There are \(N_0=N_0(a,r)\) and \(\delta _0=\delta _0(a,r){\gt}0\) such that every \(r\)-colouring of \([N]\), for \(N\geq N_0\), has a colour class \(C_j\) with
In particular this proves the previously external input in Lemma 57 from the existing Hales–Jewett theorem.
Fix \(q=s-1\), and choose the integral injective kernel parametrization \(B\) and its parameters \(p,c\) from Lemma 71. Use Theorem 70 to fix \(M,P,C\) and a finite nonempty family \(\mathcal F\) of block embeddings. Set \(F=|\mathcal F|\geq 1\), \(R=4P+2\), \(H=(2C+1)R^M\), and \(N_0=2H\). All these choices depend only on the equation and \(r\).
For each \(N\geq N_0\) use Lemma 72 to obtain \(\mathcal Y_N\subset [N]^M\) with \(|\mathcal Y_N|\geq (N/(2H))^M\). Restrict the given colouring of \([N]\) to the positive pattern associated with each seed \(Y\in \mathcal Y_N\). The finite Deuber theorem supplies some \(T\in \mathcal F\) for which \(D(q-1,p,c;TY)\) is monochromatic and is contained in \([N]\). Set \(x=BTY\). Every coordinate of \(x\) belongs to that target pattern, by the kernel matrix construction, so \(x\) is monochromatic and has all coordinates in \([N]\). Moreover \(a^{\mathsf T}x=a^{\mathsf T}BTY=0\). Choose one such output tuple for each seed; all sets involved are finite.
By Lemma 73, a fixed output tuple is selected for at most \(FN^{M-q}\) seeds. Counting the fibers of this map gives at least
distinct monochromatic solution tuples in total. Each belongs to a unique colour class, since \(s\geq 1\) and the classes are disjoint. One of the \(r\) classes therefore contains at least a proportion \(1/r\) of these tuples. Take
Since \(q=s-1\), this is exactly the claimed bound. Repeated coordinates are allowed throughout; no extra distinctness hypothesis was used or obtained.
The checked implementation uses the smaller translated grid \(Y_j=LR^j+u_j\), where independently \(u_j\in \{ 0,\ldots ,L-1\} \). It has exactly \(L^M\) vectors and lies in the same separated intervals, so all preceding positivity estimates apply. For each block matrix, restricting a fiber to nonpivot coordinates now gives at most \(L^{M-q}\) possibilities, because translating the alphabet does not affect coordinatewise injectivity. Consequently \(L^M\leq rF\, C_{\max }L^{M-q}\), where \(C_{\max }\) is the largest monochromatic solution count. Since \(L{\gt}0\) and \(q\leq M\), canceling \(L^{M-q}\) gives
This is stronger than the displayed constant with exponent \(M\) and is the constant used by the Lean assembly theorem.
5.4 What the construction makes explicit
Every finite existence choice in this proof precedes the ambient length \(N\) and its colouring. The compensated integer columns determine \(B,p,c\). A finite recursion using Hales–Jewett lengths determines \(M,P,C\) and the finite embedding family. The elementary formulas above then give \(N_0\) and \(\delta _0\). Numerical optimization is unnecessary for the Sidon application, whose constants may depend arbitrarily on the coefficient vector and the number of colours.
The new proof does not invoke an arithmetic removal lemma, a new infinite Ramsey theorem, or the unpublished Deuber statement in the 1988 paper. Its formalization uses finite sets, finite words, integer matrices, and counting fibers. All reductions in this chapter and the quantitative Rado theorem are now checked in Lean. The bounded-weight consequence in Lemma 58 is checked as well. The only Ramsey theorem imported from mathlib is Hales–Jewett.
5.5 The necessary zero-subsum condition
Let \(c_1,\ldots ,c_s\in \mathbb Z\), with \(s\ge 1\), and suppose
There is a finite colouring of the positive integers with no monochromatic solution to \(\sum _i c_ix_i=0\). There is also a colouring of all integers with the same property for tuples whose coordinates are positive.
Put \(M=\sum _i|c_i|\) and choose a prime \(p{\gt}M\). For every positive integer \(n\), write uniquely
where \(v(n)\) is its \(p\)-adic valuation. The checked factorization uses the concrete natural-number operations padicValNat and Nat.divMaxPow. Colour \(n\) by the residue \(u(n)\bmod p\), an element of the finite set \(\{ 0,\ldots ,p-1\} \). For positive \(n\) that residue is nonzero. A colour is assigned to zero as well in the Lean total function, but zero is excluded from the quantified tuples.
Suppose a positive monochromatic tuple \((x_1,\ldots ,x_s)\) solved the equation. Let \(k=\min _i v(x_i)\) and let \(I=\{ i:v(x_i)=k\} \). The finite nonempty index set ensures that the minimum is attained, so \(I\) is nonempty. For every \(i\), define the integer
Since \(k\le v(x_i)\), exponent addition gives \(x_i=p^k y_i\). Factor the nonzero integer \(p^k\) out of the equation and cancel it: \(\sum _i c_i y_i=0\).
Reduce this equality in the field \(\mathbb Z/p\mathbb Z\). If \(i\notin I\), then \(v(x_i)-k{\gt}0\) and \(y_i=0\) in that field. If \(i\in I\), then \(y_i=u(x_i)\) equals the common colour \(a\ne 0\) there. Consequently
Cancellation of \(a\) shows that \(p\) divides the integer \(\sum _{i\in I}c_i\). Its absolute value is at most \(\sum _{i\in I}|c_i|\le M{\lt}p\). An integer divisible by \(p\) and of absolute value less than \(p\) must be zero, contradicting the zero-subsum hypothesis.
This proves the finite-colouring assertion on positive integers. For a total colouring on \(\mathbb Z\), colour \(z\) by the natural-number colour of \(\max (z,0)\). On positive integers this agrees with the construction above, so the same contradiction applies. The assertion is thus genuinely about a fixed finite colouring, chosen before the positive tuple or any ambient interval.