# Proving decidability of language

Prove or disprove: The following language $L$ is decidable:

$\{ \langle M, t\rangle: M \text{ is a Turing machine and } \forall w \in \{0,1\}^* [M(w) \text{ halts in at most } t \text{ steps} ]\}$

So for proving I need to construct a TM $U$. If it accepts $L$, so L is decidable, otherwise not.

My steps are:

$U$ = "On input $\langle M, t\rangle$:

1. $i:=1$;
2. Simulate one step of $M$ on $w$.
3. If $M$ accepted $w$ then $U$ accepts.

If $M$ rejected $w$ then $U$ rejects.

If $i ≥ t$ then $U$ rejects.

4. Else $i:=i+1$; goto step 2."

Because $U$ is the decider machine (finite number of steps) $\longrightarrow$ $L$ is the decidable language.

Is this solution correct? Or I should do it in another way?

• The text of the exercise is slightly malformed, I assume from context that you actually meant "$M(w)$ halts (...)" instead of "$M(x)$ halts (...)". In that case, your proof doesn't work, because the machine you describe would yield the answer for a single input out of infinitely many. Technically, you have only proven that $L$ is co-recursively enumerable. Hint: do you really need to check infinitely many inputs? – quicksort Apr 19 '18 at 0:50
• @quicksort Turn into a full-fledged answer? – Yuval Filmus Apr 19 '18 at 7:32
• This question appears to be unsuited for this site because questions of the form: "This is the exercise problem, this is my solution. Please grade!" are not interesting for anyone but you. Please see this related meta discussion, and these hints on asking questions about exercise problems. If you want to ask a specific question about a specific part of your attempt, please edit the question accordingly and it may be reopened. Otherwise, you might want to visit Computer Science Chat and get some feedback there. – Raphael Apr 19 '18 at 9:08
• The title you have chosen is not well suited to representing your question. Please take some time to improve it; we have collected some advice here. Thank you! – Raphael Apr 19 '18 at 9:08
• Also, why post basically the same thing twice? Feedback on one should tell you all you need to know about the other. – Raphael Apr 19 '18 at 9:10