Theory of Computation 1 Theory of Computation Peer Instruction Lecture Slides by Dr. Cynthia Lee, UCSD are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike.

Slides:



Advertisements
Similar presentations
David Evans cs302: Theory of Computation University of Virginia Computer Science Lecture 17: ProvingUndecidability.
Advertisements

CS 461 – Nov. 9 Chomsky hierarchy of language classes –Review –Let’s find a language outside the TM world! –Hints: languages and TM are countable, but.
Turing -Recognizable vs. -Decidable
THE PUMPING LEMMA PROVING A LANGUAGE IS NOT REGULAR Dr. Cynthia Lee - UCSD - Spring 2011 Theory of Computation Peer Instruction Lecture Slides by Dr. Cynthia.
1 COMP 382: Reasoning about algorithms Unit 9: Undecidability [Slides adapted from Amos Israeli’s]
Theory of Computation 1 Theory of Computation Peer Instruction Lecture Slides by Dr. Cynthia Lee, UCSD are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike.
1 CSC3130 Formal Languages and Automata Theory Tutorial 9 Undecidable Problem KN Hung SHB 1026.
1 Introduction to Computability Theory Lecture14: Recap Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture15: Reductions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture12: Reductions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture13: Mapping Reductions Prof. Amos Israeli.
Lecture 8 Recursively enumerable (r.e.) languages
CHAPTER 4 Decidability Contents Decidable Languages
CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Lecture 6 Decidability Jan Maluszynski, IDA, 2007
Automata & Formal Languages, Feodor F. Dragan, Kent State University 1 CHAPTER 5 Reducibility Contents Undecidable Problems from Language Theory.
Theory of Computing Lecture 20 MAS 714 Hartmut Klauck.
Lecture 27UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 27.
CS21 Decidability and Tractability
1 Introduction to Computability Theory Lecture11: The Halting Problem Prof. Amos Israeli.
CS5371 Theory of Computation Lecture 12: Computability III (Decidable Languages relating to DFA, NFA, and CFG)
Remaining Topics Decidability Concept 4.1 The Halting Problem 4.2
Theory of Computation 1 Theory of Computation Peer Instruction Lecture Slides by Dr. Cynthia Lee, UCSD are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike.
Announcements Homework – HW8 due Tues 5/29 11am – HW5 grades are out Monday is Memorial Day; no office hours, etc. – Go see a parade, or some fireworks,
Theory of Computation 1 Theory of Computation Peer Instruction Lecture Slides by Dr. Cynthia Lee, UCSD are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike.
CSCI 2670 Introduction to Theory of Computing November 4, 2004.
CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
MA/CSSE 474 Theory of Computation More Reduction Examples Non-SD Reductions.
The Halting Problem – Undecidable Languages Lecture 31 Section 4.2 Wed, Oct 31, 2007.
CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
Tutorial: Reduction from A TM Proofs Dr. Cynthia Lee CSE 105, UCSD Spring 2011 Theory of Computation Peer Instruction Lecture Slides by Dr. Cynthia Lee,
Computer Language Theory
CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
 2005 SDU Lecture13 Reducibility — A methodology for proving un- decidability.
CS 461 – Nov. 7 Decidability concepts –Countable = can number the elements  –Uncountable = numbering scheme impossible  –A TM undecidable –Language classes.
Turing -Recognizable vs. -Decidable
CSE 311 Foundations of Computing I Lecture 28 Computability: Other Undecidable Problems Autumn 2011 CSE 3111.
CSCI 2670 Introduction to Theory of Computing October 13, 2005.
Donghyun (David) Kim Department of Mathematics and Computer Science North Carolina Central University 1 Chapter 4 Decidability Some slides are in courtesy.
CSCI 3130: Formal languages and automata theory Andrej Bogdanov The Chinese University of Hong Kong Decidable.
CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
The Church-Turing Thesis Chapter Are We Done? FSM  PDA  Turing machine Is this the end of the line? There are still problems we cannot solve:
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Undecidable.
The Acceptance Problem for TMs
CS 461 – Nov. 2 Sets Prepare for ATM finite vs. infinite Infinite sets
Theory of Computability
CSE 105 theory of computation
CSCI 2670 Introduction to Theory of Computing
CSCI 2670 Introduction to Theory of Computing
CSE 105 Theory of Computation
Theory of Computability
MCC 2093 Advanced Theoretical Computer Science
LIMITS OF ALGORITHMIC COMPUTATION
Busch Complexity Lectures: Undecidable Problems (unsolvable problems)
CSE 105 theory of computation
CSE 105 theory of computation
Decidable Languages Costas Busch - LSU.
Theory of Computability
CS21 Decidability and Tractability
CSCI 2670 Introduction to Theory of Computing
Theory of Computability
CSE 105 theory of computation
Theory of Computability
Instructor: Aaron Roth
Theory of Computability
Instructor: Aaron Roth
CSE 105 theory of computation
Automata, Grammars and Languages
More Undecidable Problems
CSE 105 theory of computation
CSE 105 theory of computation
Presentation transcript:

