CSE 105 Theory of Computation

Similar documents
CSE 105 Theory of Computation

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

Intro to Theory of Computation

CSE 105 Theory of Computation Professor Jeanne Ferrante

CS154, Lecture 10: Rice s Theorem, Oracle Machines

Computability and Complexity

CSE 105 Theory of Computation Professor Jeanne Ferrante

1 Showing Recognizability

CSE 105 THEORY OF COMPUTATION

CS5371 Theory of Computation. Lecture 12: Computability III (Decidable Languages relating to DFA, NFA, and CFG)

Lecture 23: Rice Theorem and Turing machine behavior properties 21 April 2009

CSE 105 THEORY OF COMPUTATION

CS 301. Lecture 18 Decidable languages. Stephen Checkoway. April 2, 2018

Reducability. Sipser, pages

CSCE 551 Final Exam, Spring 2004 Answer Key

Chap. 4,5 Review. Algorithms created in proofs from prior chapters

CS5371 Theory of Computation. Lecture 14: Computability V (Prove by Reduction)

V Honors Theory of Computation

Decidability and Undecidability

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

CSE 105 Theory of Computation

CS20a: Turing Machines (Oct 29, 2002)

6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, Class 8 Nancy Lynch

CSE 105 THEORY OF COMPUTATION

Lecture Notes: The Halting Problem; Reductions

What languages are Turing-decidable? What languages are not Turing-decidable? Is there a language that isn t even Turingrecognizable?

CSCE 551: Chin-Tser Huang. University of South Carolina

CSE 105 Theory of Computation

1 Reducability. CSCC63 Worksheet Reducability. For your reference, A T M is defined to be the language { M, w M accepts w}. Theorem 5.

Undecidable Problems and Reducibility

The Unsolvability of the Halting Problem. Chapter 19

Mapping Reducibility. Human-aware Robotics. 2017/11/16 Chapter 5.3 in Sipser Ø Announcement:

Undecidability. We are not so much concerned if you are slow as when you come to a halt. (Chinese Proverb)

Decidability. Human-aware Robotics. 2017/10/31 Chapter 4.1 in Sipser Ø Announcement:

Decidable Languages - relationship with other classes.

CSE 105 THEORY OF COMPUTATION

Lecture 12: Mapping Reductions

Turing Machines. Reading Assignment: Sipser Chapter 3.1, 4.2

Reading Assignment: Sipser Chapter 3.1, 4.2

} Some languages are Turing-decidable A Turing Machine will halt on all inputs (either accepting or rejecting). No infinite loops.

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

Computation Histories

CPSC 421: Tutorial #1

CS5371 Theory of Computation. Lecture 15: Computability VI (Post s Problem, Reducibility)

Turing Machine Recap

Decidability (What, stuff is unsolvable?)

uring Reducibility Dept. of Computer Sc. & Engg., IIT Kharagpur 1 Turing Reducibility

CS 361 Meeting 26 11/10/17

CS481F01 Solutions 8

CSE355 SUMMER 2018 LECTURES TURING MACHINES AND (UN)DECIDABILITY

4.2 The Halting Problem

CSE 105 THEORY OF COMPUTATION

Decision Problems with TM s. Lecture 31: Halting Problem. Universe of discourse. Semi-decidable. Look at following sets: CSCI 81 Spring, 2012

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

problem X reduces to Problem Y solving X would be easy, if we knew how to solve Y

Turing Machines Part III

Introduction to Languages and Computation

Answers to the CSCE 551 Final Exam, April 30, 2008

Computational Models Lecture 8 1

Computational Models Lecture 8 1

CSCE 551: Chin-Tser Huang. University of South Carolina

Decidability. Linz 6 th, Chapter 12: Limits of Algorithmic Computation, page 309ff

Decidability: Church-Turing Thesis

Computability and Complexity

Computational Models Lecture 9, Spring 2009

ACS2: Decidability Decidability

