# Lecture 15

## Definitions

**Definition** The (worst-case) running time of a single-tape TM \(M\) is the function \(t:\mathbb{N}\rightarrow\mathbb{N}\cup\infty\) where \(t(n)\) is the maximum number of transitions followed by \(M\) before halting over all inputs of length \(n\).

**Definition** The class of languages \(TIME(t(n))\) for some function \(t:\mathbb{N}\rightarrow\mathbb{N}\) is the set of languages \(L\) such that there exist a single-tape TM \(M\) with running time \(O(t(n))\) that decides \(L\).

## Some Examples

### Regular Language

**Theorem** If \(L\) is regular, then \(L\in TIME(n)\)

**Proof** From any DFA that recognizes \(L\), we can build a corresponding single-tape TM that halts after \(n+1\) transitions

### \(L=\{0^k1^k:k\geq 0\}\)

**Theorem** If \(L=\{0^k1^k:k\geq 0\}\) is in \(TIME(n^2)\)

**Proof** TM needs \(\frac{n}{2}\) transitions to skip \(0\)s and check the corresponding \(1\).

**Proof Sketch** Erase every second \(0\) and \(1\), check parities. Each pass takes \(O(n)\) transitions. There are \(O(\log n)\) passes.

**Theorem** Any single-tape TM that decides \(L\) has running time \(\Omega (n\log n)\)

**Proof** Bonus

**Theorem** there is a 2-tape TM that decides \(L\) in time \(O(n)\).

**Proof** Use the second tape as a stack.

**Corollary** \(TIME(t(n))\neq TIME^{multi}(t(n))\)

**Theorem** For every language \(L\) that can be decided by \(k\)-tape TM with running time \(t(n)\) , there is a \(2-tape\) \(TM\) with running time \(O(t(n)\log(t(n)))\).

### Palindrome

**Theorem** The language \(PAL=\{xx^R:x\in\{0,1\}^*\}\) can be decided by \(2\)-tape TM with running time \(O(n)\) but every \(1\)-tape TM that decides \(PAL\) has running time \(\Omega(n^2)\).

## Linear Speedup Theorem

**Theorem** For any constant \(c>0\), if there is a multi-tape TM \(M\) that decides \(L\) in time \(t(n)\), there is also a multi-tape TM \(M'\) that decides \(L\) in time \(ct(n)+2n\).

**Question** Is \(TIME^{multi}(t(n))=TIME^{multi}(n)\) for every \(t:\mathbb{N}\rightarrow\mathbb{N}\)? No

### Weak Linear Speedup Theorem

If there is a single-tape TM \(M\) that decides \(L\) in time \(t(n)\), there is a \(2-tape\) TM \(M'\) that decides \(L\) in time \(\frac{1}{2}t(n)+2n\).

**Proof** We can choose \(\Gamma'=\Gamma^3\)

\[(x_1,x_2,x_3),(x_3,x_4,x_5),...\]

Compressing the input takes time \(n\) and going back to then beginning take time \(\frac{n}{2}\).

Compressing all the transistions of \(M\) within a single window into \(1\) transition means \(M'\) makes at most \(\frac{1}{2}t(n)\) extra transitions.