MathOverflow is a question and answer site for professional mathematicians. Join them; it only takes a minute:

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

If a language L is decidable, does that imply that the is a computable function f such that L is in O(f(n)) ?

For example what would be the complexity class of the language of "provably halting Turing machines that halt in an even number of steps"

share|cite|improve this question
A better forum for this question is Theoretical Computer Science. – Joseph O'Rourke Sep 2 '13 at 13:10
Does "is in $O(f(n))$" mean that deciding whether a string is in $L$ can be computed in time $O(f(n))$ where $n$ is the length of the string? Does the language have a finite alphabet? (If both answers are yes, then the answer is trivially yes by taking $f(n)$ to be the maximum computing time of the decision algorithm over strings of length $n$. This is computable since the alphabet is finite and there are only finitely many strings of length $n$.) – François G. Dorais Sep 2 '13 at 13:33
@JosephO'Rourke, complexity theory questions are on-topic here at MO. – Joel David Hamkins Sep 2 '13 at 13:57
Ken, I think you mean Turing. – Joel David Hamkins Sep 2 '13 at 14:00
@Joel: Apologies; I stand corrected. – Joseph O'Rourke Sep 2 '13 at 14:06

The answer to your first question is yes: if $L$ is decidable, there is an algorithm that decides it, and this algorithm has a time complexity which is in $O(f(n))$ for $f(n)=$``maximal running time of the algorithm on entries of length $n$''.

As for your second question, I'm not sure your language is decidable: what would be your algorithm ? Trying all proofs of halting only works if a proof exists, and we'll get stuck if the halting problem for this machine is undecidable. Anyway if an algorithm exists, the above construction for $f(n)$ answers your question.

share|cite|improve this answer

The answer to your second question is that this problem is not decidable, since in fact that language is equivalent to the halting problem. First of all, every halting program is provably halting (in very weak systems, such as PA), since the computation itself can be turned into a proof of halting. Another way to say this is that every true $\Sigma^0_1$ assertion is provable. So you are really just asking about the language of programs that halt in an even number of steps. But this is equivalent to the halting problem, since we can reduce the halting problem to it: given any Turing machine program $p$, design a new program $p'$ that operates just like $p$, but inserts a redundant step between each step of $p$. So $p$ halts on a given input if and only if $p'$ halts on that input in an even number of steps. So if we could decide your problem, then we could decide the halting problem.

share|cite|improve this answer

Let me add something on the second question. As D K wrote, the way you formulated it it is undecidable. However, if you take a fixed Turing machine $M$ such that a ($\Sigma^0_1$-sound) theory $T$ proves “for every $x$, $M$ halts on input $x$”, then the language accepted by $M$ is indeed decidable, which means there is a recursive bound on its running time. While this is just about everything one can say in general, quite a lot more is known for some particular theories $T$. For example, if Peano arithmetic proves that $M$ halts on every input, then its running time is eventually bounded by a function $f_\alpha$ in the fast-growing hierarchy with $\alpha<\epsilon_0$.

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.