Formalizing the “no formula for primes” intuition

I was trying to formalize the intuition is that there is no formula for primes, and this is my best attempt:

Conjecture: There is no $$O(n^2)$$ expected time randomized algorithm to generate $$\ge n$$-bit primes.

Currently I believe the best algorithm has conjectured complexity $$\tilde{O}(n^3)$$: run the $$\tilde{O}(n^2)$$ Lucas-Lehmer test on $$O(n)$$ Mersenne numbers. We could go from $$n^3$$ to $$n^2$$ using the same sample-and-check strategy if a faster $$\tilde{O}(n)$$ checking algorithm is found. (This argument for the choice of 2 as exponent due to Paul Christiano.)

However, if a "formula for primes" existed, and was sufficiently simple, the fact that arithmetic is quasilinear means that we might get a quasilinear time prime generation algorithm, or $$\tilde{O}(n)$$. Conjecturing that the minimum exponent is 2 roughly approximates "the best strategy is sample-and-check".

Two questions:

1. Is there any heuristic evidence beyond the algorithms discovered so far about the optimum primality testing exponent, or the optimal exponent for generating primes?
2. Are there other attempts at formalizing the "no formula for primes" intuition?

I should clarify that of course I know that settling the conjecture is hopeless: I’m looking for heuristics only.

1 Answer

[Certainly not a complete answer, but too long for a comment]

Testing whether a given DFA accepts the base-2 representation of at least one prime number is not known to be computable. If it were uncomputable, that's some kind of weak evidence that there's no "regular-ish" formula for primality. (I mean, we know the set of primes itself is not regular, but here it's about whether there's a formula that's sufficiently simple that you could use it to help decide whether a given DFA accepts any primes.)

In another direction, given that your conjecture is about the difference between cubic and quadratic, it might be reasonable to think about whether the problem is complete for cubic time under sub-cubic reductions (see Vassilevska Williams & Williams). It looks tricky, or even unlikely, since it's so different from the other "cubic-complete" problems, like all-pairs shortest paths, triangle detection, etc., but could be worth considering nonetheless. Their framework was in the context of deterministic algorithms, but it shouldn't be too hard to adapt to randomized...

• The notion of comparing to other quadratic vs. cubic algorithms is interesting, but unfortunately I think it would miss the part about primes. E.g., one can define an oracle version of the problem where sample-and-check is optimal and has any desired complexity. The conjecture is an attempt at saying that’s the right model without mentioning oracles. – Geoffrey Irving May 23 '20 at 20:15
• To clarify, it seems unlikely that this would relate to quadratic/cubic complete problems, since intuitively it’d only be as strong as adding a random oracle, and that does solve those complete problems. – Geoffrey Irving May 23 '20 at 20:20
• @GeoffreyIrving: Ah. I see that that's a generalized version of generating primes, but it also seems quite far removed from actual prime numbers themselves (except density-wise). My point was to try to give a subcubic reduction from e.g. APSP to generating primes. Perhaps I shouldn't have said "complete for cubic time" (which indeed would relativize), but rather APSP-hard under sub-cubic reductions - would that clear up your objection, or am I missing something? – Joshua Grochow May 24 '20 at 7:13
• Yep, that would be helpful if it worked, I just have no idea how to do it. :) – Geoffrey Irving May 24 '20 at 7:37
• "a given DFA accepts the base-2 representation of any prime number", before I followed the source, this sounded like the unbelievable statement of the DFA accepting every prime number. Perhaps "at least one prime number" makes it clearer? – ComFreek May 24 '20 at 9:30