Theory of Computation 1 Theory of Computation Peer Instruction Lecture Slides by Dr. Cynthia Lee, UCSD are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. Based on a work at Cynthia Lee, UCSDCreative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported Licensewww.peerinstruction4cs.org

PARADOXXODARAP Preparing for DIAGONALIZATION! 2 XODARAPPARADOX

Making Lists Suppose you have many, many lists. So many, in fact, that some of your lists are lists of lists (to help you organize your lists), and some of them even include themselves. 3

List Organization Question Since some of your lists include themselves, and you know that self-reference is dangerous business, you make a list of all lists that do not include themselves. Call this list NON-DANGER-LIST. Question: – Should NON-DANGER-LIST include itself? a)YES b)NO c)Not enough information d)Other 4

Grandparent Paradox (Time Travel Paradox) You travel back in time and prevent one pair of your biological grandparents from ever meeting each other (assume this prevents your birth). Now you don’t exist, so can’t go back in time and prevent them from meeting. Pop culture version: 5

Pinocchio’s Paradox 6

THE TM ACCEPTANCE PROBLEM A TM 7

A TM = { | M is a TM, M accepts string w} A TM is: a)An operation b)A language c)A Turing Machine d)None or more than one of the above 8

A TM = { | M is a TM, M accepts w} A TM is Turing-recognizable a)TRUE b)FALSE c)Other 9

A TM IS UNDECIDABLE At last the proof you’ve all been waiting for! 10

The Game Plan: Recall: A TM = { | M is a TM, M accepts w} Thm: A TM is undecidable Proof by Contradiction: Assume (towards contradiction) that A TM is decidable, so there exists some TM M ATM decides A TM. Want to show: A TM D that uses M ATM as a subroutine, allowing D to do something impossible/contradictory. D(w): //w is a string – What D is or what it does is totally up to us—but we will have to be very clever to come up with something that will cause an impossibility/contradiction. Then, because we will have reached a contradiction, we will conclude that the assumption is false, and A TM is not decidable. 11

Let’s look at M ATM : Assume (towards contradiction) that A TM is decidable, so there exists some TM M ATM decides A TM. Let TM G be a TM, where L(G) = {w | |w| is even}, and G infinite loops on all strings not in L(G). What will happen if we run M ATM ( )? a)M ATM accepts b)M ATM rejects c)M ATM infinite loops d)Not enough information e)Other 12

Proof: Thm: A TM = { | M is a TM, M accepts w} is undecidable Assume (towards contradiction) that A TM is decidable, so there exists some TM M ATM that decides A TM. Construct a TM D as follows: – D( ): //input is a string description of a TM M ATM ( >) //M ATM is a decider, so no infinite looping—it will tell us if is in L(M) or not, even if M loops on If M ATM accepts, we reject If M ATM rejects, we accept // we do the opposite of M ATM Now, it will take one more step to show how D can do something impossible 13

Pause to Examine TM D D( ): //input is a string description of a TM – M ATM ( >) //M ATM is a decider, so no infinite looping—it will tell us if is in L(M) or not, even if M loops on – If M ATM accepts, we reject – If M ATM rejects, we accept // we do the opposite of M ATM Let M x be a TM, where L(M x ) = {}. What happens when we input M x to D like this: D( )? a)D accepts b)D rejects c)D infinte loops d)Not enough information e)Other 14

Pause to Examine TM D D( ): //input is a string description of a TM – M ATM ( >) //M ATM is a decider, so no infinite looping—it will tell us if is in L(M) or not, even if M loops on – If M ATM accepts, we reject – If M ATM rejects, we accept // we do the opposite of M ATM M L (w): – Go into an infinite loop What happens when we input M L to D like this: D( )? a)D accepts b)D rejects c)D infinite loops d)Not enough information e)Other 15

Pause to Examine TM D D( ): //input is a string description of a TM – M ATM ( >) //M ATM is a decider, so no infinite looping—it will tell us if is in L(M) or not, even if M loops on – If M ATM accepts, we reject – If M ATM rejects, we accept // we do the opposite of M ATM Let M v be a TM where L(M v ) = {w | w is a valid string encoding of a TM}. What happens when we input M v to D like this: D( )? a)D accepts b)D rejects c)D infinite loops d)Not enough information e)Other 16

