# Trimming two lists of possible prime positions tightens the bounds on five- and six-prime spans

How short an interval can contain five or six primes infinitely often? One way to prove an upper bound on that span is to start with a list of possible prime positions and slide the whole list along the number line. More positions give more chances to find primes, but positions far apart may contribute primes that do not fit in the same short interval. Previous calculations used lists of selected sizes. Could a shorter list give a better bound?

We found the best span that the published test accepts among all subsets of two such lists and their extensions. With the sharper of two published estimates used in the test, the minimum span is 82,188,372 for five primes and 4,816,799,794 for six. Trimming the original lists reaches the five-prime minimum and comes within 12 of the six-prime minimum.

## How pairs of positions determine the bound

A list specifies positions relative to a common starting integer $n$. Each entry, or *shift*, is an integer $h$ marking a possible prime at $n+h$. The list must be *admissible*: for each prime $p$, at least one remainder on division by $p$ must be absent from the shifts. Otherwise every choice of $n$ would place at least one position on a multiple of $p$.

Let $p_n$ be the $n$th prime. The difference $p_{n+m}-p_n$ is the span from the first to the last of $m+1$ consecutive primes. The quantity $H_m=\liminf_{n\to\infty}(p_{n+m}-p_n)$ gives the smallest such span that recurs infinitely often. For example, $H_4\le D$ means that infinitely many intervals with endpoint difference $D$ contain at least five primes.

Kapila's [pair-penalty sieve](https://hexagonmath.org/pdf/2610.00419v2) uses a weighted count of primes and permits the shifts to spread beyond the target span $D$. It charges a penalty for each unordered pair of shifts more than $D$ apart (a *long pair*). If the count of long pairs stays within an allowance, the weighted count still guarantees $m+1$ primes within span $D$ infinitely often. The allowance depends both on the number of shifts retained and on a *quotient* that measures how much the function used to weight the positions contributes to the prime count. A larger lower bound for the quotient permits more long pairs.

