Presentation is loading. Please wait.

Presentation is loading. Please wait.

INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.

Similar presentations


Presentation on theme: "INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011."— Presentation transcript:

1 INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

2 UN DECIDABILITY A language is a set of strings. It is a mathematical way of expressing a problem: given an input, is it in the set L? If a language is decidable, there is a computer program (TM) that can always solve the problem correctly – it terminates and has the right answer. If a language is undecidable, then no matter how smart you are, and no matter how long you give it, you cannot program a computer to always solve the problem correctly.

3 UNDECIDABLE PROBLEMS D TM = { 〈 M 〉 | M is a TM that does not accept 〈 M 〉 } Theorem. D TM is undecidable. Proof. Suppose machine N decides D TM. Then N accepts 〈 N 〉 ⇔ 〈 N 〉  D TM ⇔ N does not accept 〈 N 〉 A TM = { 〈 M,w 〉 | M is a TM that accepts on input w } Theorem. If A TM is decidable, so is D TM. Proof. If ¬A TM is decided by the program nAccept we can decide D TM by calling nAccept(M, 〈 M 〉 ). Theorem. If HALT TM is decidable, then so is A TM. HALT TM = { 〈 M,w 〉 | M is a TM that halts on input w }

4 In most cases, we will show that a language is undecidable by showing that if it is decidable, then so is A TM We reduce deciding A TM to deciding the language in question

5 MAPPING REDUCTIONS ƒ : Σ*  Σ* is a computable function if there is a TM that on input w, halts with ƒ(w) on its tape A  m B if there is a computable ƒ such that w  A  ƒ(w)  B ƒ is called a reduction from A to B

