5

Let \begin{align*} L_1 &=\{\langle M,w\rangle \mid M\text{ halts on }w\}\\ L_2 &=\{\langle M,w\rangle \mid M\text{ does not halt on }w\}\,. \end{align*} Here $M$ represents encoding of a Turing machine (T.M.) and $w$ is the input string. What is the class of $L=L_1 \cup L_2$?


I read that the union would be a regular language as a string has to belong to either $L_1$ or $L_2$ (i.e., halt or not halt) so their union would be a regular language.

I have a doubt. Suppose we assume $L$ as a recursively enumerable (R.E.) language then there exists a T.M. which halts on all "yes" cases. Here yes cases means strings which belong to either $L_1$ or $L_2$. So, if a string belongs to $L_2$, then the T.M. should halt which means that we are able to halt and say "yes" even if machine doesn't halt on this string (according to condition of $L_2$). This solves halting problem and hence assumption is not correct and so $L$ should be non recursively enumerable.

I know that there is some flaw in the explanation given above but I am not able to find it.

Can someone please help me?

David Richerby
  • 82,470
  • 26
  • 145
  • 239
Zephyr
  • 1,003
  • 3
  • 17
  • 34

2 Answers2

10

The language $L = L_1 \cup L_2$ consists of all pairs $\langle M,w \rangle$ where $M$ is a description of a Turing machine and $w$ is a word. This language is not necessarily regular (it depends on the exact encoding), but it is certainly decidable. All you have to do, given an input, is to decide whether it is of the form $\langle M,w \rangle$.

Note that deciding $L$ bears no relation to the halting problem. My description of $L$ doesn't refer to whether $M$ halts on $w$ or not. Here is a similar example. Let $f$ be an uncomputable integer-valued function. The function $g := 1-f$ is uncomputable as well, yet $f + g$ is computable.

Yuval Filmus
  • 280,205
  • 27
  • 317
  • 514
5

a string has to belong to either L1 or L2 (i.e halt or not halt) so their union would be a regular language.

This is a false statement. There is no chain of reasoning so it's hard to tell where the problem is.

Maybe it's a language issue. Consider this statement:

Every string (over some alphabet $\Sigma$) belongs to either $L_1$ or $L_2$. (*)

If that is true, then $L_1 \cup L_2 = \Sigma^*$ which is indeed regular.

Whether it is true depends on the encoding $\langle \_,\_ \rangle$. If it is surjective¹, then (*) is true; otherwise it's not.


I have a doubt. Suppose we assume L as recursively enumerable language then there exists a T.M which halts on all "yes" cases. Here yes cases means strings which belong to either L1 or L2. So, if a string belongs to L2, then the T.M should halt which means that we are able to halt and say "yes" even if string doesn't halt (according to condition of L2). This solves halting problem and hence assumption is not correct and so L should be non recursively enumerable.

You make a basic (but understandable and common) mistake: somebody promises you that an algorithm exists, and you go ahead an assume you know how the algorithm must work: clearly, the algorithm must check if either case happens! No, not if membership in the union can be checked in other, simpler ways.

This misconception is very widespread among novices. My favorite related example is the computability of whether $\pi$ contains $0^k$. Try to understand why that's the case, then revisit this question.


Now, for arbitrary $L_1 \in \mathrm{RE}$ and $L_2 \not\in \mathrm{RE}$ we don't know anything.

  • If $L_1 = \emptyset \in \mathrm{RE}$ we get $L_1 \cup L_2 = L_2 \not\in \mathrm{RE}$.
  • If $L_1 = \Sigma^* \in \mathrm{RE}$ we get $L_1 \cup L_2 = \Sigma^* \in \mathrm{RE}$.

  1. This is certainly possibly: Both the sets of all TMs and the set of all words are countably infinite, so we know there are bijections between either set and $\mathbb{N}$. The bijections can be lifted to pairs, and the result then bijectively maps to any universal language (your choice of alphabet). Of course, nobody outside of recursion theory uses such an encoding; it's unreadable. Then, the hardness of $L_1 \cup L_2$ depends on the specific encoding at hand.
Raphael
  • 73,212
  • 30
  • 182
  • 400