Open In App

Dovetailing in Turing Machines

Last Updated : 08 Oct, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

In the carpentry industry, dovetailing is a technique of joining two pieces of wood together by interleaving them. Similarly in the case of Turing Machines dovetailing is the technique by which we can simulate multiple Turing Machines, in some cases an infinite number of Turing Machines together.

This technique can be very useful in determining the decidability and recognizability of some Turing Machines or languages related to Turing Machines.

Dovetailing in Turing Machines

Let us consider an example where we are given two strings w1, w2 ∈ Σ* and

a Turing Machine M. It is also given that M accepts exactly one of w1,w2. The task is to determine which of the given strings w1, and w2 is accepted by M.

Now consider the following algorithm that can be used :

Algorithm 1

  • Run M on w1. If it halts and accepts, w1 is the string accepted by M.
  • If M rejects w1, w2 is the string accepted by M(as it is given that M accepts exactly one of w1,w2)

However, there is a problem with this algorithm. What if M never halts on w1 and keeps running forever? we would never know if it will halt in the future or not and we will not be able to determine which of the given strings w1, and w2 is accepted by M. Some interleaving technique can solve the problem. Let’s consider Algorithm 2.

Algorithm 2

  • Run M on w1 for k transitions(k is a finite constant).
  • Run M on w2 for k transitions.
  • If one of them halts and accepts then stop.
  • Otherwise keep repeating the above steps.

Now as it is given in the question M accepts exactly one of w1,w2. After a finite amount of time M will halt and accept either of them and we will be able to know which one. But Algorithm 2 only works if limited number of strings are given like w1 and w2 here. The idea of dovetailing comes when we have an infinite number of strings.

Dovetailing

Let us consider another example where we are given a Turing Machine M. It is also given that M accepts at least one string from Σ*. The task is to determine which string is accepted by M.

Any of the above algorithms will not work in this case. We have to simulate M in the following way:

  • Arrange all the strings of Σ* in lexicographical order.
  • Iteration 1(T1 in the image) : Take out one string w1 from Σ*, run M on w1 for 1 step
  • Iteration 2(T2 in the image): Take out another string w2 from Σ*, run M on w2 for 2 steps, and run M on w1 for 1 more step.
  • Iteration 3(T3 in the image): Take out another string w3 from Σ*, run M on w3 for 3 steps, run M on w1 for 1 more step, and run M on w2 for 1 more step.
  • …..
  • …..
  • Iteration n: Take out a string w(n) from Σ*, run M on w(n) for n steps, and run M from w1 to w(n-1) for 1 step each.
Visualization of dovetailing through image

Visualization of dovetailing through image

By interleaving all the inputs in this way we will be able to determine the only string from Σ* that is accepted by M in a finite amount of time. This special type of interleaving technique is known as dovetailing.

Identification of Language Class Using Dovetailing

The method of dovetailing can be beneficial in identifying a given language class. Let us consider the following language L = {<M> | M is a Turing machine and M accepts at least one string from Σ*} using the above example of dovetailing we know that M always halts so the Turing Machine for L will also stop for all of its member strings. In the case of the non-members M may or may not halt. So L is recognizable but not decidable, so L is a Recursively Enumerable language.

Conclusion

In short, dovetailing is just the technique of simulating infinitely many Turing machines to recognize a specific language or a string. This technique can be very useful while identifying the class of the language accepted by a Turing machine and with this knowledge method, you don’t have to memorize the decidability and recognizability table. It will become easier to check if a specific Turing Machine is decidable or recognizable as this method works as the intuition behind various decidability and recognizability proofs.


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads