## Turing machine that accepts another turing machine if it makes a certain move - turing-machines

Is it possible to build a turing-machine that has another turing-machine and a string as input and accepts if the received machine would make a left or right (or anything) move for that string?

No. Creating such a machine requires solving the halting problem. To show this, assume your input is Turing machine T, and I pass it through another machine that modifies every halt instruction with turn left followed by halt. I then feed this new machine, T' into your candidate machine. In order for your machine to correctly detect whether T' will turn left, it must solve the halting problem.

## Related

### Universal Turing Machine Problems

If I have a machine, call it machine 1, that is able to solve a problem: it's just a machine, not per se a Turing machine. It can solve one specific problem. If this exact same problem can be solved on a Universal Turing Machine, then is my original machine, 1, a Universal Turing Machine too? This does not hold for all problems, which is already ansered. Are there any problems which have this described property at all? If it is absolutely not true, then why? Can someone give an example of a problem to be solved. If this problem is solved by my original machine, 1, definately makes this a Universal Turning Machine? Or does such a problem not exists? If it doesn't exists, why? I'm very interested, but can't figure it out... Thanks. Edit: made the question more clear.

The point of the Universal Turning Machine (UTM) is that for any Turing Machine (TM) you could take that TM and create an encoding for it that describes the operation of the TM and have that encoding run on another TM. The UTM is a TM which has an definition sufficiently powerful such that any other TM definition could be rewritten in it. Think of the UTM as an interpreter. The TM is a specific task. Unless the TM is also in the class of interpreters then it is not a UTM as well. (Because a UTM is also a specifically tasked TM). So to answer your second question: if you can show that the UTM and TM are equivalent then you have shown that TM is also a UTM. To do this you need to be able to show how an encoded program for the UTM can be changed into an equivalent program for the TM.

A Universal Turing Machine can solve any of a huge class of problems. If your machine(1) can solve 1+1, that doesn't mean it can solve any of the huge class. So it may not be a Universal Turing Machine.

The logicians differentiate between "sufficient" and "neccessary" conditions. Take, for example, the sentence The sky is blue. (let's just assume that's always true). What you know now is this: When you look at the sky, you see the color blue. What you don't know is this: When you see the color blue, you're looking at the sky. -- you might as well be looking at your neighbour's car. In logical terms, the color blue is neccessary for the sky, but it's not sufficient. The same is true for your case: Machine (1) does solve your problem, so it's indeed a solvable problem. Hence, being able to solve the problem is a neccessary condition for a UTM, but not a sufficient one, because a UTM must be able to solve any problem (that's solvable at all), not just this single one.

A universal turing machine can solve any code that any specific turing machine can solve. So your universal turing machine (2) can solve the problem that your original turing machine (1) was designed to solve. Your original turing machine (1) however can solve only that exact problem and can't solve any other problem (including the "problem" of being a universal turing machine). So no, your original turing machine is not a universal turing machine according to your description. (It might be if the you define it to, but that's kind of cheating).

Can someone give an example of a problem to be solved. Sure: Given encoded turning machine and data, what is the result :) If your machine can solve this problem, it is surely UTM. Do you know the line of reasoning why those different problems are in NP? Like 'can i solve the 3-sat problem when I have a machine that solves the Hamiltonian problem?' You can surely use the same to answer your question.

Proving the Turing completeness of a particular system is not trivial, unless you can easily show that it's equivalent/isomorphic to another system that is know to be Turing complete. So short answer: there is no simple test that you can put your machine through to check whether it is Turing complete. You have to analyze and show properties of the system as a whole. If you want to learn more about this topic, read these articles about Turing completeness and computability theory.

Imagine a UTM as if how would you proceed if you have to write a code(High level) for simulating the turing machine.You will require the following: 1.Array to hold the input symbols and the stuff that yiu would do on it. 2.An array(possible 2-d) to hold the transition function that you will prompt the user. 3.An algorithm that read user's inputs of transition functions and simulates it on array 1. 4.Few variables that your program will need to track its own state. If you think in this way,if you end up getting a perfectly working code you end up with a perfect UTM. However the catch is no matter how efficiently you code you can't stop the user from entering transition functions that can cause your code to run forever.So there will be certain problems for which UTM will fail,and then we say that for those problems we can't develop a membership testing machine.(though notice a membership verification machine is always possible)