Kapila's [certificates for prime-cluster bounds](https://github.com/a-kapila/maths-proofs/tree/2e2d689f198e7bd51d264cd5468d6b7606886d2e/prime-gaps) give calculations at selected list sizes. A [November release of shifts and sieve estimates](https://github.com/pruzze/bounded-gaps-witnesses/tree/e04144013918630e5663f4cc17c5c87851d89d37/kapila_h2_h5) supplies a list of 5,089,150 shifts for five primes and sharper quotient estimates. For six primes, [Giraudin's construction](https://hexagonmath.org/pdf/2611.00516v2) gives a span of 4,817,211,684 using 232,465,000 shifts and Kapila's printed quotient. These lists give a starting point for testing whether dropping shifts saves enough long pairs to compensate for the loss of possible prime positions.

## Minimum spans

Table 1 gives the smallest span accepted by the pair-count test in each search. “Printed” and “sharper” refer to the two lower bounds for the quotient. The first two result columns use only the published shifts; the last two draw from a larger pool made by applying the same exclusions beyond both ends of each published list. In each pool we compared keeping the published list size with allowing the size to vary.

| Primes | Quotient | Published set, unchanged | Published set, any size | Extended pool, published size | Extended pool, any size |
| --- | --- | --- | --- | --- | --- |
| 5 | Printed | 82,205,490 | 82,205,490 | 82,205,490 | 82,205,490 |
| 5 | Sharper | 82,190,538 | 82,188,372 | 82,190,538 | 82,188,372 |
| 6 | Printed | 4,817,211,684 | 4,817,180,226 | 4,817,211,684 | 4,817,180,220 |
| 6 | Sharper | 4,816,912,080 | 4,816,799,806 | 4,816,912,056 | 4,816,799,794 |

For five primes, trimming the published list saves 2,166 with the sharper quotient. Extending the pool gives no further gain. With the printed quotient, neither trimming nor extending improves the span.

For six primes, changing just the quotient on Giraudin's unchanged list brings the span down to 4,816,912,080. Keeping the first shift and dropping the last 34,108 saves another 112,274, the most any subset of that list can save. Extending the pool saves only 12 more. Within the extended pool, allowing the size to vary rather than fixing it at 232,465,000 saves 112,262 with the sharper quotient and 31,464 with the printed quotient.

## Why consecutive entries suffice

A *window* consists of consecutive entries in the ordered pool. To see why a search over windows can establish a minimum over all subsets, suppose the distance between the first and last entries of the pool is at most $2D$. Take any subset that skips a pool entry between its endpoints. Replace whichever endpoint is nearer to the skipped entry with that entry. The move is at most $D$, so every selected point that the endpoint passes is within $D$ of its replacement. Distances to selected points beyond the replacement only decrease. The exchange therefore creates no new long pair. It also leaves fewer pool entries between the selected endpoints. Repeating the exchange gives a window of the same size with no more long pairs.

Both pools meet the width condition at each reported minimum and at the preceding even span. Within each pool the shifts are either all even or all odd, so every pair distance is even. For an attained even span $D$, reducing the span by any amount less than two gives the same count as testing $D-2$. If every window fails at $D-2$, the exchange argument rules out every subset there. Lowering the span further can only add long pairs.

## Counts at the minimum

Table 2 gives a qualifying window for each minimum found by varying the size in an extended pool. The window contains every pool entry from the first shift shown to the last. The distance between those shifts exceeds the target prime span $D$; the test allows this because the long-pair count stays within the allowance. The last column shows how far the best window misses its own allowance when the target span falls by two.

| Primes | Quotient | First and last shifts | Size | Long pairs / allowance | Smallest excess at $D-2$ |
| --- | --- | --- | --- | --- | --- |
| 5 | Printed | -37,933,474 to 44,319,256 | 5,089,146 | 4,064,292 / 4,064,820 | 133 |
| 5 | Sharper | -37,927,852 to 44,308,934 | 5,088,177 | 4,273,248 / 4,273,281 | 569 |
| 6 | Printed | -2,427,798,523 to 2,391,139,279 | 232,448,311 | 3,315,666,464 / 3,315,678,345 | 1,767 |
| 6 | Sharper | -2,427,824,911 to 2,390,739,487 | 232,430,850 | 3,328,755,015 / 3,328,756,683 | 3,736 |

At the sharper six-prime minimum, the window shown clears its allowance by 1,668 pairs. Two units lower, even the best window exceeds its allowance by 3,736 pairs.

At the preceding even spans, the exhaustive checks with the sharper quotients covered 74,316,479 windows for five primes and 41,658,662,843 for six. A second count at the attained spans found 132 and 40,760 qualifying windows, respectively. Their sizes fill exactly the intervals 5,088,171–5,088,183 and 232,430,792–232,430,907. Because endpoint exchanges preserve size, these are also the complete ranges of sizes for qualifying subsets. There may be qualifying subsets besides the windows counted.

The endpoint counts show why the benefit from trimming stops. For the sharper six-prime window in Table 2, deleting one more shift must save at least 81,727 long pairs to preserve the margin by which the set passes the sieve inequality. Deleting the left endpoint saves 81,724; deleting the right saves 81,723. Adding back the first omitted shift on the left or right would introduce 81,727 or 81,728 long pairs, respectively. These comparisons locate a stopping point for trimming that window. The exhaustive counts establish the minimum over the pool.

## Methods

### Constructing the pools

The five-prime release uses the same set of shifts for both quotients, from −37,934,836 to 44,318,042. The release specifies forbidden residue classes, each of which excludes all integers with a particular remainder for a particular prime. Removing those classes from the interval recovered exactly the published set. We applied the exclusions to 200,000 more integers on each side, giving an extended pool of 5,111,211 shifts.

For six primes we reconstructed Giraudin's set from Kapila's table of residue classes and [Giraudin's amendments to the table](https://hexagonmath.org/src/2611.00516v2/files). The set contains selected primes above ten million, selected negatives of such primes, and the two integers −1 and 1. Its endpoints are −2,427,786,701 and 2,391,510,637. If a prescribed missing class contained −1 or 1, we chose the first absent class starting at remainder 2. Applying these exclusions inside the published interval recovered the same set. We extended the search by 4,000,000 integers on either side, retaining signed primes that passed the same exclusions, for a total of 232,824,829 shifts.

The sieve starts with a function of $k$ coordinates, one for each possible shift in the calculation. We consider subsets with at most $k$ shifts. An independent membership check verified that each extended pool omits a residue class for every prime through its corresponding $k$, given below. For any larger prime there are more classes than shifts in the subset, so at least one class must be absent.

### Computing the allowance at each size

Kapila's sieve uses a symmetric trial function, so the allowance depends on how many coordinates we retain, regardless of which ones they are. Write $K\le k$ for the number retained and $K_0$ for the published list size. Changing $K$ changes both the benefit $\beta(K)$ from rescaling the retained coordinates and the cost $C(K)$ of one long pair. In the table, the subscript 0 marks values at $K_0$, and $q$ is the quotient lower bound. The parameter $r$ limits the rescaling factor to $r/(r-1)$, and $\eta$ sets the weight in the integral used to compute the pair cost. The decimal inputs are exact.

| $m$ | $k$ | $K_0$ | $r$ | $\eta$ | $\beta_0$ | $C_0$ | $q$, printed / sharper |
|---|---:|---:|---:|---:|---:|---:|---|
| 4 | 5,090,000 | 5,089,150 | 10 | 1.081 | .00015523001241465 | 1.945365350719 × 10⁻¹¹ | 15.23857870587577 / 15.2388031515275 |
| 5 | 232,500,000 | 232,465,000 | 4 | 1.082 | .00014210693394371 | 1.491020798040 × 10⁻¹⁴ | 19.04804762745624 / 19.0481293148757 |

To obtain the pair cost at each size, we use Kapila's integral (8.4), written $J(K)=J_K(K\eta)$. Over the triangle $u,v\ge0$, $u+v\le1$, integrate the reciprocal of
$$
(1-u-v+K\eta u)(1-u-v+K\eta v)+\tfrac12 K\eta^2(u-v)^2
$$
against $du\,dv$. With Kapila's limiting sieve parameter $\rho=151320927303522335/2^{59}$, the benefit, cost and resulting threshold $F(K)$ for long pairs are
$$
\beta(K)=\beta_0\frac{\binom{k}{r}-\binom{K}{r}}{\binom{k}{r}-\binom{K_0}{r}},\qquad
C(K)=C_0\frac{J(K)}{J(K_0)},\qquad
F(K)=\frac{\rho q K/k-m(1-\beta(K))}{C(K)}.
$$
A set passes if its long-pair count $B_D$ is strictly below $F(K)$. The largest allowed integer count is therefore $A(K)=\lceil F(K)\rceil-1$. A nonpositive numerator rules out the size without evaluating $J$.

The formula for $\beta(K)$ follows from Kapila's equation (10.2). Its lower bound on the benefit is a fixed mean for the original trial function divided by $r$, times $1-\binom{K}{r}/\binom{k}{r}$. Rescaling the conservative bound $\beta_0$ by the ratio of this factor at $K$ to its value at $K_0$ gives the stated benefit. For the cost, Kapila's Proposition 10.2 multiplies $J(K)$ by a coefficient independent of $K$. The ratio of integrals thus gives the change in the raw cost, before any division by $1-\beta(K)$. To obtain the sharper $q$ values, we took the lower endpoints of the released quotient estimates, subtracted the bounds on the loss from restricting the trial function's support, and rounded down. The strict inequality leaves room to approach the limiting sieve parameters as in Kapila §11.4.

Only sizes near $k$ can pass. To see how the numerator of $F$ changes as shifts are removed, let $\mu=r\beta_0/[1-\binom{K_0}{r}/\binom{k}{r}]$. By Pascal's identity for binomial coefficients, the first deletion from $k$ shifts increases $\beta$ by $\mu/k$, and subsequent increases are smaller. Since $\rho q>m\mu$ in each case, the numerator decreases with every deletion. Exact rational comparison for the sharper quotients leaves only $0\le k-K\le3,253$ for five primes and $0\le k-K\le109,717$ for six.

We computed each allowance from the closed form for $J$ in Kapila (8.8) using interval arithmetic, which gives lower and upper bounds throughout the calculation. We accepted the integer allowance only when both bounds gave the same ceiling. As an independent check, we integrated the one-dimensional form in §8.3 at eight nearly equally spaced integer sizes across the eligible range. We interpolated between them with a degree-seven polynomial.

To bound the interpolation error, write the denominator of the defining integral at fixed $u,v$ as $P(K)=a+bK+cK^2$ with nonnegative coefficients. For a change $h$ in size, set $t=h/K$. Then $P(K)/P(K+h)$ is the reciprocal of $1+st+wt^2$, with $0\le s\le2$ and $0\le w\le1$. The recurrence for the coefficients of this reciprocal bounds its $n$th coefficient in absolute value by $(5/2)^n$. Integrating gives the derivative bound $|J^{(8)}(K)|/8!\le(5/(2K))^8J(K)$. Since $J$ decreases, the interpolation error on an interval of length $L$ starting at $K_{\min}$ is at most $(5L/(2K_{\min}))^8J(K_{\min})$. With this error included, the two evaluations agreed on every integer allowance. Using the full released endpoints in place of the shortened constants added at most one pair per allowance and no eligible sizes. Every minimum found by varying the size stayed the same.

### Finding and checking the minimum

With the left endpoint fixed, deleting the right endpoint saves one pair for each retained shift more than $D$ to its left. As the right endpoint moves inward, the number saved at each step cannot increase. To preserve or improve the margin $F(K)-B_D$, a deletion must save at least $\lceil F(K)-F(K-1)\rceil$ pairs. Interval arithmetic verified that this threshold never fell with successive deletions over the eligible sizes tested. Once a deletion saved too few pairs, no later deletion could help. We therefore used binary search to find the best right endpoint for each left endpoint, then binary search in $D$ to find the first feasible even span.

A separate enumeration checked every eligible window at that span and at the preceding even span without using the stopping rule. For each possible right endpoint, we tabulated how many pool entries were more than $D$ to its left. Dropping $i$ entries on the left reduces that count by $i$, down to a minimum of zero. Cumulative sums of the tabulated counts gave the initial pair total without listing individual pairs. At each left endpoint we started with the longest eligible window. Each time we removed the right endpoint, we subtracted its long-pair count and compared the remaining total with the allowance for the smaller window. We independently checked each window in Table 2 by scanning its shifts in increasing order. For each shift we counted earlier entries strictly below that shift minus $D$. Summing those counts reproduced its long-pair total.

These minima are exact for the specified pools and pair allowances. Interpreting them as bounds on infinitely recurring prime clusters relies on Kapila's analytic criterion and the cited bounds on its inputs. Other pools or sieve estimates could yield shorter spans. The minimum span accepted by the test is not a lower bound on how closely primes themselves can cluster.
