Pattern in twin primes

Julián Aguirre's answer is the definitive one, but I also want to give some insight on why this conjecture is kind of unreasonable (i.e. that one should expect it to become false by just doing a little computation).

Caveat: none of the following is proven — for instance, it hasn't been proven that there are infinitely many twin primes, so the probability of a number being part of a twin prime could in fact be $0$. But it is based on what number theorists call a heuristic argument based on the idea that primes are a reasonably good source of randomness and don't contain hidden correlations except for those that are easily explained (e.g. very few even numbers are prime). Heuristic arguments are frequently used to guess at what conjectures are plausible and which are implausible, and surprisingly they can be made quite precise.

There is a huge amount of flexibility in choosing $P_p$ (exponentially many choices), so one might expect that the failure of this conjecture will be that there are too many twin primes than predicted (and indeed this is what Julián discovered). How would we begin to analyze this?

Given a random large number $N$, the chances that $(N,N+2)$ is a twin prime are a little bit higher than $1/(\log N)^2$. In your case these numbers are not entirely random but they are specifically chosen to be indivisible by certain small primes ($2$ as well as the primes composing $P_p$), so we should really think of $1/(\log N)^2$ as a lower bound.

For a given $P_p = \prod_{p \in S_p} p$, the size of $1/(\log N)^2$ will depend on the specific set of primes $S_p$ that go into it: $\log N$ itself will be almost exactly equal to $\log p_n + \sum_{p \in S_p} \log p$. Since we're going for a lower bound, instead of summing up all the possibilities let's just take the worst case of all primes from $p_2$ to $p_n$. This gives (after some computation) $\log N \approx p_n$ so $1/(\log N)^2 \approx 1/p_n^2$.

But there are $2^{n-2}$ choices for $P_p$. Each of them has at least a $1/p_n^2$ chance of being part of a twin prime, so heuristically we would expect to find $2^{n-2}/p_n^2$ twin primes this way. Since $p_n$ only grows as fast as $n \log n$, the expected number of twin primes approaches infinity very quickly, so we should easily expect it to outstrip $n-2$ itself.

On the other hand, given that it has no reason to be true in general, it's nice that the pattern does hold up for $n=3, \ldots, 8$.


This is an answer to your last demand:

Do[
 q = Prime[n] Times@@@Rest[Subsets[Table[Prime[k], {k, 2, n - 1}]]];
 twin = Intersection[Select[q - 4, PrimeQ] + 2, Select[q - 2, PrimeQ]];
 Print["n = ", n, " - ", twin, " - ", Length[twin]],
 {n, 3, 20}]

The pattern breaks at $n=9$, since there are $8$ and not $7$ pairs of twin primes. For $n=20$ there are $2674$ pairs.

I have included the possibility of $m=2$, since you use it (although in the question you say $2<m<n$.)


Starting from a prime $p_n$, the first candidate for a twin prime that the pattern generates is $3p_n-4$. If this formula does indeed produce prime numbers, then by iterating it, we have a simple way to generate arbitrarily large primes. That would be a big deal all by itself, as no such generator is known today. So we should be skeptical that the formula works...

Well, let's try it!

$5 \times 3 - 4 = 11$
$11 \times 3 - 4 = 29$
$29 \times 3 - 4 = 83$
$83 \times 3 - 4 = 245$

but $245$ is not prime.