## Practice Problems for Exam 1

### Turing Machines

- Implement a Turing machine that, given an input number n in binary
representation, increments n by 1.

- Implement a Turing machine that decides the language
L = {ww^R | w belongs to Sigma*},
where w^R denotes "the reverse of w", and Sigma is an alphabet.

- Consider a variant version of Turing machines that can insert and
delete characters in and from their inputs.
- Give a formal definition of these Insert-Delete Turing Machine
"IDTM".
- Show that IDTMs are equivalent to TMs. That is, IDTMs and TMs can
simulate each other.

- Construct the state diagram with transitions of a Turing machine that,
given an input number n in binary representation, accepts n iff n is odd.

- Implement a Turing machine that, given an input number n in binary
representation, multiplies the number by 2.

### Decidable and Semi-decidable Languages

- Let L be a decidable language. Show that there are infinitely many different
Turing machines that decide L.

- Show that FINITEcfg = {< A > | A is a CFG and L(A) is finite} is decidable.

- Show that INFINITEcfg = {< A > | A is a CFG and L(A) is infinite} is decidable.

- Show that MAQtm = {< M > | M is a TM} is decidable. That is, show that there
is a TM K that accepts an input number n if n encodes a TM; and rejects n
otherwise.

- Show that, if a language L is semi-decidable, then there is an enumerator M
that enumerates L without ever repeating an element of L.

- Show that a language L is recursive iff there is a TM M that enumerates L in such
a way that the strings in L are output by M in length-increasing fashion.

### Undecidable Languages

- Show that ALLcfg = {< A > | A is a CFG and L(A) = Sigma*} is undecidable.

- Show that INTERSECTIONcfg = {< A,B > | A and B are CFG's and the intersection
of L(A)
and L(B) is empty} is undecidable.

### Countable vs. Uncountable Sets

- Show that the set MAQtm = {< M > | M is a TM} is countable.
- Let Sigma be an alphabet. Show that the set of languages over the alphabet Sigma
is uncountable.

### Primitive and MU Recursive Functions

Show that the following functions are PRIMITIVE recursive:
- DIV(n,m) := "k, where k is the integer quotient of n divided by m."
- SUMg(n) := "g(0) + g(1) + ... + g(n)", where g is primitive recursive.
- PRODg(n) := "g(0) * g(1) * ... * g(n)", where g is primitive recursive.