Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
aa:intro:computability_theory [2016/07/21 23:06] malex |
aa:intro:computability_theory [2016/08/01 16:36] (current) malex [1.4.6. Proposition] |
||
---|---|---|---|
Line 196: | Line 196: | ||
//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. | //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. | ||
- | Let $math[NonFin = \mid K \ F \ \{s_0\} \mid] be the set of non-final 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 | + | Let $math[NonFin = \mid K \setminus F \setminus \{s_0\} \mid] be the set of non-final 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 |
$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[\{\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. | ||
Line 211: | 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[U] which, 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[1] whenever $math[M(w) = 1] and $math[0] whenever $math[M(w) = 0]. We call $math[U], the// Universal Turing Machine//, and say that $math[U] simulates $math[M].// |
- | as input and outputs// 1 //whenever $math[M(w) = 1] and// 0 //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[M] be a $math[TM] and $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[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 $math[M] while $math[c_1] is the first 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 conguration 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 first 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 conguration 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[U] will 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[U] will 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[U] will change the original symbol in $math[w] according to the transition; |
- | - //U// will change the original symbol in //w// according to the transition; | + | - $math[U] will change the current symbol, according to $math[pos], from the transition; |
- | - //U// will change the current symbol, according to //pos//, from the transition; | + | * $math[U] will repeat this process until an accepting state of $math[M] is 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 239: | Line 235: | ||
[Matei: The fact that the totality problem is undecidable means that we cannot write a program that can find any infinite 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 infinite 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 256: | Line 252: | ||
//Proof:// It is sucient to show that $math[Hom(\mathbb{N}, \{0, 1\})] is uncountably infinite. We build a proof by contraposition. We assume $math[Hom(\mathbb{N}, \{0, 1\})] is countably infinite. 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 infinite. We build a proof by contraposition. We assume $math[Hom(\mathbb{N}, \{0, 1\})] is countably infinite. 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 filled 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 filled out purely for the illustration. | ||
Line 273: | 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[TM] at hand can provide both a //yes// and a //no// answer to any problem instance, while in the former, the $math[TM] can only provide an answer of //yes//. If the answer to the problem instance at hand is //no//, the $math[TM] will 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 285: | 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 303: | 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 312: | 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 324: | 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 331: | 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 infinitum. |
- | 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 infinitum. | + | |
Returning to our simpler classication, we must observe an interesting feature of recursively-enumerable functions, which is also the reason they are called this way. | Returning to our simpler classication, we must observe an interesting feature of recursively-enumerable functions, which is also the reason they are called this way. | ||
Line 340: | 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 377: | 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 \{ w \};] | + | $math[\quad A_f = A_f \cup \{ v \};] |
$math[\mathbf{end}] | $math[\mathbf{end}] | ||
Line 400: | 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 fixed 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 fixed 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 419: | 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 439: | 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 define: | 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 define: | ||
Line 465: | 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 476: | 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 482: | 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]. |