Theory of Computation p.1/?? Theory of Computation p.2/?? We develop examples of languages that are decidable

CSCI3390-Lecture 6: An Undecidable Problem

Computational Models Lecture 8 1

Computability Crib Sheet

Please give details of your answer. A direct answer without explanation is not counted.

TURING MAHINES

Decidability (intro.)

16.1 Countability. CS125 Lecture 16 Fall 2014

Theory of Computation (IX) Yijia Chen Fudan University

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Introduction to Turing Machines. Reading: Chapters 8 & 9

Name: Student ID: Instructions:

CpSc 421 Final Exam December 15, 2006

17.1 The Halting Problem

CS 125 Section #10 (Un)decidability and Probability November 1, 2016

CpSc 421 Homework 9 Solution

CSCE 551 Final Exam, April 28, 2016 Answer Key

SD & Turing Enumerable. Lecture 33: Reductions and Undecidability. Lexicographically Enumerable. SD & Turing Enumerable

Exam Computability and Complexity

Homework Assignment 6 Answers

Midterm II : Formal Languages, Automata, and Computability

Computability Theory

CSE 555 Homework Three Sample Solutions

MA/CSSE 474 Theory of Computation

CS 154 Introduction to Automata and Complexity Theory

Midterm Exam 2 CS 341: Foundations of Computer Science II Fall 2018, face-to-face day section Prof. Marvin K. Nakayama

6.045J/18.400J: Automata, Computability and Complexity. Quiz 2. March 30, Please write your name in the upper corner of each page.

Undecidability COMS Ashley Montanaro 4 April Department of Computer Science, University of Bristol Bristol, UK

MTAT Introduction to Theoretical Computer Science

Transcription:

CSE 105 Theory of Computation http://www.jflap.org/jflaptmp/ Professor Jeanne Ferrante 1

Undecidability Today s Agenda Review and More Problems A Non-TR Language Reminders and announcements: HW 7 (Last!!) due Fri May 27 by 11:59 pm Reading Quiz 9 (Last!!) due Mon May 30 by 11:59 pm REVIEW SESSIONS (Nathan Speidel): Wed May 25 8 pm 9:20 pm in WLH 2001 Thurs Jun 2 7 pm 8:50 pm in Peterson 108 Final Exam: If you need a LEFT handed seat, make a private post to instructors on Piazza 2

Status: Language Hierarchy Context-Free Regular Decidable Turing- Recognizable CF but not Regular: {0 n 1 n n > 0} By pumping lemma (Regular) Decidable but not CF: { a n b n c n n > 0} By pumping lemma (CF) Turing-Recognizable but Not Decidable: A TM By Diagonalization HALT TM, E TM REGULAR TM By Reduction Not Turing Recognizable:? By counting 3

Decidable Or Undecidable? Decidable languages: Construct a Decider! A DFA E DFA EQ DFA ALL DFA A CFG E CFG Any CFL {<M> M is a TM} Undecidable languages: By Diag. (D) or Reduction A TM (D) E TM EQ TM HALT TM REGULAR TM T = {<M> M is a TM and if M accepts w then it also accepts w R } {<M> M is a decider} (D) 4

Ex: T = {<M> M is a TM and if M accepts w then it also accepts w R } is undecidable We show that A TM reduces to T. Proof: By Contradiction. Assume that T decidable, with TM R T. We show that A TM is decidable, a contradiction. Construct a TM M ATM that decides A TM : M ATM = On input <M,w>: 1. Construct X = On input w: 2. Run R T with input <X>; If R T accepts, then accept. If R T rejects, reject. Correctness: M ATM is a decider since R T is, and accepts <M,w> iff R T accepts <X> iff..iff M accepts w. So L(M ATM ) = A TM But A TM is undecidable, a contradiction. So the assumption is false and E TM is undecidable. 5