### Given the encoding of a specific Turing machine, can it be decided if it will halt on a specific input?

Say I have the Universal Turing Machine encoding of a specific Turing machine T. Also say I have the encoding of a specific input s. Is the question of whether T halts on s decidable? Can simulating running T on s be used to reach an answer?

This problem is decidable in all instances. Any specific, fixed TM either halts or doesn't on any specific, fixed input, assuming for the moment that the excluded middle is not something you want to challenge here. For a specific instance of your problem where you are fixing the TM and input, the TM should either halt-accept for all inputs (not the specific, fixed input with which you are parameterizing the problem, but the typical input to the TM which will solve our parameterized problem) if that specific instance if the problem has a TM halting on the supplied input, or it should halt-reject if that specific instance has a TM that fails to halt. The difficulty is that for any specific instance of the problem, we know that the specific TM either halts or doesn't given the specific input, but we don't have any computationally effective way to know which is the case. Certainly one or the other is (again, whether you accept the excluded middle is a larger discussion) and therefore the specific instance of the problem is decidable - regular, even - but that doesn't help us too much, except to understand computability a little better. Note that there are lots of instances of this problem where we could know which of the two cases holds; for instance, it is not hard to produce TMs which halt, or fail to halt, on any or all inputs. Those instances of the problem are not only decidable and regular, but we know which decidable/regular languages they are.

### How to convert a CFG to a Turing Machine

How do I convert a CFG to a TM? I have a basic idea of how to convert a DFA to a TM, but I can't think of a way to do this one properly. Can I get some general implementation steps on this?

Construct a pushdown automata (PDA) using a standard algorithm. I won't go into details of any particular construction (a separate question would be a better place to cover that) but you can search "convert cfg to pda" and get results. One example is here. Construct a two-tape Turing Machine from the PDA as follows: The Turing machine reads the input tape (tape #1) left to right The Turing machine uses the second tape as the stack, moving right when pushing and left when popping. Construct a vanilla one-tape Turing Machine from the two-tape machine using a standard construction. The proof that one-tape and two-tape TMs are equivalent is a constructive proof and you can follow the implied algorithm to show construct a single-tape TM for the language of your CFG.

Every produced word of the CFG can be written as a parse tree. If you get a string produced by the CFG these are the leafs of your parse tree. To determine whether the string is produced by the CFG you simply go from the leaves to inner nodes till the root. So the general idea is to turn around the production rules. If you can reach the root, then the string is part of the grammar. If you are at a point, where no turned production rule fits, then the word is not produced by the CFG. Note that if there are more than one possibilities you need to try all possibilities and if one works, the string is produced by the CFG. If none works, it is not.

### Universal turing machine U should determine if M(x) stops

so we have a universal turing machine U, that should determine if a turing machine M with input x will stop. The solution should be presented in pseudo code. can someone help me a bit out, who should i solve it ?

This sounds like the halting problem: The halting problem can be stated as follows: "Given a description of an arbitrary computer program, decide whether the program finishes running or continues to run forever". This is equivalent to the problem of deciding, given a program and an input, whether the program will eventually halt when run with that input, or will run forever. Alan Turing proved in 1936 that a general algorithm to solve the halting problem for all possible program-input pairs cannot exist. A key part of the proof was a mathematical definition of a computer and program, what became known as a Turing machine; the halting problem is undecidable over Turing machines. So no, it's not possible. If you want, you can probably run M on x for a while. If it stops, we know it stops. If it doesn't stop, we don't really know whether or not it stops.

### DPDA to Turing Machine?

Is there a way to convert a deterministic pushdown automata into a turing machine? I thought about putting the stack after the input on the tape, with '#' between them. But it seems kind of impossible to prove it formally. Do you have any suggestions? Did somebody do it already? Thank you

Push-down automaton works only in one direction. That is it cannot retrace its step or keep a count. For example, if you want a formal language: L = {1^n+0^m | n>m, m>0} Here the no. of 1's are greater than no. of zeroes. This problem is solvable by both DPDA and Turing Machine. However if we add another condition, like: L = {1^n.0^m.1^n | n>m, m>0} Assuming that you know how to solve the above problem in Turing Machine, you would understand its not possible to solve it without back tracing the input tape. Therefore there is no way you can make PDA as powerful as Turing Machine. Here is link to Wiki for your more understanding :https://en.wikipedia.org/wiki/Chomsky_hierarchy