Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Section 14.1 Computability Some problems cannot be solved by any machine/algorithm. To prove such statements we need to effectively describe all possible.

Similar presentations


Presentation on theme: "1 Section 14.1 Computability Some problems cannot be solved by any machine/algorithm. To prove such statements we need to effectively describe all possible."— Presentation transcript:

1 1 Section 14.1 Computability Some problems cannot be solved by any machine/algorithm. To prove such statements we need to effectively describe all possible algorithms. Example (Turing machines). Associate a Turing machine with each n  N as follows: n  b(n)(the binary representation of n)  a(b(n))(b(n) split into 7-bit ASCII blocks, with leading zeros if needed)  if a(b(n)) is the syntax of a TM then a(b(n)) else (0, a, a, S, halt) fi. So we can effectively describe all possible Turing machines: T 0, T 1, T 2, … Of course we could use the same technique to list all possible instances of any computational model. For example, we can effectively list all possible simple programs and we can effectively list all possible partial recursive functions. If we want to use the Church-Turing thesis, then we can effectively list all possible solutions (e.g., Turing machines) to every intuitively computable problem. Decision Problems A decision problem is a problem can be phrased as a yes/no question. Such a problem is decidable if an algorithm exists to answer yes or no to each instance of the problem. Otherwise it is called undecidable. A decision problem is partially decidableif an algorithm exists to halt with the answer yes to yes-instances of the problem, but may run forever if the answer is no.

2 2 Examples.1. Is an arbitrary propositional wff a tautology? Decidable. 2. Is an arbitrary first-order wff valid? Undecidable and partially decidable. 3. Does a DFA accept infinitely many strings? Decidable. 4. Does a PDA accept a string s? Decidable. The Halting Problem The halting problem asks the following question. Does an arbitrary program halt on an arbitrary input? The halting problem is partially decidable: Just execute the program on the input. If the program halts, output yes. The halting problem is undecidable. To prove this, we’ll prove the following form for computable functions. Is there a computable function that can decide whether an arbitrary computable function halts on an arbitrary input? Proof: Assume, BWOC, that the halting problem is decidable. We’ll use the following effective listing of all computable functions of a single variable. ƒ 0, ƒ 1, ƒ 2, … Define the partial function g by g(n) = if ƒ n (n) halts then loop forever else 0 fi. Observe that g is computable because “ƒ n (n) halts” is computable by assumption. So there is some k such that g = ƒ k. Now apply g to k to obtain a contradiction: g(k) halts iff g(k) does not halt. Therefore the halting problem is undecidable. QED.

3 3 Example/Quiz. Given the following effective listing of all Turing machines. T 0, T 1, T 2, … Is it decidable whether T n halts on some input string of a’s within k steps? Answer: Yes. Perform the following algorithm. l := 0; (l represents the length of an input string of a’s. So the tape is initially empty.) while l ≤ k do Execute T n for k steps or until the halt state is reached, whichever comes first; If the halt state was reached, stop and output the answer YES; l := l + 1 (Reset the tape with one more a) od; Output the answer NO. Notice: If the while loop terminates without stopping with a YES-answer, then l > k. In this case T n will take more than k steps to process l cells with a’s. So the answer is NO. Some Total Problems There is no effective listing of the total computable functions. Proof: To see this for total computable functions of a single variable, assume, BWOC, that we have the following effective listing of these functions. ƒ 0, ƒ 1, ƒ 2, … Define g(n) = ƒ n (n) + 1. Since ƒ n is total, it follows that g is total too. Therefore g must be somewhere in the list. So there is some k such that g = ƒ k. But then ƒ k (k) = g(k) = ƒ k (k) + 1, which is a contradiction. QED.

4 4 The total problem asks whether an arbitrary computable function is total. The total problem is undecidable. Proof: Assume, BWOC, that the total problem is decidable. We’ll use the effective listing of all computable functions of a single variable ƒ 0, ƒ 1, ƒ 2, …. Now define the function T(n) = if ƒ n is total then 1 else 0 fi. Since “ƒ n is total” is computable by assumption, it follows that T is total too. But now we can effectively list all the total computable functions from the given list as follows: Let g0 be the smallest k such that T(k) = 1; Let g1 be the smallest k > g0 such that T(k) = 1; … Let g(n +1) be the smallest k > gn such that T(k) = 1. Continue in this manner to construct the list ƒ g0, ƒ g1, …, ƒ gn, … of all total computable functions of a single variable. But this contradicts the fact that it can’t be done. QED. Example/Quiz. Show that we can’t effectively list the total computable functions that have finite ranges. For example, ƒ(n) = n mod 4 has range {0, 1, 2, 3}. Proof: Suppose, BWOC, that ƒ 0, ƒ 1, ƒ 2, … is an effective listing of the single-variable computable functions with finite range. Now define the function g(n) = if ƒ n (n) ≤ 25 then ƒ n (n) + 1 else 25 fi. Observe that g is total, computable, and has finite range. So there is some k such that g = ƒ k. Quiz: What is the contradiction? Answer: If ƒ k (k) ≤ 25 then ƒ k (k) = ƒ k (k) + 1. If ƒ k (k) > 25 then ƒ k (k) = 25. QED.

5 5 Post Correspondence Problem (PCP) Given an arbitrary finite sequence (s 1, t 1 ), …, (s n, t n ) of pairs of strings, does there exist a sequence of indices i 1, …, i k, with repetitions allowed, such that s i1 …s ik = t i1 …t ik ? Example/Quiz. Does the following instance of the PCP have a solution? (ab, b), (b, a), (a, ab), (ba, b). Answer: Yes. If the pairs are labeled 1, 2, 3, 4, then the sequence 3, 2, 1 gives the equation abab = abab. Quiz. Does the following instance of the PCP have a solution? (a, aa), (aaaa, a). Answer: Yes. If the pairs are labeled 1, 2, then the sequence 1, 1, 1, 2 gives the equation aaaaaaa = aaaaaaa. The Post correspondence problem is undecidable for alphabets of size 2 or more. The proof involves reducing the problem to the halting problem. The PCP is also used in proving that it is undecidable to tell whether a context-free grammar over an alphabet of size 4 or more is ambiguous. Details of these two proofs can be found in: Harrison, Introduction to Formal Language Theory, Addison Wesley, 1981.


Download ppt "1 Section 14.1 Computability Some problems cannot be solved by any machine/algorithm. To prove such statements we need to effectively describe all possible."

Similar presentations


Ads by Google