Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Phrased another way: Are there any problems that are known to be decidable in a better worst-case time complexity than the best known procedure?

share|cite|improve this question
up vote 5 down vote accepted

Easy answer:

Decide the set of numbers $n$ such that every even number between $4$ and $n$ is the sum of two primes.

This is known to be decidable in $O(1)$ time, because either Goldbach's conjecture is true and the program that always outputs "yes" will work, or the conjecture fails, in which case the program only needs to compare its input to a constant.

However, we don't know which algorithm decides this problem in $O(1)$ time, and if Goldbach's conjecture is true but unprovable (which looks fairly likely at this point), it will be forever unknown which algorithm to use.

Does this feel like cheating? One objection is that the set to decide is either $\mathbb N$ or $\{1,2,3,\ldots,n\}$ for some $n$, and all of those have known, or at least easily constructible, constant-time algorithms. However, that just shows that what we can prove about a problem doesn't depend only on the Platonic identity of the problem as a subset of $\mathbb N$ but rather on the particular description of the problem we need to prove things from. So I don't think you are going to make that objection.

A more serious objection is that we might want to reinterpret the question such that "decidable in $O(f(n))$ time" means that there is some algorithm that provably decides the problem, and happens to finish within $O(f(n))$ time each time we run it -- even though this bound may not itself be provable. We may even, without loss of generality, be so liberal as to accept a non-constructive proof that the algorithm exists, if only it also proves that if we ever find the algorithm, we would be able to prove that it decides the right problem.

Not-so-easy, but surprising, answer: Even with this reinterpretation, the answer is still that if you can prove (however non-constructively) that a particular problem is decidable within some particular asymptotic bound (in the above sense), then I can give you an algorithm that decides it within that asymptotic bound. In fact, I can give you an concrete algorithm right now that will run within any asymptotic upper bound you can prove for the problem, ever.

This is based on Levin's universal search theorem, and goes roughly like this:

  • Enumerate all programs that provably decide the problem at hand. This can be done by enumerating all possible strings of symbols, in order of increasing length, and checking for each one whether it happens to be a valid proof (say, in ZFC or PA according to which kind of provability you want) that some program decides the problem.
  • Simulate all of the found programs on the given input in parallel, time-sharing between them such that the search form more programs uses $\frac 12$ of the total time used, and the $i$th found program gets $\frac 1{2^{i+2}}$ of the total time we spend.
  • Once any of the simulated programs halts, stop everything and halt with that answer.

Now, if you prove that there is an algorithm that decides the problem in $g(n) = O(f(n))$ time, then that algorithm, even if you don't know which it is, must have some index $i$ in the enumeration. Then the running time of the parallel search algorithm can be at most the sum of (a) the time it takes for the program-enumeration to reach index $i$ (which is independent of $n$ and therefore just a constant term, asymptotically), and (b) $g(n)$, times $2^{i+2}$ (because the simulation only gets a fraction of the total time we use), times the slowdown factor inherent in simulating the found program instead of running it directly. In a reasonable cost model, this slowdown can be shown to be at most a constant factor.

Thus, the running time of the search algorithm is at most a constant term plus a constant times $g(n)$, which is $O(f(n))$ because $g(n)$ is. And that is a worst-case estimate because it assumes that algorithm $i$ in the enumeration is the first to stop, but it might possibly be another algorithm that wins the race, in which case the search algorithm can run strictly faster than $O(f(n))$.

And the best thing is you can go right ahead and write this program now. You'll need: a proof checker (more or less an off-the-shelf component); a linear-slowdown interpreter for a general-purpose programming language (very off-the-shelf, but watch out for patents); a formal semantics for the interpreted language (here you'll need a literature search, or possibly to hire a CS graduate student); and a formal statement of the problem you want to solve (likely the hardest part).

The worst thing is, of course, that the constant factors that the big-O notation hides will be truly, mind-bogglingly gargantuan. It's not a practically feasible algorithm for anything -- in fact do not expect any test run to finish before the heat death of the universe. But mathematically speaking it's going to work impeccably!

share|cite|improve this answer
I remember seeing similar things like "There is aliens on Mars" in Michael Sipser's book. – FiniteA Mar 21 '12 at 2:36
Great answer! So I guess then that any unsolved problem in mathematics would fit this criteria. For example, the question "Does $P = NP$" is decidable in $O(1)$ time (always outputs 'yes' or always outputs 'no'), but we don't know which answer it should always output. – Matthew Pirocchi Mar 21 '12 at 2:41
@Matthew: Yes. The Goldbach example does have the special appeal that in the formulation I gave it here it is easy to write a naive algorithm that provably decides the problem in pseudo-polynomial time -- it is only if we want a fast algorithm that we run into the "one of these works, but we don't know which" situation. – Henning Makholm Mar 21 '12 at 2:51
Nice answer, but things can be done even closer to Goldbach's conjecture; I mean that I do not see why using this sophisticated way of presenting Goldbach's conjecture. I refer to the fact that the set of natural numbers $\{ n \in \mathbb{N}: \textrm{ there is some even number which is not the addition of two prime numbers } \}$ is also trivially satisfying the requirements of the question (because this set is either $\mathbb{N}$ or $\emptyset$, and in both cases it is trivially decidable in a constant amount of time). – boumol Mar 23 '12 at 16:54
@boumol: That is answered in my previous comment. In my formulation there is a concrete, easy-to-write algorithm for deciding the set; it is just slow. Your set has no known algorithm. My point with this extra complication is to illustrate that the "there's an algorithm but we don't know which" phenomenon does not have to be inherent in the problem -- it may be that it only shows up for some particular resource bound applied to the problem. – Henning Makholm Mar 23 '12 at 17:08

Does this answer to a CS Theory stack exchange question suffice? In general, the most promising idea here would be to find a problem where deciding it just involves enumerating a list of choices and checking them for a property, which will have some definite bound of $O(n^{k})$ or something once the number of choices $k$ is known, but finding problems where that value of $k$ isn't known. The Robertson and Seymour graph minor work is basically this idea, which is why the worst-case constant on $n^{3}$ isn't known a priori for a problem instance.

Imagine if we know that polynomials all had $k$ roots for some value of $k$, and that given $k$ there was an $O(n^{k})$ algorithm for finding them... but that it was unknown how to compute $k$. I'm wondering if that would suffice for you, or would you say that we "don't know" how to solve that problem since we don't know how to compute $k$.

(Obviously, in real life, we'd need to find an example that swaps out polynomials for some other objects and roots for some other property/attribute. Nothing vivid comes to my mind.)

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.