How do we construct X? Choose very simple X! We construct X so that L(X) = { 01,10} if M accepts w OR = {01} if M does not accept w Note the subset relationship between these 2 If M accepts w, can add more strings to L(X)! X = On input w: 1. If w 01 or 10, reject. 2. If w = 01, accept 3. If w = 10, run M on w. If it accepts, accept Then within M ATM run M T with input <X> to distinguish between these 2, and decide A TM 6

Ex: T = {<M> M is a TM and if M accepts w then it also accepts w R } is undecidable We show that A TM reduces to T. Proof: By Contradiction. Assume that T decidable, with TM R T. We show that A TM is decidable, a contradiction. Construct a TM M ATM that decides A TM : M ATM = On input <M,w>: 1. Construct X = On input w: //L(X) = {01,10} IFF M accepts w 1. If w 01 or 10, reject. 2. If w = 01, accept 3. If w = 10, run M on w. If it accepts, accept 2. Run R T with input <X>; If R T accepts, then accept. If R T rejects, then reject. Correctness: M ATM is a decider since R T is, and accepts <M,w> iff R T accepts <X> iff L(X) = {01,10} iff M accepts w iff L(M ATM ) = A TM. But A TM is undecidable, a contradiction. So the assumption is false and E is undecidable. 7

We just did a Reduction For 2 problems P 1 and P 2, P 1 reduces to P 2 if any solution for P 2 can be used to solve P 1 (May be) Easier P 1 P 2 Yes No Yes No (May be) Harder Suppose P 1 reduces to P 2, then which of the following are true? A. If P 2 is decidable, then P 1 is also decidable. B. If P 1 is decidable, then P 2 is also decidable C. If P 1 is undecidable, then P 2 is also undecidable D. None or more than one of the above are true 8

Ex. INF TM = {<M> M a TM and L(M) is infinite} is undecidable We show that A TM reduces to INF TM. Proof: By contradiction. Assume that INF TM is decidable, with TM R. We show then that A TM is decidable, a contradiction. Construct TM M ATM that decides A TM : M ATM = On input <M,w>: 1. Construct TM X: 2. Run R on <X>. If R accepts, accept. If R rejects, reject. Correctness: M ATM is a decider since R is, and accepts <M,w> iff R accepts <X> iff.. iff M accepts w. But A TM is undecidable, a contradiction. So the assumption is false and INF TM is undecidable. 9

What should X do? If M accepts w, then L(X) should be infinite Pick one! Let s make it easy and choose {0,1}* If M rejects w, then L(X) must be finite Pick one! {0} X (z) = 1. If z = 0, accept. 2. If z is 0, then run M on w. If M accepts w, then accept z Qu: What is L(X) if M accepts w? A. L(X) = {0} B. L(X) = {z} C. L(X) = {0,1}* D. L(X) = { w є {0, 1}* w 0} E. None of the above 10

What should X do? If M accepts w, then L(X) should be infinite Pick one! Let s make it easy and choose {0,1}* If M rejects w, then L(X) must be finite Pick one! {0} X (z) = 1. If z = 0, accept. 2. If z is 0, then run M on w. If M accepts w, then accept z Qu: What is L(X) if M does not accept w? A. L(X) = {0} B. L(X) = {z} C. L(X) = {0,1}* D. L(X) = { w є {0, 1}* w 0} E. None of the above 11

Ex. INF TM = {<M> M a TM and L(M) is infinite} is undecidable We show that A TM reduces to INF TM. Proof: By contradiction. Assume that INF TM is decidable, with TM R. We show then that A TM is decidable, a contradiction. Construct TM M ATM that decides A TM : M ATM = On input <M,w>: 1. Construct TM X: X (z) = a) If z = 0, accept. // X accepts only string 0 if M does not accept w b) If z 0, then run M on w. If M accepts w, then accept z // X accepts all strings if M accepts w 2. Run R on <X>. If R accepts, accept. If R rejects, reject. Correctness: M ATM is a decider since R is, and accepts <M,w> iff R accepts <X> iff L(X) is infinite iff M accepts w. But A TM is undecidable, a contradiction. So the assumption is false and INF TM is undecidable. 12

