Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
aa:intro:computability_theory [2016/07/21 22:39]
malex
aa:intro:computability_theory [2016/08/01 16:36] (current)
malex [1.4.6. Proposition]
Line 142: Line 142:
   * $math[s_0\in K] //is an //initial state//​.// ​   * $math[s_0\in K] //is an //initial state//​.// ​
  
-The Turing Machine has a tape which contains infinite cells in both directions, and on each tape cell we have a symbol from $math[\Sigma]. The Turing Machine +//The Turing Machine has a tape which contains infinite cells in both directions, and on each tape cell we have a symbol from $math[\Sigma]. The Turing Machine has a// tape head//, which is able to read the symbol from the current cell. Also, the Turing Machine is always in a given state. Initially (before the machine has started) the state is $math[s_0]. From a given state $math[s], the Turing Machine reads the symbol ​$math[cfrom the current cell, and performs a// transition//​. The transition is given by $math[\delta(s,​ c) = (s^\prime ​, c^\prime ​, pos)]. Performing the transition means that the $math[TMmoves from state $math[s] to $math[s^\prime] , overrides the symbol $math[c] with $math[c^\prime] on the tape cell and: (i) if $math[pos = Lmoves the tape head on the next cell to the left, (ii) if $math[pos = Rmoves the tape head on the next cell to the right and (iii) $math[pos = Hleaves tape head on the current cell.//
-has// tape head//, which is able to read the symbol from the current cell. Also, +
-the Turing Machine is always in a given state. Initially (before the machine +
-has started) the state is $math[s_0]. From a given state s, the Turing Machine reads +
-the symbol c from the current cell, and performs a// transition//​. The transition +
-is given by $math[\delta(s,​ c) = (s^, c^, pos)]. Performing the transition means that the +
-TM moves from state $math[s] to $math[s^,] , overrides the symbol $math[c] with $math[c^,] on the tape cell +
-and: (i) if pos = L moves the tape head on the next cell to the left, (ii) if +
-pos = R moves the tape head on the next cell to the right and (iii) pos = H +
-leaves tape head on the current cell.+
  
-The Turing Machine will perform transitions according to $math[\delta].+//The Turing Machine will perform transitions according to $math[\delta].//
  