Pause to Examine TM D D( ): //input is a string description of a TM – M ATM ( >) //M ATM is a decider, so no infinite looping—it will tell us if is in L(M) or not, even if M loops on – If M ATM accepts, we reject – If M ATM rejects, we accept // we do the opposite of M ATM What happens when we input D to D like this: D( )? a)D accepts b)D rejects c)D infinite loops d)Not enough information e)Other 17

Proof: Thm: A TM = { | M is a TM, M accepts w} is undecidable Assume (towards contradiction) that A TM is decidable, so some TM M ATM decides A TM. Construct a TM D as follows: – D( ): //input is a string description of a TM M ATM ( >)– M ATM is a decider, so it will either accept or reject (no infinite looping) If M ATM accepts, we reject If M ATM rejects, we accept // we do the opposite of M ATM Run D( ). Observe that D( ) should accept when D( ) rejects, and D( ) should reject when D( ) accepts, a contradiction. Therefore the assumption is false, and A TM is undecidable. 18

THE HALTING PROBLEM HALT TM Proving it is undecidable, by reduction from A TM 19

The Halting Problem HALT TM = { | M is a TM and M halts on input w} – Doesn’t say if M accepts or rejects w, just that it halts Imagine we have a hypothetical TM M halt that decides HALT TM. – Could we use M halt to build a decider for A TM, (hypothetically)? 20

Proof Ideas (trying to use hypothetical decider for HALT TM to construct a hypothetical decider for A TM ) a)M ATM ( ): – Run M halt ( ) //see if M will halt on w. – If M halt rejects, then accept. – Else, run M(w) If it accepts, then reject. If it rejects, then accept. 21 b) M ATM ( ): – Run M halt ( ) //see if M will halt on w. – If M halt rejects, then reject. – Else, run M(w) If it accepts, then accept. If it rejects, then reject.

Thm. HALT TM is undecidable. Proof by contradiction. Assume that HALT TM is decidable, and some TM M halt decides it. Construct a TM M ATM that decides A TM : But is A TM is undecidable, a contradiction. So the assumption is false and HALT TM is undecidable. 22

REDUCTIONS MORPHING ONE SOLUTION INTO ANOTHER A very useful tool! Now building towards P vs NP problem… 23

We just did a reduction We showed that *if* we have a solution to HALT TM, then we have a solution to A TM. What did we show exactly? a)A TM reduces to HALT TM. b)HALT TM reduces to A TM. c)HALT TM and A TM reduce to each other. d)None of the above or more than one of the above. 24

EQ TM = { | M 1, M 2 are TMs and L(M 1 ) = L(M 2 ) } Thm. EQ TM is undecidable. Proof by contradiction. Assume that EQ TM is decidable, and some TM M EQ decides it. Construct a TM M ETM that decides E TM : M ETM ( ): – Run M EQ ( ) If M EQ accepts, then accept. If it rejects, then reject. But is E TM is undecidable, a contradiction. So the assumption is false and EQ TM is undecidable. 25 What M x makes this proof work? (a) L(M x ) = { w | w is in Σ* } (b) L(M x ) = EQ TM (c) L(M x ) = {} (d) L(M X ) = E TM

We just did a reduction We showed that *if* we have a solution to EQ TM, then we have a solution to E TM. What did we show exactly? a)E TM reduces to EQ TM. b)EQ TM reduces to E TM. c)EQ TM and E TM reduce to each other. d)None of the above or more than one of the above. 26

ARE THERE LANGUAGES THAT ARE NOT TURING-RECOGNIZABLE? 27 Now we know there are languages that are not decidable…

Could A TM be not R.E.? { | M is a TM, M accepts w} No. We proved it was r.e. earlier by making this: – M ATM-Rec ( ): 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 just guess that it is also r.e., 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 ? 28

Thm.: A TM is not Turing-recognizable (R.E.) Proof by contradiction Assume A TM is r.e., and so some TM M Co-ATM-Rec recognizes it. We know that A TM is r.e., so let M ATM-Rec be a TM that recognizes it. M ATM-Decider ( ): – Run M ATM-Rec ( ) and M Co-ATM-Rec ( ) in parallel. – 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. But A TM is undecidable, a contradiction. So the assumption is false and A TM is not r.e. 29

Language Classes 30 R.E.Co-R.E. Decidable R.E. Decidable R.E. Decidable Co-R.E. R.E.Co-R.E. Decidable

