====== Lab 03 - Turing Machines =======
**Key concepts**
- acceptance vs decision
- complement of a problem
==== 1. Accepting and deciding a decision problem ====
**1.1** Can the problem $math[f(w) = 0] (for all w in $math[\Sigma^*]) be accepted by a Turing Machine?
**1.2** Can a problem be accepted by two different Turing Machines?
**1.3** Can a Turing Machine accept two different problems?
**1.4** Write a Turing Machine which accepts the problem $math[f(x) = 1] iff x (encoded as binary word) is odd, but does **NOT** decide it.
**1.5** Which of the following problems you think can be accepted and which can be decided? Use pseudocode instead of writing a TM.
**Diophantine equations (Hilbert's Tenth Problem)**
* A //diophantine// equation is a polynomial equation where only **integer solutions** are sought.
* Examples:
* $math[x^2+y^2=1]
* $math[x^4+y^4+z^4=w^4]
* $math[3x^2-2xy-y^2z-7=0]
* The decision problem we are interested in is: //Given a diophantine equation, does it have at least one solution//?
**Linear Integer Programming**
* You are given a set of arithmetic **constraints** over integers, and try to find if a solution to the constraints exists.
* Example:
* $math[y-x\leq 1]
* $math[3x+2y\leq 12]
* $math[2x+3y\leq 12]
**Wang Tiles**
* Wang tiles are squares where each **side** has a specific color. An example is given below.
{{ :aa:lab:wang_11_tiles.svg.png?200 |}}
* Wang tiles can be used to tile surfaces, but each tile must be placed such that adjacent tiles have the **same color side**.
* The wang tiling decision problem is: //Is it possible to tile the plane (an infinite surface) with a given set of tiles//?
**k-color**
* You are given a undirected graph and a number of ''k'' colors. Is it possible to assign a color to each node such that **no adjacent** (connected by an edge) nodes have the same color?
==== 2. Complement ====
**2.1** What is the complement of the problem from Exercise 1.1 ?
**2.2** What is the complement of k Vertex Cover?
**2.3** If a problem is decided by some TM, can its complement be decided?
**2.4** If a problem is accepted by some TM, can its complement be accepted?
==== 3. Turing Machine pseudocode ====
**3.1** Write a TM pseudocode which:
* takes a TM encoding enc(M)
* accepts if there exists a word which is accepted by M, in k steps
Suppose M is encoded on binary words, and also working on binary words, for simplicity.
/* Solution:
Pseudocode(M): <- input
- divide the tape on three sections:
- [word][value i][value k in binary][enc(M)]
- set the w=[word] section to "0", set the [value i] section to 0 in binary
- simulate w on M. After each transition, increment i and perform following checks
- if M accepts (crt state of M is final), go to final state
- if i == k:
"increment" the current word w. E.g. "0010" may be incremented as "0011" this is the "next" binary word
set i = 0
repeat the same process all over
*/
**3.2** Which of the following pseudocode is a proper Turing Machine? Explain why.
Algoritm(M,w){
if size(w) > 10
then if M accepts w in k steps
accept.
}
Algoritm(M1,M2,w){
k = 0
while true
if M1 accepts w <=(iff)=> M2 accepts w , in k steps
then accept
else k = k + 1
}
Algorithm(M,A) {
// A is a finite set of words
for each w in A
if M(w) accepts
then accept
}
Algorithm(M) {
if M accepts all words w in Sigma*
accept
}
Algorithm(M1,M2) {
if M1 always accepts then
if M2 always accepts then
accept
}
**3.4** Write a TM pseudocode which:
* takes two TMs as input
* accepts if there exists a word which is accepted by both TMs
**3.5** Write a TM pseudocode which:
* takes a word as input
* accepts if there exists a TM which accepts the word
**3.6** Write a TM pseudocode which:
* takes a Turing Machine M, and a finite set of words A
* checks if all words in A are accepted by M
**3.7** Write a TM pseudocode which:
* takes a Turing Machine M, and a finite set of words A
* checks if some words in A are accepted by M