## Theory of Computation turing machine - turing-machines

What are the implications of a non-blank character being over-written by a Turing machine M for the given input variable 'x'?
Intention of the question: I am trying to answer how the halting problem can be made decidable provided we have a TM which can say whether 'M' overwrites a non-blank character by Blank or not?

Remember that at the beginning of the computation, the tape (except for the input) is full of blanks. If the head never overwrites a blank, what do you think would happen?

## Related

### Why is this an invalid Turing machine?

Whilst doing exam revision I am having trouble answering the following question from the book, "An Introduction to the Theory of Computation" by Sipser. Unfortunately there's no solution to this question in the book. Explain why the following is not a legitimate Turing machine. M = { The input is a polynomial p over variables x1, ..., xn Try all possible settings of x1, ..., xn to integer values Evaluate p on all of these settings If any of these settings evaluates to 0, accept; otherwise reject. } This is driving me crazy! I suspect it is because the set of integers is infinite? Does this somehow exceed the alphabet's allowable size?

Although this is quite an informal way of describing a Turing machine, I'd say the problem is one of the following: otherwise reject - i agree with Welbog on that. Since you have a countably infinite set of possible settings, the machine can never know whether a setting on which it evaluates to 0 is still to come, and will loop forever if it doesn't find any - only when such a setting is encountered, the machine may stop. That last statement is useless and will never be true, unless of course you limit the machine to a finite set of integers. The code order: I would read this pseudocode as "first write all possible settings down, then evaluate p on each one" and there's your problem: Again, by having an infinite set of possible settings, not even the first part will ever terminate, because there never is a last setting to write down and continue with the next step. In this case, not even can the machine never say "there is no 0 setting", but it can never even start evaluating to find one. This, too, would be solved by limiting the integer set. Anyway, i don't think the problem is the alphabet's size. You wouldn't use an infinite alphabet since your integers can be written in decimal / binary / etc, and those only use a (very) finite alphabet.

I'm a bit rusty on turing machines, but I believe your reasoning is correct, ie the set of integers is infinite therefore you cannot compute them all. I am not sure how to prove this theoretically though. However, the easiest way to get your head around Turing machines is to remember "Anything a real computer can compute, a Turing machine can also compute.". So, if you can write a program that given a polynomial can solve your 3 questions, you will be able to find a Turing machine which can also do it.

I think the problem is with the very last part: otherwise reject. According to countable set basics, any vector space over a countable set is countable itself. In your case, you have a vector space over the integers of size n, which is countable. So your set of integers is countable and therefore it is possible to try every combination of them. (That is to say without missing any combination.) Also, computing the result of p on a given set of inputs is also possible. And entering an accepting state when p evaluates to 0 is also possible. However, since there is an infinite number of input vectors, you can never reject the input. Therefore no Turing machine can follow all of the rules defined in the question. Without that last rule, it is possible.

### How to design a Turing machine which checks whether a number is prime or not?

I could only make out that the logic must have included the logic of multiplication and division in Turing machines . But actually I cannot make out the exact solution.

Well, if just any old TM will do, this one is easy to understand. input tape is #(n)# use a TM to write this to the tape: #(n):(2):(n)# use a TM to subtract whatever is in between the : from the thing after both : over and over until either (1) you have too few symbols to remove (not divisible) or (2) there are exactly zero symbols left (evenly divisible). In case of (1) continue, otherwise - in case of (2) - halt-reject as not prime. use a TM to write this to the tape: #(n):(m+1):(n)# use a TM to check wither the thing before the first : is greater than the thing in between the two :. If so, continue with step 3. Otherwise, halt-accept (since the original input cannot be divisible by a number greater than itself) Take all the TMs described and construct a single TM that incorporates all that behavior in various states. This is a TM for the language of prime numbers. Assuming a unary encoding (that is, the natural number n is represented by the string 11...1 where 1 is repeated n times), here's some more pointers on making the individual TMs: original input go to the first blank after the input and write a :. Then, go to the right and write 1. Then, go to the right and write another 1. Then go to the right and write another :. Then, bounce back and forth from the beginning to the first blank at the end, copying the input natural number's unary digits. To do this, update the input digits to some other symbol, like A, so you remember ones you already copied. Stop this process when there is an A immediately to the left of the first :. Then, set all the A back to 1. bouncing back and forth, remove a 1 from the rightmost section for each 1 in the innermost section, updating the innermost section to use A to mark them. Once everything in the innermost section is marked, set them back to 1, and repeat the process until you run out of 1s in the rightmost section . erase the second : and everything after it; then write a 1 at the end, then a :, and do what the TM described in 2 does. bounce back and forth between the leftmost and innermost sections, marking in each one as you go. If you run out of symbols in the innermost section first, the number is less than the input number; if you run out at the same time, the numbers are the same, meaning that the input number is first divisible by itself, so it's prime.

