## Why does a Turing machine take n^k steps for computing an input? - turing-machines

### How to compute a turing machine program to subtract x-y,where x and y are natural numbers

```I need a program for a turing machine that subtracts x-y that are both natural numbers, starting with q0. How does that work?
This is for automata. It needs to start with q0 and qAccept```

### Is this language decidable

```L={(〈M1〉,〈M2〉, x)|M1(x) runs for strictly more steps than M2(x) does.
If both computations run forever, then neither takes strictly more steps than the other.
Is this language decidable or not? How to prove it?
```
```As templatetypedef hints in the comment, this language is undecidable. If it were decidable, you could decide the halting problem as follows.
First, let M1 be any TM that fails to halt on input x. Such a TM might be a trivial one with two states that moves left and right and doesn't change the tape. Let M2 be any TM. A decider for your language now lets us answer the question "does M2 halt for all inputs", which is equivalent to the halting problem. You can also let M2 be a TM that first confirms any particular input w is on the tape, and then continues according to some TM M3. This would change the problem to "does M3 halt on input w", which is maybe the more canonical version of the problem.```

### What does a Turing machine do when it reaches the end of it's input?

```If a Turing Machine has an input tape of 01011, for example, what happens if you reach the end of that sequence without reaching any resolution within the Turing Machine?
```
`The tape is infinite, the input does not only consist of 5 cells. To the left and right, the tape is blank (i.e. filled with 0, or possibly some other symbol if you have more than two). There is no "end of the sequence", the turing machine will continue running its program until it halts (which might be never).`

### Is this language decidable, recognizable, or unrecognizable?

```The language L that consists of all Turing Machine descriptions M, for which the language accepted by M is finite.
I said L is a decidable language because I can just run M on a function D(M) that returns false if there exists a loop somewhere between start and accept state of M, and returns true otherwise.
I have a feeling that I am wrong because I am underestimating the difficulty of detecting an infinite loop.
Assistance is appreciated, thank you in advance.
```
```If you could decide this language, you could decide the halting problem.
Suppose M is a machine and x is its input. The halting problem is to say whether or not M halts on x. Consider a machine N that clears the tape and writes x in place of whatever input was there before. Now consider the machine obtained by running N and then running M. This machine accepts all inputs if M accepts x, and no inputs otherwise. If you could say for any machine whether the language accepted is finite, you'd be able to say whether M halts on x or not. But that was the halting problem.```

### Turing Machines and Machine Schemas

```Arthur Dent, using space age technology not yet available on earth developed an algorithm which determines if a TM M1 halts or not when started on a blank tape. But then later, he discovered that the meaning to life, the universe, and everything is 42.
(a)  Given a TM M2, prove that Arthur can determine if M2 halts or not on the input 42 using the program he already developed which determines if a TM M1 halts or not when started on a blank tape. If you create a new TM in your proof, give its machine schema.
(b)  Suppose there is a program which is faster than Arthur's but it answers the question of whether a TM M2 halts on input 42. Explain how Arthur can use this algorithm to determine if some TM M1 halts when started on a blank tape. If you create a new TM in your proof, give its machine schema.
(c)  We proved in class that that the problem of determining if a TM M halts when started on a blank tape is not decidable. Is it part (a) or part (b) which can be used to prove that it is also undecidable to determine if a TM M halts on input 42?
Can anyone help me decipher what my prof is talking about here?
```
```Welcome to some really complicated computer science theory. Try starting here: http://en.wikipedia.org/wiki/Halting_problem
Google Turing Machine as well if you're not familiar with that.```