# Why is $\{ w \in \Sigma^* : M_w[\epsilon]\downarrow \land |w| \leq 7\}$ decidable?

I get that the argument for this set $$\{ w \in \Sigma^* : M_w[\epsilon]\downarrow \land |w| \leq 7\}$$ to be decidable is that $$|w|\leq7$$ meaning it is a finite set and therefore it can be decided. But my problem is that for each of the $$w$$ it could be the case that one has to wait an infinite amount of time in order to decide whether or not it belongs in the set. So where lies my mistake in this reasoning?

$$M_w[\epsilon]$$ is the output of the Turing machine corresponding to encoding $$w$$ on input $$\epsilon$$.

$$M_w[\epsilon]\downarrow$$ is short for $$M_w[\epsilon]$$ halts.

New contributor
linuxxx is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
• Please edit your question to define all notation in a self-contained way, including $M_w[\epsilon]\downarrow$.
– D.W.
Aug 1 at 16:46
• Related: cs.stackexchange.com/q/367/755.
– D.W.
Aug 1 at 16:49
• \sum is $\sum$ and \Sigma is $\Sigma$. I fixed it for you. Aug 1 at 19:47

First, note that if $$|\Sigma| > 1$$, you have more than eight different $$w$$.

Second, I would assume that $$M_w[\varepsilon]$$ is the output of the Turing machine corresponding to encoding $$w$$ on input $$\varepsilon$$.

I assume, that $$M_w[v]\downarrow$$ is short for $$M_w$$ halts on $$v$$.

You correctly observed that the restriction to $$|w| \leq 7$$ guarantees that the set is finite and hence, decidable. However, this reason is indeed not very constructive: Which Turing machine codes are actually in your language is not clear but it is a (finite) subset of $$\{w \in \Sigma^\ast \mid |w| \leq 7\}$$. For each of those subsets you can construct a TM (in fact, a finite automaton even) and one of these TMs is the correct machine, you just do not know which one.

• I don't get from your answer why my incorrect reasoning that basically, the question if $M_[w]\downarrow$ holds for a $w \in \Sigma^\ast$ is essentially a halting problem on an empty tape - so $\mathcal{H}_0$ for each of the finite $w$, is incorrect. The main takeaway I got from your answer is that $\{w \in \Sigma^\ast | |w| \leq 7\}$ is decidable (obv.). But then how is the "or each of those subsets you can construct a TM (in fact, a finite automaton even) and one of these TMs is the correct machine, you just do not know which one." part something that is decidable? Aug 1 at 17:04
• You do get why any finite set is decidable, right (constructing a TM is essentially constructing a straight-forward finite automaton). Now whether $M_w[\varepsilon]\downarrow$ or $M_w[\varepsilon]\uparrow$ – you don't know but for each $w$ considered, one of these statements is true and your language is just the set of words where the former statement is true. No matter which words are now in the set, you can construct a TM for that set. That makes the set decidable. It abstracts from the notion that you are solving a halting problem,it appears just a set of words that coincides with your HP Aug 1 at 17:25
• Ah I think I'm getting closer to understanding. We basically skip this question of whether or not $M_w[\epsilon]$ holds $\rightarrow$ $M_w[\epsilon]\downarrow$ for one of the $w$ in the finite set of $\{w \in \Sigma^\ast | |w| \leq 7\}$ and instead want to know if there's a TM that can 'depict' all the elements in this set once the $w$ that satisfy the condition are found - which is always the case as the language has to be finite and therefore we could just hardwire this in a TM, DFA style? Aug 1 at 17:53
• But this still feels like cheating as the process of deciding $M_w[\epsilon]\downarrow$ is undecidable - but we just think about wether or not once these $w$ are found if there are only finite many and therefore if the language is finite... Aug 1 at 17:58
• But I guess the question of decidability regarding $\{w \in \Sigma^\ast | M_w[0]\downarrow\}$ is strictly a question regarding the decidability of $|\{...\}| \neq \infty$ and not $M_w[0]\downarrow$ Aug 1 at 18:04

The error in your reasoning is where you say "one has to wait an infinite amount of time in order to decide whether or not it belongs in the set". You are hypothesizing one possible way to decide, and then demonstrating that this possible way doesn't work. That is all correct as far as it goes.

But this doesn't mean that the problem is undecidable. There is another way to decide the problem, that doesn't require doing things the way you were hypothesizing, but that does things differently. The other way works by hardcoding the answers, without simulating the Turing machine or running it for a while. See How can it be decidable whether $\pi$ has some sequence of digits?. That other way shows that the problem is decidable.

You can't show a problem is undecidable by showing that one particular way of deciding fails. You can only show a problem is undecidable if you can show that all candidate ways of deciding don't work.

Regarding your comment about "feels like cheating", whenever you get that feeling, I recommend you go back to the mathematical definition. The mathematical definition of when a problem is decidable is if there exists an algorithm that decides it, and there is a specific mathematical definition of when we consider an algorithm to decide a problem. Hardcoding yields an algorithm meets all of those criteria.

I understand your sense that it "feels like cheating". What that sense is teaching you is that your intuition isn't quite right yet: it doesn't quite match the mathematical definition. These examples are designed to help you refine your intuition so that it better captures the actual mathematical definition.

• So regarding my original question to make it concise - the problem in my reasoning is that there could very well be a TM $M$ with $enc(M) = w, |w|\leq7$ such that $M_w[\epsilon]$ holds and therefore $w \in L$ - the core of this problem is that such a TM can exist as the problem it has to decide is - decidable (as the set it has to decide is finite)? I think this makes a lot more sense and feels intuitively right. Aug 1 at 20:35