6 NET = { J | J is a java applet that opens a network connection } Theorem. A TM ≤ m NET. Proof. On input 〈 M,w 〉, output the Java applet: import cs4011.tools.TuringMachine; import java.net.*; public class OutputApplet extends Applet { public void start() { TuringMachine TM = new TuringMachine(“M”, “w”); TM.run(); if (TM.accepted()) { // open a network connection URL url = new URL(“http://is.gd/”); Object o = url.getContent(); }

7 import cs4011.tools.TuringMachine; import java.net.*; public class OutputApplet extends Applet { public void start() { TuringMachine TM = new TuringMachine(“M”, “w”); TM.run(); if (TM.accepted()) { // open a network connection URL url = new URL(“http://is.gd/”); Object o = url.getContent(); } If M accepts w: OutputApplet opens url. If M loops on w: OutputApplet never gets to url. If M rejects w: OutputApplet skips if {… } block. In both cases, OutputApplet ∉ NET. Thus OutputApplet ∈ NET.

8 What’s wrong with this reduction? On input 〈 M,w 〉 : Run M on w. if M accepts, output: public class OutputApplet extends Applet { public void start() { URL url = new URL(“http://is.gd/”); Object o = url.getContent(); } else output: public class OutputApplet extends Applet { public void start() { return; }

9 PROBLEMS ABOUT TMs

10 NE TM = { 〈 M 〉 | M is a TM and L(M)   } Theorem: A TM ≤ m NE TM. if s  w: reject if s = w: run M(w) P Mw (s): Let ƒ( 〈 M,w 〉 ) = P Mw defined as: Need to show that: 1.If 〈 M,w 〉 ∈ A TM then P Mw ∈ NE TM. 2. If 〈 M,w 〉  A TM then P Mw  NE TM. If M accepts w then L(P Mw ) = {w}  . If M does not accept w then L(P Mw ) = . Proof:

11 REG TM = { 〈 M 〉 | M is a TM and L(M) is regular} Theorem: REG TM is undecidable Proof: We show that A TM ≤ m REG TM. The reduction, on input 〈 M,w 〉 outputs the TM P Mw : If ∃ n.s = 0 n 1 n : accept else: return M(w) P Mw (s): If M accepts w, L(P Mw ) = Σ*, so P Mw  REG TM. If M does not accept w, then L(P Mw ) = { 0 n 1 n | n ≥ 0} so P Mw  REG TM.

12 A TM REG TM ƒ ƒ 〈 M,w 〉 L(P Mw ) =  * 〈 M,w 〉 L(P Mw ) = 0 n 1 n EXAMPLE: REG TM ƒ( 〈 M,w 〉 ) = P Mw.

13 EXAMPLE SINGLETON TM = { 〈 M 〉 | M is a TM that accepts exactly one string} Show that A TM ≤ m SINGLETON TM. ES TM = { 〈 M 〉 | M is a TM that accepts on input ε } Show that A TM ≤ m ES TM.

14 RICE ’ S THEOREM Let P be a language of Turing machine encodings. IF P satisfies the following properties: For all TMs M 1 and M 2, where L(M 1 ) = L(M 2 ), 〈 M 1 〉  P if and only if 〈 M 2 〉  P There exist TMs 〈 M IN 〉  P and 〈 M OUT 〉  P THEN P is undecidable EXTREMELY POWERFUL (i.e. P is a “nontrivial property of the r.e. languages.”)

15 Theorem: Let P be a nontrivial property of the r.e. languages. Then P is undecidable We show that either A TM ≤ m P or A TM ≤ m ¬PProof: Let S be whichever of P, ¬P does not contain the TM T Ø that accepts no strings, and let M IN  S. On input 〈 M,w 〉 our reduction outputs T Mw : if (M(w) and M IN (s)): accept else: reject T Mw (s):

16 〈 M,w 〉  A TM iff ƒ( 〈 M,w 〉 )  S: If M accepts w, then T Mw accepts whenever M IN does. Then L(T Mw ) = L(M IN ); since S is a “language property”, T Mw  S If M does not accept w, then T Mw doesn’t accept any strings. So L(T Mw ) =  and since T Ø  S, neither is T Mw. if (M(w) and M IN (s)): accept else: reject T Mw (s):

17 Let 2S TM = { 〈 M 〉 | M is a TM and |L(M)| = 2 }. Theorem: 2S TM is undecidable. Proof: Apply Rice’s Theorem: 1. If L(M 1 ) = L(M 2 ) then |L(M 1 )| = |L(M 2 )| so 〈 M 1 〉  2S TM ⇔ 〈 M 2 〉 in 2S TM. 2. Let M IN (s) = “If s = 0 or s = 1 then accept. else reject.” Let M OUT (s) = accept. Then 〈 M IN 〉  2S TM and 〈 M OUT 〉  2S TM.

18 EXAMPLES CF TM = { 〈 M 〉 | M is a TM and L(M) is context-free} A ε = { 〈 M 〉 | M is a TM and L(M) = {ε} } OL TM = { 〈 M 〉 | M is a TM and accepts only odd length strings} Use Rice’s Theorem to prove that A ε, CF TM, and OL TM are undecidable.

19 Let EH = { 〈 M 〉 | M is a TM and ∃ w. M(w) halts } Rice’s Theorem does not apply to EH: Then L(M 1 ) = L(M 2 ) but 〈 M 1 〉∈ EH and 〈 M 2 〉  EH. EH is undecidable. ƒ( 〈 M,w 〉 ) = “P Mw (s): if (s  w): loop forever. else: return M(s).” WITH GREAT POWER COMES GREAT RESPONSIBILITY! Proof: HALT TM ≤ m EH: Let M 1 (s) = “reject.”, M 2 (s) = “loop forever.”

20 GREAT RESPONSIBILITY WRITE-2-1s = { 〈 M 〉 | M is a TM that writes exactly two ones to its tape on some input} Prove that Rice’s Theorem does not apply to: Let UL TM = { 〈 M 〉 | M is a TM with a useless state } *state q is useless if for all s, M(s) is never in state q

21 EQ TM = { 〈 M 1,M 2 〉 | M 1,M 2 are TMs and L(M 1 ) = L(M 2 )} Prove EQ TM is undecidable Hint: reduce E TM to EQ TM. EXAMPLE


Download ppt "INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011."

Similar presentations


Ads by Google