### Turing machine that erase its input

I have got this question : Consider a Turing machine Cw which erases its input, writes w on the tape, and halts while scanning the leftmost character of w. Design the Turing machine C011 I need explanation what is actual the question is and what Cw does. I kind of understand it writes empty symbol on every input it gets but the rest is unclear to me. Hope someone can help me understand the question and what is required me to do.

In your case w = 011. Indeed, the TM should first overwrite the entire input. I think we can assume that the input does not have gaps. So as soon as the TM reads an empty space on the input tape, it should begin writing 011. When writing the second 1, enter into a state for which there do not exist any transitions. This way you ensure that the machine halts on that position. Nothing is said explicitely about whether this state should be accepting, but it would make sense to have it as the unique accepting state.

### Turing machine decidability ambiguous cases

1) Is a Turing machine M that accepts the language L = {ε}, accepting no entry? In one hand, I think it can be false because the empty word could be an entry, but in another i think this could possibly be an indecidable problem. 2) Is every Turing machine whose language is decidable stops on any input ? Same idea, intuitively I would have say yes, due to the definition of decidable, but I don't know, something trouble me. 3) Is the language of the palindromes decidable whatever the aphabet ? For this one, I have almost no doubt that it's False, because with Rice's Theorem we can prove that, this probleme is indecidable.

1) I am not sure how to parse this but if a TM accepts the language consisting only of the empty set, it will eventually halt-accept on a blank tape. Whether that counts as an entry or not depends on your definition of "entry". I would count it as an entry, so I would answer "no". 2) The language consisting of only the empty string is decidable. However, we can write a TM that halt-accepts the empty string only and goes into an infinite loop for all other inputs. What is meant by "whose language" is debatable but for TMs that encode partial functions I would call the language of that TM the set of strings which it halt-accepts on, so I would answer "no". 3) It seems to me that, given an alphabet with n symbols, you can always construct a single-tape deterministic TM with O(n) states which halt-accepts on palindromes over that alphabet and halt-rejects other strings, thus deciding the language of palindromes over the alphabet. I would answer "yes", as long as the terms have their usual meanings. Note that Rice's theorem does not apply; it would apply to the problem of deciding whether a TM accepts the language of palindromes over an alphabet, but actually deciding whether something is a palindrome is of course possible (PDAs do it).

### How to convert a DFA to a Turing machine?

Having the diagram of a DFA, how can I convert it to a Turing Machine? Do I have to find the language that the DFA accepts and then create the Turing Machine? Or is there a direct way? Thank you.

Each transition in a DFA reads a character of input, follows a transition, then moves to the next character of input. Once all input has been read, the DFA accepts if it's in an accepting state and rejects otherwise. You can directly simulate this with a Turing machine. Build the finite state control of the Turing machine by creating one state for each state in the DFA. For each transition in the DFA on the character c, replace that transition in the TM with one that, on reading character c, writes back some arbitrary character to the tape (it doesn't matter what) and then moving the tape head right (to the next spot on the tape). Then, for each state, introduce a transition on the blank symbol from that state either to the accept state of the TM or the reject state of the TM (based on whether that state is accepting or rejecting). This TM effectively runs the DFA by stepping manually across the input string and finally deciding whether to accept or reject at the end of the run. Hope this helps!