Many Undecidability proofs follow a common pattern. Always a proof by contradiction Assume T is decidable by TM M T T checks for condition P, and always halts with accept or reject Use M T to construct TM M ATM (<M,w>) to decide A TM Within M ATM, construct special TM X such that 1. If M accepts w, then L(X) has property P 2. If M does not accept w, then L(X) has property not P Note: sometimes easier to build X so that X has P iff w not in L(M) Run M T with input <X> to distinguish between P or not P for L(X), to decide if M accepts w Show that M ATM decides A TM for the contradiction 13

ODD TM = {<M> M is a TM and L(M) consists of strings of odd length} is undecidable We show A TM reduces to ODD TM Proof: Assume that ODD TM is decidable, with TM R. We show that A TM is decidable, a contradiction. Construct a TM M ATM that decides A TM : M ATM = On input <M,w>: 1. Construct TM X as follows: X = On input y: If y = 0 then run M on w. If M accepts, accept What is L(X) if M accepts w? A. A TM B. {0} C. φ D. 0 E. None of the above 2. Run R on <X>. If R accepts, accept. If R rejects, reject. Correctness: M ATM is a decider since R is, and R accepts <X> iff L(X) = {0} iff M accepts w. But A TM is undecidable, a contradiction. So the assumption is false and ODD TM is undecidable. 14

ODD TM = {<M> M is a TM and L(M) consists of strings of odd length} is undecidable We show A TM reduces to ODD TM Proof: Assume that ODD TM is decidable, with TM R. We show that A TM is decidable, a contradiction. Construct a TM M ATM that decides A TM : M ATM = On input <M,w>: 1. Construct TM X as follows: X = On input y: If y = 0 then run M on w. If M accepts, accept What is L(X) if M does not accept w? A. A TM B. {0} C. φ D. 0 E. None of the above 2. Run R on <X>. If R accepts, accept. If R rejects, reject. Correctness: M ATM is a decider since R is, and R accepts <X> iff L(X) = {0} iff M accepts w. But A TM is undecidable, a contradiction. So the assumption is false and ODD TM is undecidable. 15

Why this X?? Want X to be such that L(X) consists of strings of odd length if M accepts w {0} L(X) does not consist of strings of odd length if M does not accept w X = On input y: 1.If y = 0 then run M on w. If M accepts, accept φ 16

E TM = {<M> M is a TM and L(M) is nonempty} is undecidable We show that A TM reduces to E TM Proof by contradiction: Assume that E TM is decidable, with TM R. We show that A TM is decidable, a contradiction. Using R, we construct a TM M ATM and show that it decides A TM : M ATM = On input <M,w>: 1. Construct TM X, X = On input y a) If y w, reject What is L(X)? A. A TM B. {w} C. w or φ D. {w} or φ E. None of the b) If y = w, runs M on w. If M accepts, accept above // Note that L(X) is nonempty iff M accepts w. 2. Run R on <X>. If R accepts, accept. If R rejects, reject. Correctness: M ATM is a decider since R is, and accepts <M,w> iff L(X) is nonempty iff M accepts w. But A TM is undecidable, so we have a contradiction. The assumption is false and E TM is undecidable.

Recall: There are exceptions! No special X construction needed for: A TM directly reduces to HALT TM Define M ATM (<M,w>): 1. Run M HALT (<M,w>) If M HALT rejects, then reject. 2. Else, run M(w); If it accepts, then accept. If it rejects, then reject. And we don t need to use only A TM to get our contradiction! 18

Proof INF TM undecidable using M HALT Let R decide INF TM = { <M> M is TM and L(M) is infinite} Show there is a decider for M HALT M HALT : "On input <M,w> 1. Build X such that L(X) is infinite iff. 2. Run R on <X>. If R accepts, accept; if R rejects, reject." X: "On input y 1. Run M on w. If."