Theorem 4.22: A language L is decidable iff it is both r.e. and co-r.e. Decidable -> r.e. and co-r.e. – Easy proof! Just use the decider to recognize L, so it is r.e. Then use the decider again to build a recognizer for L, by flipping the accept/reject result. R.e. and co-r.e. -> 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 L one accepts, accept. If the L one accepts, reject. One of these must accept, so this is a decider. 31

HOMEWORK #4 HELP 32 Hints & tips

#1: Decidability Proof Reading Problem: Prove that the language L = { w | there exists k>=0 such that w is a polynomial over variables v 1,..., v k, and there exists an integer assignment i 1,..., i k such that the polynomial evaluates to 0 (i.e., when v x = i x for all x 1<=x<=k, then the polynomial evaluates to 0)} is decidable. Proof by Construction: The language L is decidable if there exists a Turing Machine that decides L. We will construct a TM M that decides L, as follows: M(w): For each integer assignment to the polynomial variables (starting with 0, 0,..., 0 then 0, 0,..., 1, then 0, 0,..., -1, etc): 1.Evaluate the polynomial on the assignment. 2.If the assignment evaluates to 0 then accept; If no assignment accepts then reject. In step 2, the Turing Machine M either accepts or rejects (no looping), so M is a decider for L. Therefore the language L is decidable. QED. 33

#2: R.E. and Co-R.E. a)Show that EQ CFG is co-Turing-recognizable. – First, read Section 4.1 in the book and figure out what EQ CFG is (p.172), and see similar languages, like EQ DFA. – EQ CFG = { | G and H are CFGs and L(G) = L(H)} – Remember that to show a language is co-Turing- recognizable, you show that its complement is Turing- recognizable i.e., you need to build a TM that recognizes the complement of EQ CFG “Build a TM” means that you write the pseudocode for it, just like we’ve done in class many times today and on Tuesday – Be careful— If your TM can go into an infinite loop, that may be ok, because it is just supposed to be a recognizer BUT, make sure that it will get all its work done—in other words, watch out for cases where you get stuck down one path and don’t test everything you need to test (remember the issue about whether our enumerator could print “car”…) 34

#2: R.E. and Co-R.E. a)More hints: – You should use known decidable languages listed in Section 4.1 as a “toolkit” for proofs like this Example: Do you need to test if a string is in the language of an NFA? Well, by Theorem 4.2, we know that A NFA is a decidable language, so we know there is a decider TM that does that test that you can use as a subroutine! (for Problem #2, you won’t need this NFA test—this is just an example) Very convenient! Section 4.1 is like a software library for you! Just cite the Theorem # anytime you need to use one of these Be careful to distinguish the language name, like A NFA, from a TM for that language, which in this case they called “N”. So N( ) is the subroutine call, where B is the NFA and w is the string to test. 35

#2: R.E. and Co-R.E. b) Is EQ CFG is Turing-recognizable? Why or why not? – Assume from problem #4 that EQ CFG is undecidable – Also have your result from problem #2 part (a) – This is now super easy (~1-2 sentence(s)) 36

#3: Paradox and A TM This is a short essay question where you just give “your take” on what we talked about today with the paradoxes and A TM undecidability Goal: write something simple and coherent that shows you understand the big picture Do not stress about this problem—graded on “effort” 37

#4: Undecidability Proof by Reduction Show that EQ CFG is undecidable by reduction from ALL CFG. – This might look intimidating at first, but you can do it! – On slide #25 from today, we showed that EQ TM is undecidable, by reduction from E TM This is a really, really good example problem to refer to for ideas – I added notes (in green) to the homework description on moodle, explaining the general approach for this problem – One big thing to keep clear is exactly what EQ CFG language is—remember that you do *NOT* have given to you as arguments the two languages of the CFGs. You are given the CFGs themselves (i.e., “S -> NP | VP; NP -> P N…” etc) Also important to remember this distinction for Problem #2 38

Looking Ahead to the Final Exam 1.DFAs, NFAs, REs, PDAs, Grammars: general understanding 2.Closure proofs (for all language classes) 3.Pumping Lemma proofs 4.Prove a language is decidable/r.e./co-r.e. (write TM code, maybe use something from the “toolkit” from Section 4.1, like problem #2, be careful to avoid loops or “’car’ issue”) 5.Prove a language is undecidable by reduction from some other language (like problem #4; same notes apply as re: 4.1 toolkit and beware of loops etc.) 6.Prove a language is undecidable by reduction from A TM (this is similar to #5 on this list, but when reducing from A TM specifically, there are some special tricks to know— we’ll do many examples on Tuesday) – This is really the only major new thing not covered yet 39