## Turing Machine Blank Symbol After Halting - turing-machines

### Determining whether the following language is decidable

```{⟨M,N⟩ | All strings in L(M)∩L(N) begin with 110.}
I think that this language is decidable. We can make a Turing Machine TM, which takes as input . For every string that is in L(M)∩L(N), if the string starts with 110, after the first 3 digits, we halt and accept. If the first three digits are not 110, we halt and reject. I am unsure what we do if the string is not in L(M)∩L(N).
Also overall I am unsure if my Turing Machine is actually working or not. Could I get some feedback on this?
```
`If M and N are Turing machines, then this language is not decidable. If it were, we could make N a TM that accepts all strings, and then we'd have a decider for {M | all strings in M begin with 110}. We can recognize this is not decidable since the condition is true for some TMs, false for others, and it's semantic in that it deals with the strings in the language; so Rice's theorem applies.`

### Proving a decision is undecidable

```I understand that HP is an undecidable problem because of the diagonalization argument.
In my book (kozen) the first example of a reduction to the halting problem is a machine that can decide whether or not the empty string ε is accepted.
from my book:
Suppose we could decide whether e. given machine a.ccepts E. We could then
decide the halting problem as folIows. Say we are given a Turing machine
M and string x, and we wish to determine whether M halts on X. Construct
from M and x a new machine M' that does the following on input y:
(i) erases its input y;
(ii) writes x on its tape (M' has x hard-wired in its finite control);
(iii) runs M on input x (M' also has a description of M hard-wired in its
finite control);
(iv) accepts if M halts on X.
Here already, numerous questions come to my mind. M' is not based (as far as the text tells at least) on the actual machine that decides whether ε is accepted or not.
Why do we erase the input y? Is x in M' arbitrary? And the biggest confusion comes from my question: Why can't I prove any decision problem this way: Make a machine M' that erases its input, writes x on the tape, runs M on the input x and accepts if M halts on x?
I'm trying to understand the relation between the decider for a machine to accept ε and the TM given by the book, but I can't seem to understand it, neither can my fellow students.
```
```Erasing the input is just to show that it is irrelevant. You could as well leave it there and write behind it.
x in M' is not arbitrary but "M' has x hard-wired in its finite control" for deciding the problem "given a Turing machine M and string x, and we wish to determine whether M halts on x."
The new machine always does the same independent of its input. Therefore, it either accepts ALL inputs or NONE. So it accepts the empty string IFF M accepts x. It is important to note that we are talking about only one computation of M but all the computations of M'.```

### Turing machine for palindrome

```Describe TM with one tape and two tape, which decide language сonsisting of palindrome (words have only '1' and '0' symbols). Estimate time of work each TM.
```
```One tape:
Read first symbol and move to state A if 0 or state B if 1. Replace with a blank. Move right to the end of the tape (first blank symbol). Move left one symbol. If this symbol is a 0 and you are in state A, or if it is 1 and you are in state B, make it a blank and return all the way to the left until you find a blank symbol, and then move one right. Otherwise, the word is not a palindrome and you halt-reject. Continue in this manner until you halt-reject or all symbols on the tape have been replaced with blanks, in which case you halt-accept. This will take roughly (n+1) + n + ... + 1 ~ O(n^2) moves.
Two tapes:
Move the tape head of the input tape to the end, and then read backwards to the start of the input tape. As you go, write the tape symbols in order on the second tape so that you end up with the reverse of the input tape on the second tape. Reset both tape heads, and then move each to the end of the tape, at each step comparing the symbols each head is pointing to. If you find a position where the symbols are different, the input is not a palindrome and you halt-reject. If you get to the end (first blank symbol on the end) without finding a mismatch then it is a palindrome and you halt-accept.```

### Turing Machine with non trivial states and transitions

```Please give me some idea as to how to go about this
Draw a Turing machine (using Sipser notation) having at least 4 nontrivial (i.e., nonrejecting) states and at least six nontrivial (i.e., not to the rejecting state) transitions.
```
```A Turing machine has:
A finite number of states, of which one is accepting and one is rejecting. The task apparently requires five states (four nonrejecting (of which one must be accepting) and one rejecting). The states are usually drawn as circles, with a label (the state name) inside each. One of the states is the starting state; it is marked with an arrow pointing at it.
A finite input alphabet. {0, 1} or {a, b} are typical choices.
A finite tape alphabet, which includes a special blank symbol, all symbols from the input alphabet, and possibly more symbols (but this is not required).
A transition function which assigns a state, a tape symbol and a direction to each combination of a state and a tape symbol. The direction can be L (left) or R (right). A transition is drawn as an arrow from one state to another (or possibly a circular arrow from a state back to itself), and the arrow is labelled with two tape symbols and either L or R. Apparently, you need six such arrows.
The machine also has an infinite tape that is divided into cells. In each cell, there can be a symbol from the tape alphabet. The symbols that initially are on the tape are called the input to the machine. The machine has a read head that is always located over one of the cells. Let's say you have a transition arrow from state A to state B, with the symbols a, b, and R on it. That means: "If the machine is in state A and the symbol under the tape head is a, then we should replace that symbol with b, go to state B, and move the read head one cell to the right."```

### Can a Turing machine be constructed having only two tape symbols?

```A Turing machine M containing any number of tape symbols can be simulated by one M' containing just three tape symbols: {0, 1, B} (B = Blank).
Can M be be simulated by a M" that has just two tape symbols, say {1, B}?
```
```The first step - getting from any TM to a TM with just ones and zeros - is not as hard as you might think but not as easy as what everyone else is saying. The idea is to develop a fixed-length binary encoding for each of the symbols in the alphabet. You then update the finite-state control so that at each step the TM scans the appropriate number of bits, decides which way to move and which symbol to write, writes the binary representation of the new symbol, and repeats. This can be done by having a HUGE finite-state control, and I'll leave the details to the reader since it's really pedantic to go over how it works. :-). The one detail to note is that in this construction you represent the blank symbol as a sequence of blanks with the same length as the binary symbols you invented.
To implement a TM using just 1 and B you use a similar trick. First, reduce the TM to use just 1, 0, and B. We'll again reduce the symbol set by a smaller one, but will have to be a bit more clever with how we do so because the tape has infinitely many blanks on it. We will use the following encoding:
11 encodes the number 1
1B encodes the number 0
BB encodes a blank.
As we run the TM using this encoding scheme, if we ever walk past the end of the previously-visited tape, we will encounter infinitely many blank symbols, which fortunately correspond to our encoding of the blank symbol.
The only challenge is how to encode the input to this new TM so that we can convert it to this above format. Since blanks can't appear in the TM input, the input must be encoded in unary. We then stipulate that for any binary string w of the old machine, the input to the new machine should be the unary encoding of the number 1w. We then have the first step of the machine be to convert from the unary encoding to the above binary encoding. This can be done with just two symbols, but the details are really hard and again I'm going to punt on them. You can work out the details if you want.
Hope this helps!
```
```The first one is easy, think of a computer, binary....
In the first one you can encode each symbol into a 0,1 representation.
In the second one, you can do 2 things:
Think of the B as 0 ... it doesn't matter what you call it... and then you have a 0,1 machine and can encode whatever you want.
Encode the symbols as a series of ones, separated by a B. The N'th symbol will hold N 1's```