-Whenever the TM reaches an accepting/​final state, we say it// halts//. If +//Whenever the TM reaches an accepting/​final state, we say it// halts//. If 
-a TM reaches a non-accepting state where no other transitions are possible, +$math[TMreaches a non-accepting state where no other transitions are possible, we say it// clings/​hangs//​.//
-we say it// clings/​hangs//​.+
  
-  * the //input// of a Turing Machine is a finite word which is contained in its otherwise empty tape; +  * //the //input// of a Turing Machine is a finite word which is contained in its otherwise empty tape;// 
-  * the //output// of a TM is the contents of the tape (not including empty cells) after the Machine has halted. We also write $math[M(w)] to refer to the output of $math[M], given input $math[w].+  * //the //output// of a $math[TMis the contents of the tape (not including empty cells) after the Machine has halted. We also write $math[M(w)] to refer to the output of $math[M], given input $math[w].//
 $end $end
  
Line 166: Line 156:
  
 $example[Turing Machine] $example[Turing Machine]
-Consider the alphabet $math[\Sigma = \{\#, >, 0, 1\}], the set of states $math[K = \{s_0, s_1, s_2\}], the set of final states $math[F = \{s_2\}] and the transition function:+//Consider the alphabet $math[\Sigma = \{\#, >, 0, 1\}], the set of states $math[K = \{s_0, s_1, s_2\}], the set of final states $math[F = \{s_2\}] and the transition function://
  
-$math[\delta(s_0,​ 0) = (s_0, 0 ,R)     ​\delta(s_0, 1) = (s_0, 1, R)]+$math[\delta(s_0,​ 0) = (s_0, 0 ,R) \quad \quad \delta(s_0, 1) = (s_0, 1, R)]
  
-$math[\delta(s_0,​ \#) = (s_1, \# ,L)     ​\delta(s_1, 1) = (s_1, 0, L)]+$math[\delta(s_0,​ \#) = (s_1, \# ,L) \quad \quad \delta(s_1, 1) = (s_1, 0, L)]
  
-$math[\delta(s_1,​ 0) = (s_2, 1 ,H)     ​\delta(s_1, >) = (s_2, 1, H)]+$math[\delta(s_1,​ 0) = (s_2, 1 ,H) \quad \quad \delta(s_1, >) = (s_2, 1, H)]
  
-The Turing Machine $math[M = (K, F, \Sigma, \delta, s_0)] reads a number encoded in binary +//The Turing Machine $math[M = (K, F, \Sigma, \delta, s_0)] reads a number encoded in binary on the tape, and increments it by $math[1]. The symbol $math[\#] encodes the empty cell tape //(We shall use $math[\#] to refer to the empty cell, throught the text)//. Initially, the tape head is positioned at the most significant bit of the number. The Machine first goes over all bits, from left to right. When the first empty cell is detected, the machine goes into state $math[s_1], and starts flipping ​$math[1]s ​to $math[0]s, until the first $math[0(or the initial position, marked by $math[>​]) is detected. Finally, the machine places ​$math[1on this current cell, and enters it’s final state.//
-on the tape, and increments it by 1. The symbol $math[\#] encodes the empty cell +
-tape (We shall use $math[\#] to refer to the empty cell, throught the text). +
-Initially, the tape head is positioned at the most significant bit of the +
-number. The Machine first goes over all bits, from left to right. When the +
-first empty cell is detected, the machine goes into state $math[s_1], and starts flipping +
-1s to 0s, until the first 0 (or the initial position, marked by $math[>​]) is detected. +
-Finally, the machine places 1 on this current cell, and enters it’s final state.+
  
 {{ :​aa:​intro:​aafigura_2.3.1.jpg?​nolink&​400 |}} {{ :​aa:​intro:​aafigura_2.3.1.jpg?​nolink&​400 |}}
  
-The behaviour of the transition function can be more intuitively represented +//The behaviour of the transition function can be more intuitively represented 
-as in the figure above. Each node represents a state, and each edge, a transition. ​ +as in the figure above. Each node represents a state, and each edge, a transition. The label on each edge is of the form $math[c/c^\prime,pos] where $math[c] is the symbol read from the current tape cell, $math[c^\prime] is the symbol written on the current tape cell and $math[pos] is a tape head position. The label should be read as: //the machine replaces $math[c] with $math[c^\prime] on the current cell tape and moves in the direction indicated by $math[pos]//​.//
-The label on each edge is of the form $math[c/c^,,pos] where $math[c] is the symbol read from the current tape cell, $math[c^,] is the symbol written on the current tape cell and $math[pos] is a tape head position. The +
-label should be read as: //the machine replaces $math[c] with $math[c^,] on the current cell tape and moves in +
-the direction indicated by $math[pos]//​.+
  
-Let us consider that, initially, on the tape we have $math[>​0111] — the representation +//Let us consider that, initially, on the tape we have $math[>​0111] — the representation of the number ​$math[7]. The evolution of the tape is shown below. Each line shows the //$math[TMconfiguration at step $math[i]//, that is, the tape and current state, after transition ​$math[i]. For convenience,​ we have chosen to show two empty cells in each direction, only. Also, the underline indicates the position of the tape head.//
-of the number 7. The evolution of the tape is shown below. Each +
-line shows the //TM configuration at step i//, that is, the tape and current state, +
-after transition i. For convenience,​ we have chosen to show two empty cells +
-in each direction, only. Also, the underline indicates the position of the tape +
-head.+
 ^  Transition no  ^  Tape           ​^ ​ Curent state  ^  ^  Transition no  ^  Tape           ​^ ​ Curent state  ^ 
 |  0              |  ##​__>​__0111## ​ |  $math[s_0] ​   | |  0              |  ##​__>​__0111## ​ |  $math[s_0] ​   |
Line 212: Line 187:
  
 In order to better understand the Turing Machine, it is useful to establish In order to better understand the Turing Machine, it is useful to establish
-some similarities with, e.g. assembly languages. As speci ed in Denition of Deterministic Turing Machine, a Turing Machine is //M// speci es a clearly de fined behaviour, +some similarities with, e.g. assembly languages. As speci ed in Denition of Deterministic Turing Machine, a Turing Machine is $math[M] specifi es a clearly de fined behaviour, which is actually captured by $math[\delta]. Thus, $math[Mis quite similar to a speci c //​program//,​ performing a de nite task. If programs (algorithms) are abstracted by Turing Machine, then what is the abstraction for the programming language? The answer is, again, the Turing Machine. This implies that, a Turing Machine acting as a programming language, can be fed another Turing Machine acting as program, and execute it.
-which is actually captured by $math[\delta]. Thus, //M// is quite similar to a speci c //​program//,​ performing a de nite task. If programs (algorithms) are abstracted +
-by Turing Machine, then what is the abstraction for the programming language? +
-The answer is, again, the Turing Machine. This implies that, a +
-Turing Machine acting as a programming language, can be fed another Turing +
-Machine acting as program, and execute it.+
  
 In the following Proposition,​ we show how Turing Machines can be encoded as words: In the following Proposition,​ we show how Turing Machines can be encoded as words:
Line 224: Line 194:
 //Any Turing Machine $math[M = (K, F, \Sigma, \delta, s_0)] can be encoded as a word over $math[\Sigma]. We write $math[enc(M)] to refer to this word.// //Any Turing Machine $math[M = (K, F, \Sigma, \delta, s_0)] can be encoded as a word over $math[\Sigma]. We write $math[enc(M)] to refer to this word.//
  
-//​Proof:​(sketch)//​ Intuitively,​ we encode states and positions as integers $math[n \in N], +//​Proof:​(sketch)//​ Intuitively,​ we encode states and positions as integers $math[n \in $mathbb{N}], transitions as pairs of integers, etc. and subsequently //"​convert"//​ each integer to it's word counterpart in $math[\Sigma^*],​ cf. Proposition 1.2.2.
-transitions as pairs of integers, etc. and subsequently //"​convert"//​ each integer +
-to it's word counterpart in $math[\Sigma^*],​ cf. Proposition 1.2.2.+
  
-Let $math[NonFin = |K \ F \ \{s_0\}|] be the set of non-fi nal states, excluding +Let $math[NonFin = \mid K \setminus ​F \setminus ​\{s_0\} ​\mid] be the set of non-fi nal states, excluding the initial one. We encode each state in $math[NonFin] as an integer in $math[\{1, 2, ..., NonFin\}] and each final state as an integer in 
-the initial one. We encode each state in $math[NonFin] as an integer in +$math[\{\mid NonFin \mid +1, ..., \mid NonFin \mid + \mid F \mid \}]. We encode the initial state $math[s_0] as $math[\mid NonFin \mid + \mid F \mid + 1], and L,H,R as $math[\mid NonFin \mid + \mid F \mid + i] with $math[i \in \{2,3,4\}]. Each integer from the above is represented as a word using $math[\lceil{ log_{\mid \Sigma \mid} {(\mid NonFin \mid + \mid F \mid + 4)} }\rceil]
-$math[\{1, 2, ..., NonFin\}] and each final state as an integer in +
-$math[\{\mid NonFin \mid +1, ..., \mid NonFin \mid + \mid F \mid \}]. We encode the initial state $math[s_0] as $math[\mid NonFin \mid + \mid F \mid + 1], and L,H,R as $math[\mid NonFin \mid + \mid F \mid + i] with $math[i \in \{2,3,4\}]. Each integer +
-from the above is represented as a word using $math[\lceil{ log_{\mid \Sigma \mid} {(\mid NonFin \mid + \mid F \mid + 4)} }\rceil]+
 bits. bits.
  
-Each transition $math[\delta(s,​ c) = (s^,, c^,, pos)] is encoded as:+Each transition $math[\delta(s,​ c) = (s^\prime, c^\prime, pos)] is encoded as:
  
-$math[enc(s)\#​c\#​enc(s^,)\#c^,\#enc(pos)]+$math[enc(s)\#​c\#​enc(s^\prime ​)\#c^\prime ​\#enc(pos)]
  
 where $math[enc(\cdot)] is the encoding described above. The entire $math[\delta] is encoded a sequence of encoded transitions,​ separed by $math[\#]. The encoding of $math[M] is where $math[enc(\cdot)] is the encoding described above. The entire $math[\delta] is encoded a sequence of encoded transitions,​ separed by $math[\#]. The encoding of $math[M] is
Line 246: Line 211:
  
 ==== - Proposition (The Universal Turing Machine) ==== ==== - Proposition (The Universal Turing Machine) ====
-//There exists a TM U which, for any TM M, and every word $math[w \in \Sigma^*], takes $math[enc(M)] and $math[w] +//There exists a $math[TM] $math[Uwhich, for any $math[TM] $math[M], and every word $math[w \in \Sigma^*], takes $math[enc(M)] and $math[w] as input and outputs ​$math[1whenever $math[M(w) = 1] and $math[0whenever $math[M(w) = 0]. We call $math[U], the// Universal Turing Machine//, and say that $math[Usimulates ​$math[M].//
-as input and outputs// //whenever $math[M(w) = 1] and// //whenever $math[M(w) = 0]. We +
-call U, the// Universal Turing Machine//, and say that U //simulates ​//M//.+
  
-//Proof:// Let //M// be a TM and $math[w = c_1c_2 ... c_n] be a word which is built from +//Proof:// Let $math[Mbe a $math[TMand $math[w = c_1c_2 ... c_n] be a word which is built from the alphabet of $math[M]. We build the Universal Turing Machine ​$math[U], as follows: 
-the alphabet of //M//. We build the Universal Turing Machine ​//U//, as follows: +  * The input of $math[Uis $math[enc(M)\#​enc(s_0)\#​c_1\#​c_2 ... c_n]. Note that $math[enc(s_0)] encodes the initial state of $math[Mwhile $math[c_1] is the fi rst symbol from $math[w]. The portion of the tape $math[enc(s_0)\#​c_1\#​c_2 ... c_n] will be used to mark the current con guration of $math[M], namely the current state of $math[M(initially $math[s_0]),​ the contents of $math[M]'s tape, and $math[M]'s current head position. More generally, this portion of the tape is of the form $math[enc(s_i)\#​u\#​v],​ with $math[u, v \in \Sigma_b^*] and $math[s_i] being the current state of $math[M]. The last symbol of $math[u] marks the current symbol, while $math[v] is the word which is to the left of the head. Initially, the current symbol is the first one, namely $math[c_1]. 
-  * The input of //U// is $math[enc(M)\#​enc(s_0)\#​c_1\#​c_2 ... c_n]. Note that $math[enc(s_0)] encodes the initial state of //M// while $math[c_1] is the fi rst symbol from $math[w]. The portion of the tape $math[enc(s_0)\#​c_1\#​c_2 ... c_n] will be used to mark the current con guration of //M//, namely the current state of //M// (initially $math[s_0]),​ the contents of //M//'s tape, and //M//'s current head position. More generally, this portion of the tape is of the form $math[enc(s_i)\#​u\#​v],​ with $math[u, v \in \Sigma_b^*] and $math[s_i] being the current state of //M//. The last symbol of $marh[u] marks the current symbol, while $math[v] is the word which is to the left of the head. Initially, the current symbol is the rst one, namely $math[c_1]. +  * $math[Uwill scan the initial state of $math[M], then it will move on the initial symbol from $math[w], and finally ​will move on the portion of $math[enc(M)] were transitions are encoded. Once a valid transition is found, it will execute it:  
-  * //U// will scan the initial state of //M//, then it will move on the initial symbol from //w//, and nally will move on the portion of $math[enc(M)] were transitions are encoded. Once a valid transition is found, it will execute it:  +    - $math[Uwill change the initial state to the current one, according to the transition;​ 
-    - //U// will change the initial state to the current one, according to the transition;​ +    - $math[Uwill change the original symbol in $math[waccording to the transition;​ 
-    - //U// will change the original symbol in //w// according to the transition;​ +    - $math[Uwill change the current symbol, according to $math[pos], from the transition;​ 
-    - //U// will change the current symbol, according to //pos//, from the transition;​ +  * $math[Uwill repeat this process until an accepting state of $math[Mis detected, or until no transition can be performed.
-  * //U// will repeat this process until an accepting state of //M// is detected, or until no transition can be performed.+
  
-Propositions 1.3.2 and 1.3.1 show that TMs have the capability to characterize both algorithms, as well as the computa +Propositions 1.3.2 and 1.3.1 show that TMs have the capability to characterize both algorithms, as well as the computational ​framework to execute them. One question remains: what can TMs actually compute? Can they be used to sort vectors, solve SAT, etc.? The answer, which is positive is given by the following hypothesis:
-tional ​framework to execute them. One question remains: what can TMs actually compute? Can they be used to sort vectors, solve SAT, etc.? The answer, which is positive is given by the following hypothesis:+
  
 ==== - Conjecture (Church-Turing) ==== ==== - Conjecture (Church-Turing) ====
Line 274: Line 235:
 [Matei: The fact that the totality problem is undecidable means that we cannot write a program that can find any infi nite loop in any program. The fact that the equivalence problem is undecidable means that the code optimization phase of a compiler may improve a program, but can never guarantee finding the optimally eficient version of the program. There may be potentially improved versions of the program that it cannot even be sure are equivalent.] [Matei: The fact that the totality problem is undecidable means that we cannot write a program that can find any infi nite loop in any program. The fact that the equivalence problem is undecidable means that the code optimization phase of a compiler may improve a program, but can never guarantee finding the optimally eficient version of the program. There may be potentially improved versions of the program that it cannot even be sure are equivalent.]
  
-The existence of the Universal Turing Machine $math[(U)] inevitably leads to interesting questions. Assume $math[M] is a Turing Machine and $math[w] is a word. We use the following convention: $math[enc(M)\_w] in order to represent the input of the $math[U]. Thus, $math[U] expects the encoding of a TM, followed by the special ​_____ symbol, and $math[M]'​s input $math[w]. $math[(\star)] Does $math[U] halt for all inputs? If the answer is positive, then $math[U] can be used to tell whether any machine halts, for a given input.+The existence of the Universal Turing Machine $math[(U)] inevitably leads to interesting questions. Assume $math[M] is a Turing Machine and $math[w] is a word. We use the following convention: $math[enc(M)\_w] in order to represent the input of the $math[U]. Thus, $math[U] expects the encoding of a $math[TM], followed by the special symbol ​$math[\_], and $math[M]'​s input $math[w]. $math[(\star)] Does $math[U] halt for all inputs? If the answer is positive, then $math[U] can be used to tell whether any machine halts, for a given input.
  
 We already have some reasons to believe we cannot answer positively to $math[(\star)],​ if we examine the proof of Proposition 1.3.2. Actually $math[(\star)] is a decision problem, one that is quite interesting and useful. We already have some reasons to believe we cannot answer positively to $math[(\star)],​ if we examine the proof of Proposition 1.3.2. Actually $math[(\star)] is a decision problem, one that is quite interesting and useful.
Line 291: Line 252:
 //Proof:// It is sucient to show that $math[Hom(\mathbb{N},​ \{0, 1\})] is uncountably infi nite. We build a proof by contraposition. We assume $math[Hom(\mathbb{N},​ \{0, 1\})] is countably infi nite. Hence, each natural number $math[n \in \mathbb{N}] corresponds to a function $math[f_n \in Hom(\mathbb{N},​ \{0, 1\})]. We build a matrix as follows: Columns describe functions $math[f_n : n \in \mathbb{N}]. Rows describe inputs $math[k \in \mathbb{N}]. Each matrix content $math[m_{i,​j}] is the value of $math[f_j(i)] (hence, the expected output for input $math[i], from function $math[f_j]). //Proof:// It is sucient to show that $math[Hom(\mathbb{N},​ \{0, 1\})] is uncountably infi nite. We build a proof by contraposition. We assume $math[Hom(\mathbb{N},​ \{0, 1\})] is countably infi nite. Hence, each natural number $math[n \in \mathbb{N}] corresponds to a function $math[f_n \in Hom(\mathbb{N},​ \{0, 1\})]. We build a matrix as follows: Columns describe functions $math[f_n : n \in \mathbb{N}]. Rows describe inputs $math[k \in \mathbb{N}]. Each matrix content $math[m_{i,​j}] is the value of $math[f_j(i)] (hence, the expected output for input $math[i], from function $math[f_j]).
  
-{{ :​aa:​intro:​aafigura2.4.2.jpg?​nolink&​300 |}}+$math[\begin{array}{ll} \mbox{ } & f_0 & f_1 & f_2 & \ldots & f_n & \ldots \\ 0 & 1 & 1 & 0 & \ldots & 0 & \ldots \\ 1 & 0 & 1 & 1 & \ldots & 0 & \ldots \\ 2 & 1 & 0 & 1 & \ldots & 1 & \ldots \\ \ldots & \ldots & \ldots & \ldots & \ldots & \ldots & \ldots \\ n & 1 & 1 & 0 & \ldots & 1 & \ldots \\ \ldots & \ldots & \ldots & \ldots & \ldots & \ldots & \ldots \end{array} \\ \mbox{Figure 1.4.2}]
  
 Figure 1.4.2: An example of the matrix of the proof of Proposition 1.4.2. The value $math[m_{i,​j}] have been fi lled out purely for the illustration. Figure 1.4.2: An example of the matrix of the proof of Proposition 1.4.2. The value $math[m_{i,​j}] have been fi lled out purely for the illustration.
Line 308: Line 269:
  
 $def[Decision,​ acceptance] $def[Decision,​ acceptance]
-Let $math[M] be a Turing Machine and $math[f \in Hom(\mathbb{N},​ \{0, 1\})].We say that: +//Let $math[M] be a Turing Machine and $math[f \in Hom(\mathbb{N},​ \{0, 1\})].We say that:// 
-  * $math[M] **decides** $math[f], iff for all $math[n \in \mathbb{N}]:​ $math[M(w) = 1] whenever $math[f(n^w) = 1] and $math[M(w) = 0] whenever $math[f(n^w) = 0]. +  * //$math[M] **decides** $math[f], iff for all $math[n \in \mathbb{N}]:​ $math[M(w) = 1] whenever $math[f(n^w) = 1] and $math[M(w) = 0] whenever $math[f(n^w) = 0].// 
-  * $math[M] **accepts** $math[f] iff for all $math[n \in \mathbb{N}]:​ $math[M(w) = 1] iff $math[f(n^w) = 1], and $math[M(w) = \perp] iff $math[f(n)=0].+  * //$math[M] **accepts** $math[f] iff for all $math[n \in \mathbb{N}]:​ $math[M(w) = 1] iff $math[f(n^w) = 1], and $math[M(w) = \perp] iff $math[f(n)=0].//
 $end $end
  
-Note that, in contrast with acceptance, decision is, intuitively,​ a stronger means of computing a function (i.e. solving a problem). In the latter case, the TM at hand can provide both a //yes// and a //no// answer to any problem instance, while in the former, the TM can only provide an answer of //yes//. If the answer to the problem instance at hand is //no//, the TM will not halt.+Note that, in contrast with acceptance, decision is, intuitively,​ a stronger means of computing a function (i.e. solving a problem). In the latter case, the $math[TMat hand can provide both a //yes// and a //no// answer to any problem instance, while in the former, the $math[TMcan only provide an answer of //yes//. If the answer to the problem instance at hand is //no//, the $math[TMwill not halt.
  
 Based on the two types of problem solving, we can classify problems (functions) as follows: Based on the two types of problem solving, we can classify problems (functions) as follows:
Line 320: Line 281:
 //Let $math[f \in Hom(\mathbb{N},​ \{0, 1\})] be a decision problem.// //Let $math[f \in Hom(\mathbb{N},​ \{0, 1\})] be a decision problem.//
  
-  * //$math[f] is **recursive** (decidable) iff there exists a $math[TM M] which decides $math[f]. The set of recursive functions is $math[R = \{f \in Hom(\mathbb{N},​ \{0,1\}) \mid \mbox{f is recursive} \}]// +  * //$math[f] is **recursive** (decidable) iff there exists a $math[TM] $math[M] which decides $math[f]. The set of recursive functions is $math[R = \{f \in Hom(\mathbb{N},​ \{0,1\}) \mid \mbox{f is recursive} \}]// 
-  * //$math[f] is **recursively enumerable** (//​semi-decidable//​) iff there exists a $math[TM M] which accepts $math[f]. The set of recursive-enumerable function is $math[RE = \{f \in Hom(\mathbb{N},​\{0,​1\}) \mid \mbox{f is recursively-enumerable} \}]//+  * //$math[f] is **recursively enumerable** (//​semi-decidable//​) iff there exists a $math[TM] $math[M] which accepts $math[f]. The set of recursive-enumerable function is $math[RE = \{f \in Hom(\mathbb{N},​\{0,​1\}) \mid \mbox{f is recursively-enumerable} \}]//
 $end $end
  
-Now, let us turn our attention to ques +Now, let us turn our attention to question ​$math[\star],​ which we shall formulate as a problem:
-tion $math[\star],​ which we shall formulate as a problem:+
  
 $math[f_h(n^{enc(M)\_w})= \left\{ \begin{array}{ll} 1 & \mbox{iff } M(w) \mbox{halts} \\ 0 & \mbox{iff } M(w) = \perp \end{array} \right.] $math[f_h(n^{enc(M)\_w})= \left\{ \begin{array}{ll} 1 & \mbox{iff } M(w) \mbox{halts} \\ 0 & \mbox{iff } M(w) = \perp \end{array} \right.]
Line 338: Line 298:
 $math[D(enc(M)) = \left\{ \begin{array}{ll} \perp & \mbox{iff } M_h(enc(M)\_enc(M)) = 1 \\ 1 & \mbox{iff } M_h(enc(M)\_enc(M)) = 0 \end{array} \right.] $math[D(enc(M)) = \left\{ \begin{array}{ll} \perp & \mbox{iff } M_h(enc(M)\_enc(M)) = 1 \\ 1 & \mbox{iff } M_h(enc(M)\_enc(M)) = 0 \end{array} \right.]
  
-The existence of the Universal Turing Machine guarantees that $math[D] can indeed be built, since $math[D] simulates $math[M_h]. We note that $math[M_h(enc(M)\_enc(M))] decides if the $math[TM M] halts with "//​itself//"​ as input (namely $math[enc(M)]).+The existence of the Universal Turing Machine guarantees that $math[D] can indeed be built, since $math[D] simulates $math[M_h]. We note that $math[M_h(enc(M)\_enc(M))] decides if the $math[TM] $math[M] halts with "//​itself//"​ as input (namely $math[enc(M)]).
  
 Assume $math[D(enc(D)) = 1]. Hence $math[M_h(enc(D),​enc(D)) = 0], that is, machine $math[D] does not halt for input $math[enc(D)]. Hence $math[D(enc(D)) = \perp]. Contradiction. Assume $math[D(enc(D)) = 1]. Hence $math[M_h(enc(D),​enc(D)) = 0], that is, machine $math[D] does not halt for input $math[enc(D)]. Hence $math[D(enc(D)) = \perp]. Contradiction.
Line 347: Line 307:
  
 ==== Exercise ==== ==== Exercise ====
-Apply the diagonalization technique from the proof of Proposition 1.4.2, in order to prove Proposition 1.4.3.+//Apply the diagonalization technique from the proof of Proposition 1.4.2, in order to prove Proposition 1.4.3.//
  
 ==== - Proposition ==== ==== - Proposition ====
Line 359: Line 319:
 $math[R \subsetneq RE] $math[R \subsetneq RE]
  
-//Proof:// $math[R \subseteq RE] is straightforward from Definition of $math[R] and $math[RE] from Definition of $math[R] and $math[RE]. Let $math[f \in R], and $math[M_f] be the $math[TM] which decides $math[M_f]. We build the $math[TM] $math[M'] such that $math[M'(w)=1] iff $math[M_f(w)=1] and $math[M'(w)=\perp] iff $math[M_f(w)=0]. $math[M'] simulates $math[M] but enters into an infinite loop whenever $math[M_f(w)=0]. $math[M'] accepts $math[f] hence $math[f \in RE].+//Proof:// $math[R \subseteq RE] is straightforward from Definition of $math[R] and $math[RE] from Definition of $math[R] and $math[RE]. Let $math[f \in R], and $math[M_f] be the $math[TM] which decides $math[M_f]. We build the $math[TM] $math[M^\prime] such that $math[M^\prime(w)=1] iff $math[M_f(w)=1] and $math[M^\prime(w)=\perp] iff $math[M_f(w)=0]. $math[M^\prime] simulates $math[M] but enters into an infinite loop whenever $math[M_f(w)=0]. $math[M^\prime] accepts $math[f] hence $math[f \in RE].
  
 $math[R \neq RE] has already been shown by Propositions 1.4.3 and 1.4.4. $math[f_h \in RE] but $math[f_h \notin R]. $math[R \neq RE] has already been shown by Propositions 1.4.3 and 1.4.4. $math[f_h \in RE] but $math[f_h \notin R].
Line 366: Line 326:
  
 ==== 1.4.1 Remark ==== ==== 1.4.1 Remark ====
-//We note that $math[R] and $math[RE] are not the only sets of functions which are used in Computability Theory. It has been shown that there are //"​degrees"//​ of unsolvability,​ of //"​higher level"//​ than $math[R] and $math[RE]. These degrees are intuitively obtained as follows: We assume we live in a world where $math[f_h] is decidable (recursive). Now, as before, we ask which problems are recursive and which are recursively-enumerable. It turns out that, also in this ideal case, there still exist recurs +//We note that $math[R] and $math[RE] are not the only sets of functions which are used in Computability Theory. It has been shown that there are //"​degrees"//​ of unsolvability,​ of //"​higher level"//​ than $math[R] and $math[RE]. These degrees are intuitively obtained as follows: We assume we live  
-ive and recursively-enumerable problems, as well +in a world where $math[f_h] is decidable (recursive). Now, as before, we ask which problems are recursive and which are recursively-enumerable. It turns out that, also in this ideal case, there still exist recursive ​and recursively-enumerable problems, as well as some which are neither. This could be imagined as //"​undecidability level 1"//. Now, we take some problem which is in $math[RE] on level 1, and repeat the same assumption: it is decidable. Again, under this assumption, we find problems in $math[R], $math[RE] and outside the two, which form up //"​undecidability level 2"//. This process can be repeated// ad infi nitum.
-as some which are neither. This could be imagined as //"​undecidability level 1"//. Now, we take some problem which is in $math[RE] on level 1, and repeat the same assumption: it is decidable. Again, under this assumption, we find problems in $math[R], $math[RE] and outside the two, which form up //"​undecidability level 2"//. This process can be repeated// ad infi nitum.+
  
 Returning to our simpler classi cation,​ we must observe an interesting feature of recursively-enumerable functions, which is also the reason they are called this way. Returning to our simpler classi cation,​ we must observe an interesting feature of recursively-enumerable functions, which is also the reason they are called this way.
Line 375: Line 334:
 //A function $math[f \in Hom(\mathbb{N},​ \{0, 1\})] is recursively enumerable iff there exists a Turing Machine which can **enumerate/​generate** all elements in $math[A_f = \{w \in \mathbb{N} \mid f(n^w) = 1\}]. Intuitively,​ $math[A_f] is the set of inputs of $math[f] for which the answer at hand is yes.// //A function $math[f \in Hom(\mathbb{N},​ \{0, 1\})] is recursively enumerable iff there exists a Turing Machine which can **enumerate/​generate** all elements in $math[A_f = \{w \in \mathbb{N} \mid f(n^w) = 1\}]. Intuitively,​ $math[A_f] is the set of inputs of $math[f] for which the answer at hand is yes.//
  
-//Proof:// $math[\Longrightarrow] Suppose $math[f] is recursively-enumerable and $math[M] ​accpts ​$math[f]. We write $math[w_i] to refer to the //i//th word from $math[\Sigma^*]. We specify the $math[TM] generating $math[A_f] by the following pseudocode:+//Proof:// $math[\Longrightarrow] Suppose $math[f] is recursively-enumerable and $math[M] ​accepts ​$math[f]. We write $math[w_i] to refer to the //i//th word from $math[\Sigma^*]. We specify the $math[TM] generating $math[A_f] by the following pseudocode:
  
 $algorithm[$math[GEN()]] $algorithm[$math[GEN()]]
Line 412: Line 371:
 $math[\mathbf{while} \mbox{ } w \notin A_f \mbox{ } \mathbf{do}] $math[\mathbf{while} \mbox{ } w \notin A_f \mbox{ } \mathbf{do}]
  
-$math[\quad ​w=GEN();]+$math[\quad ​v=GEN();]
  
-$math[\quad A_f = A_f \cup \{ \};]+$math[\quad A_f = A_f \cup \{ \};]
  
 $math[\mathbf{end}] $math[\mathbf{end}]
Line 435: Line 394:
 The technique we use to show $math[f_{all} \notin R] is called a //​reduction//​ (from $math[f_h]). It proceeds as follows. We assume $math[f_{all} \in R]. Starting from the $math[TM \mbox{ } M_{all}] which decides $math[f_{all}] we built a $math[TM] which decides $math[f_h]. Thus, if $math[f_{all}] is decidable then $math[f_h] is decidable, which leads to contradiction. The technique we use to show $math[f_{all} \notin R] is called a //​reduction//​ (from $math[f_h]). It proceeds as follows. We assume $math[f_{all} \in R]. Starting from the $math[TM \mbox{ } M_{all}] which decides $math[f_{all}] we built a $math[TM] which decides $math[f_h]. Thus, if $math[f_{all}] is decidable then $math[f_h] is decidable, which leads to contradiction.
  
-First, for each fixed $math[TM \mbox{ } M] and fi xed input $math[w \in \Sigma^*],​ we build the $math[TM \mbox{ } \Pi_{M,​w}(\omega) = ]//"​Replace $math[\omega] by $math[w] and then simulate $math[M(w)]"//​. It is easy to see that $math[(\forall \omega \in \Sigma^* : \Pi_{M,​w}(\omega) \mbox{ halts})] iff $math[M(w)] halts. Now, we build the $math[TM \mbox{ } M_h] which decides $math[f_h]. The input of $math[M_h] is $math[enc(M)\_w]. We construct $math[\Pi_{M,​w}] and run $math[M_{all}(enc(\Pi_{M,​w}))]. By assumption $math[M_{all}] must always halt. If the output is $math[1], then $math[\Pi_{M,​w}(\omega)] halts for all inputs, hence $math[M(w)] halts. We output $math[1]. If the output is $math[0], then $math[\Pi_{M,​w}(\omega)] does not halt for all inputs, hence $math[M(w)] does not halt. We output $math[0].+First, for each fixed $math[TM \mbox{ } M] and fi xed input $math[w \in \Sigma^*],​ we build the $math[TM \mbox{ } \Pi_{M,​w}(\omega) = ]//"​Replace $math[\omega] by $math[w] and then simulate $math[M(w)]"//​. It is easy to see that $math[(\forall \omega \in \Sigma^* : \Pi_{M,​w}(\omega) \mbox{ halts})] iff $math[M(w) 
 +] halts. Now, we build the $math[TM \mbox{ } M_h] which decides $math[f_h]. The input of $math[M_h] is $math[enc(M)\_w]. We construct $math[\Pi_{M,​w}] and run $math[M_{all}(enc(\Pi_{M,​w}))]. By assumption $math[M_{all}] must always halt. If the output is $math[1], then $math[\Pi_{M,​w}(\omega)] halts for all inputs, hence $math[M(w)] halts. We output $math[1]. If the output is $math[0], then $math[\Pi_{M,​w}(\omega)] does not halt for all inputs, hence $math[M(w)] does not halt. We output $math[0].
  
 We have built a reduction from $math[f_{all}] to $math[f_h]: Using the $math[TM] which decides $math[f_{all}] we have constructed a machine which decides $math[f_h]. Since $math[f_h] is not recursive, we obtain a contradiction. We have built a reduction from $math[f_{all}] to $math[f_h]: Using the $math[TM] which decides $math[f_{all}] we have constructed a machine which decides $math[f_h]. Since $math[f_h] is not recursive, we obtain a contradiction.
Line 454: Line 414:
 $math[\Pi_{M,​w}(\omega) = \mbox{ if } \omega = 111 \mbox{ then } M(w) \mbox{ else loop }] $math[\Pi_{M,​w}(\omega) = \mbox{ if } \omega = 111 \mbox{ then } M(w) \mbox{ else loop }]
  
-We observe that (i) the transformation from $math[enc(M)\_w] to $math[enc(\Pi_{M,​w})] is decidable since it involves adding precisely three states to $math[M]: these states check the input $math[\omega],​ and if it is $math[111] - replace it with $math[w] and run $math[M]; (ii) $math[M_{111}(\Pi_{M,​w}) = 1 \mbox{ iff } M(w)halts. The reduction is complete. $math[f_{111} \notin R].+We observe that (i) the transformation from $math[enc(M)\_w] to $math[enc(\Pi_{M,​w})] is decidable since it involves adding precisely three states to $math[M]: these states check the input $math[\omega],​ and if it is $math[111] - replace it with $math[w] and run $math[M]; (ii) $math[M_{111}(\Pi_{M,​w}) = 1 \mbox{ iff } M(w) \mbox{halts}]. The reduction is complete. $math[f_{111} \notin R].
  
 **Halting on some input** **Halting on some input**
Line 474: Line 434:
 $math[f_{eq}(n^{enc(M_1)\_enc(M_2)}) = \left\{ \begin{array}{ll} 1 & \mbox{for all } w \in \Sigma^* \mbox{ : } M_1(w) \mbox{ halts iff } M_2(w) \mbox{ halts} \\ 0 & \mbox{otherwise} \end{array} \right.] $math[f_{eq}(n^{enc(M_1)\_enc(M_2)}) = \left\{ \begin{array}{ll} 1 & \mbox{for all } w \in \Sigma^* \mbox{ : } M_1(w) \mbox{ halts iff } M_2(w) \mbox{ halts} \\ 0 & \mbox{otherwise} \end{array} \right.]
  
-We reduce $math[f_{all}] to $math[f_{eq}]. Let $math[M_{triv}] be a one-state Turing Machine which halts on every input, and $math[M_{eq}] be the Turing Machine which decides $math[f_{eq}]. Then $math[M_{eq}(enc(M)\_enc(M_{triv}) = 1 \mbox{ iff } M] halts on all inputs. We have shown we can use $math +We reduce $math[f_{all}] to $math[f_{eq}]. Let $math[M_{triv}] be a one-state Turing Machine which halts on every input, and $math[M_{eq}] be the Turing Machine which decides $math[f_{eq}]. Then $math[M_{eq}(enc(M)\_enc(M_{triv})) = 1 \mbox{ iff } M] halts on all inputs. We have shown we can use $math[M_{eq}] in order to build a machine which decides $math[f_{all}]. Contradiction. $math[f_{eq} \notin R].
-[M_{eq}] in order to build a machine which decides $math[f_{all}]. Contradiction. $math[f_{eq} \notin R].+
  
 So far, we have used reductions in order to establish problem nonmembership in $math[R]. There are other properties of $math[R] and $math[RE] which can be of use for this task. First we defi ne: So far, we have used reductions in order to establish problem nonmembership in $math[R]. There are other properties of $math[R] and $math[RE] which can be of use for this task. First we defi ne:
Line 500: Line 459:
 $math[RE \cap coRE = R]. $math[RE \cap coRE = R].
  
-//Proof:// Assume $math[f \in RE \cap coRE]. Hence, there exists a Turing Machine $math[M] which ccepts ​$math[f] ​ +//Proof:// Assume $math[f \in RE \cap coRE]. Hence, there exists a Turing Machine $math[M] which accepts ​$math[f] and a Turing Machine $math[\overline{M}] which accepts $math[\overline{f}]. We build the Turing Machine:
-and a Turing Machine $math[\overline{M}] which accepts $math[\overline{f}]. We build the Turing Machine:+
  
-$math[M^*(w) = \mbox{ for } i \in \mathbb{N} \left\{ \begin{array}{ll} \mbox{ run } M(w) \mbox{ for } i \mbox{steps.}\\ \mbox{ If } M(w) = 1 \mbox{, return } 1 \mbox{. Otherwise:​}\\ \mbox{ run } \overline{M}(w) \mbox{ for } i \mbox{steps.}\\ \mbox{ If } \overline{M}(w) = 1 \mbox{, return } 0 \mbox{.} \end{array} \right.]+$math[M^*(w) = \mbox{ for } i \in \mathbb{N} \left\{ \begin{array}{ll} \mbox{ run } M(w) \mbox{ for } i \mbox{ steps.}\\ \mbox{ If } M(w) = 1 \mbox{, return } 1 \mbox{. Otherwise:​}\\ \mbox{ run } \overline{M}(w) \mbox{ for } i \mbox{ steps.}\\ \mbox{ If } \overline{M}(w) = 1 \mbox{, return } 0 \mbox{.} \end{array} \right.]
  
 Since $math[M] and $math[\overline{M}] will always halt when expected result is 1, they can be used together to decide $math[f]. Hence $math[f \in R]. Since $math[M] and $math[\overline{M}] will always halt when expected result is 1, they can be used together to decide $math[f]. Hence $math[f \in R].
Line 511: Line 469:
  
 //Proof:// The proposition follows immediately since the Turing Machine which decides $math[f] can be used to decide $math[\overline{f}],​ by simply switching it's output from $math[0] to $math[1] and $math[1] to $math[0]. The same holds for the other direction. //Proof:// The proposition follows immediately since the Turing Machine which decides $math[f] can be used to decide $math[\overline{f}],​ by simply switching it's output from $math[0] to $math[1] and $math[1] to $math[0]. The same holds for the other direction.
- +
 We conclude this chapter with a very powerful result which states that an //​category/​type//​ of problems does not belong in $math[R]. We conclude this chapter with a very powerful result which states that an //​category/​type//​ of problems does not belong in $math[R].
  
Line 517: Line 475:
 //Let $math[\mathcal{C} \subseteq RE]. Given a Turing Machine $math[M], we ask:// "The problem accepted by $math[M] is in $math[\mathcal{C}]?"​. //Answering this question is not in $math[R].// //Let $math[\mathcal{C} \subseteq RE]. Given a Turing Machine $math[M], we ask:// "The problem accepted by $math[M] is in $math[\mathcal{C}]?"​. //Answering this question is not in $math[R].//
  
-//Proof:// We consider that the trivial problem $math[f(n) = 0] is not in $math[\mathcal{C}]. Since $math[\mathcal{C}] is non-empty, suppose $math[f^* \in \mathcal{C}],​ and since $math[f^*] is recursively-enumerable,​ let $math[M] be the Turing Machine which accepts $math[f^*].+//Proof:// We consider that the trivial problem $math[f(n) = 0] is not in $math[\mathcal{C}]. Since $math[\mathcal{C}] is non-empty, suppose $math[f^* \in \mathcal{C}],​ and since $math[f^*] is recursively-enumerable,​ let $math[M^*] be the Turing Machine which accepts $math[f^*].
  
 We apply a reduction from a variant of $math[f_{111}],​ namely $math[f_x]. $math[f_x] asks if a Turing Machine halts for input $math[x]. We assume we can decide the membership $math[f \in \mathcal{C}] by some Turing Machine. Based on the latter, we construct a Turing Machine which decides $math[f_x] (i.e. solves the halting problem for a particular input). Let $math[M_x] be the Turing Machine which //accepts// $math[fx]. We apply a reduction from a variant of $math[f_{111}],​ namely $math[f_x]. $math[f_x] asks if a Turing Machine halts for input $math[x]. We assume we can decide the membership $math[f \in \mathcal{C}] by some Turing Machine. Based on the latter, we construct a Turing Machine which decides $math[f_x] (i.e. solves the halting problem for a particular input). Let $math[M_x] be the Turing Machine which //accepts// $math[fx].