Review: Thm 5.4: EQ TM = { <M 1,M 2 > M 1, M 2 are TMs and L(M 1 ) = L(M 2 ) } is undecidable We show E TM directly reduces to EQ TM Proof: By contradiction. Assume that EQ TM is decidable, and some TM M EQ decides it. Construct a TM M E that decides E TM : M E (<M>): 1. Run M EQ (<M, Φ >) //Where Φ is the TM that accepts empty set 2. If M EQ accepts, then accept. If it rejects, then reject. But E TM is undecidable, a contradiction. So the assumption is false and EQ TM is undecidable. 20

We have examples of languages that are not decidable ARE THERE LANGUAGES THAT ARE NOT TURING-RECOGNIZABLE? 21

Could A TM be not Turing Recognizable? A TM = {<M,w> M is a TM, M accepts w} No. We proved it was TR earlier by making this TM: M ATM-Rec (<M,w>): Run M(w) and accept if it accepts, reject if it rejects (If it loops that s ok since this isn t supposed to be a decider) But what about the complement of A TM? Lets assume (for contradiction) that it is also TR, and has a TM M Co-ATM-Rec that recognizes it Could we use M ATM-Rec and M Co-ATM-Rec to build a decider(!) for A TM? 22

Thm.: A TM is not Turing-recognizable Proof by contradiction Assume A TM is TR, and so some TM M Co-ATM-Rec recognizes it. We know that A TM is TR, so let M ATM-Rec be a TM that recognizes it. We define M ATM-Decider (<M,w>): 1. Run M ATM-Rec (<M,w>) and M Co-ATM-Rec (<M,w>) in parallel. 2. If M ATM-Rec accepts then accept. If M Co-ATM-Rec accepts, then reject. Is M ATM-Decider really a decider? A. No B. Yes, because M ATM-Rec and M Co-ATM-Rec are deciders C. Yes, since A TM is the complement of A TM 23

Thm.: A TM is not Turing-recognizable Proof by contradiction Assume A TM is TR, and so some TM M Co-ATM-Rec recognizes it. We know that A TM is TR, so let M ATM-Rec be a TM that recognizes it. We define M ATM-Decider (<M,w>): 1. Run M ATM-Rec (<M,w>) and M Co-ATM-Rec (<M,w>) in parallel. 2. If M ATM-Rec accepts then accept. If M Co-ATM-Rec accepts, then reject. One of the subroutines is guaranteed to accept, by definition of complement, so this machine is a decider for A TM. But A TM is undecidable, a contradiction. So the assumption is false and A TM is not TR. 24

Theorem 4.22: A language L is decidable iff L is both TR and co-tr L Decidable -> TR and co-tr Easy proof! Just use the decider to recognize L, so it is TR. Then use the decider again to build a recognizer for L, by flipping the accept/reject result. L TR and co-tr -> Decidable We can use the same run-in-parallel method we did for A TM and A TM to build a decider for L: Run recognizer TM s for L and L in parallel If the TM for L accepts, accept. If the TM for L accepts, reject. One of these must accept, so we can conclude this is a decider, and accepts A TM. 25

Only one of these can be recognizable: E TM or E TM. WHY? Qu: Which one is recognizable? A. E TM B. E TM C. Neither of them We define TM C = On input <M>: For positive integers i = 1,2, 3.. 1. Run M for i steps on the first i input strings (in lexicographical order). 2. If M every accepts a string, then ACCEPT.

Status: Language Hierarchy A TM A TM Context-Free Decidable Turing- Regular Recognizable E TM E TM CF but not Regular: {0 n 1 n n > 0} By pumping lemma (Regular) Decidable but not CF: { a n b n c n n > 0} By pumping lemma (CF) Turing-Recognizable but Not Decidable: A TM By Diagonalization E TM By Reduction Not Turing Recognizable: A TM TH 4.22 E TM