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
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
Advertisements

Prof. Shachar Lovett Clicker frequency: CA CSE 20 Discrete math Prof. Shachar Lovett
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.
1 COMP 382: Reasoning about algorithms Unit 9: Undecidability [Slides adapted from Amos Israeli’s]
Week 7 - Wednesday.  What did we talk about last time?  Set proofs and disproofs  Russell’s paradox.
EE1J2 - Slide 1 EE1J2 – Discrete Maths Lecture 10 Cardinality Uncountability of the real numbers.
CSE 20 DISCRETE MATH Prof. Shachar Lovett Clicker frequency: CA.
1 Introduction to Computability Theory Lecture14: Recap Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture12: Reductions Prof. Amos Israeli.
Introduction to Computability Theory
The Halting Problem Sipser 4.2 (pages ). CS 311 Mount Holyoke College 2 Taking stock All languages Turing-recognizable Turing-decidable Context-free.
The Halting Problem Sipser 4.2 (pages ).
CSCI 2670 Introduction to Theory of Computing October 19, 2005.
Courtesy Costas Busch - RPI1 A Universal Turing Machine.
Great Theoretical Ideas in Computer Science.
1 Undecidability Andreas Klappenecker [based on slides by Prof. Welch]
Decidability. Why study un-solvability? When a problem is algorithmically unsolvable, we realize that the problem must be simplified or altered before.
Decidable and undecidable problems deciding regular languages and CFL’s Undecidable problems.
CHAPTER 4 Decidability Contents Decidable Languages
Fall 2004COMP 3351 A Universal Turing Machine. Fall 2004COMP 3352 Turing Machines are “hardwired” they execute only one program A limitation of Turing.
CS 310 – Fall 2006 Pacific University CS310 The Halting Problem Section 4.2 November 15, 2006.
January 28, 2015CS21 Lecture 101 CS21 Decidability and Tractability Lecture 10 January 28, 2015.
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.
Cantor’s Legacy: Infinity And Diagonalization Great Theoretical Ideas In Computer Science Steven RudichCS Spring 2004 Lecture 25Apr 13, 2004Carnegie.
Set Theory A B C.
Cardinality of Sets Section 2.5.
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.
CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
The Halting Problem – Undecidable Languages Lecture 31 Section 4.2 Wed, Oct 31, 2007.
1 Undecidability Reading: Chapter 8 & 9. 2 Decidability vs. Undecidability There are two types of TMs (based on halting): (Recursive) TMs that always.
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 15-1 Mälardalen University 2012.
CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
Copyright © Cengage Learning. All rights reserved. CHAPTER 7 FUNCTIONS.
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
A Universal Turing Machine
COMPSCI 102 Introduction to Discrete Mathematics.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
1 Turing’s Thesis. 2 Turing’s thesis: Any computation carried out by mechanical means can be performed by a Turing Machine (1930)
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
D E C I D A B I L I T Y 1. 2 Objectives To investigate the power of algorithms to solve problems. To explore the limits of algorithmic solvability. To.
Computability Universal Turing Machine. Countability. Halting Problem. Homework: Show that the integers have the same cardinality (size) as the natural.
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.
Great Theoretical Ideas in Computer Science.
CSE 20 – Discrete Mathematics Dr. Cynthia Bailey Lee Dr. Shachar Lovett Peer Instruction in Discrete Mathematics by Cynthia Leeis licensed under a Creative.
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.
CS 461 – Nov. 7 Decidability concepts –Countable = can number the elements  –Uncountable = numbering scheme impossible  –A TM undecidable –Language classes.
Donghyun (David) Kim Department of Mathematics and Computer Science North Carolina Central University 1 Chapter 4 Decidability Some slides are in courtesy.
CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
1 A Universal Turing Machine. 2 Turing Machines are “hardwired” they execute only one program A limitation of Turing Machines: Real Computers are re-programmable.
The Acceptance Problem for TMs
A Universal Turing Machine
CS 461 – Nov. 2 Sets Prepare for ATM finite vs. infinite Infinite sets
This statement is false.
CSCI 2670 Introduction to Theory of Computing
CSE 105 Theory of Computation
Lecture12 The Halting Problem
CSCI 2670 Introduction to Theory of Computing
Formal Languages, Automata and Models of Computation
CS21 Decidability and Tractability
Cardinality Definition: The cardinality of a set A is equal to the cardinality of a set B, denoted |A| = |B|, if and only if there is a one-to-one correspondence.
CSCI 2670 Introduction to Theory of Computing
Cpt S 317: Spring 2009 Reading: Chapter 8 & 9
Instructor: Aaron Roth
Turing Machines Everything is an Integer
Intro to 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

INFINITE LOOPS “ARE WE THERE YET?” Flashback from CSE 8A/B: 2

If there exists a TM M that accepts every string in L, and rejects all other strings, then L is: a)Turing decidable b)Turing recognizable, but not decidable c)Not enough information 3

If there exists a TM M that accepts every string in L, and loops for all strings not in L, then L is: a)Turing decidable b)Turing recognizable, but not decidable c)Not enough information 4

If there exists a for all TM M such that M recognizes L, M is not a decider, then L is: a)Turing decidable b)Turing recognizable, but not decidable c)Not enough information 5

DECIDABILITY IMPORTANT DECIDABLE LANGUAGES More Proofs 6

String Encoding Notation Turing Machines always take a single input string of finite length – M(w) But sometimes we want them to take as input several strings, or an object, or several objects We use to denote “encode this as a single string” – Several strings can be combined into one string by using a delimiter character not in the main alphabet – Object(s) can be encoded as a finite string A video V can be encoded as a (very long) string of 0’s and 1’s The diagram for TM M can be encoded as a string Three TM’s M 1, M 2 and M 3 7

String Encoding Notation Since we already know these encodings can be done, we just put triangle brackets around them to denote “encode this as a string” – For standard objects (TMs, DFAs, etc), no further explanation is necessary—use book as your guide NOTE! Languages CANNOT generally be encoded as a string because if there are infinitely many strings, there is no way to concatenate all the strings together into a single finite string – DFAs, NFAs, REs, PDAs, CFGs and TMs can all be encoded as strings ( etc) – However their languages cannot

Prove that the class of Turing-decidable languages is closed under Union Given: Two decidable languages A and B, and TMs that decide them, M A and M B. Want to Show: A TM M U that decides A U B. Construction: – M U (w) = //w is a string 1.Simulate running M A (w) – If it accepts, accept. If it rejects, go to step 2: 2.Simulate running M B (w) – If it accepts, accept. If it rejects, reject. Correctness: //this is for you to debate! Conclusion: M U is a TM that decides AUB, therefore AUB is decidable, and decidable languages are closed under union. QED. This proof is: (a)Correct (b)Incorrect

Prove that the class of Turing-recognizable languages is closed under Union Given: Two Turing-recognizable languages A and B, and TMs that recognize them, M A and M B. Want to Show: A TM M U that recognizes A U B. Construction: – M U (w) = //w is a string 1.Simulate running M A (w) – If it accepts, accept. If it rejects, go to step 2: 2.Simulate running M B (w) – If it accepts, accept. If it rejects, reject. Correctness: //this is for you to debate! Conclusion: M U is a TM that recognizes AUB, therefore AUB is Turing-recognizable, and Turing-recognizable languages are closed under union. QED. This proof is: (a)Correct (b)Incorrect

Prove that the class of Turing-recognizable languages is closed under Intersection Given: Two Turing-recognizable languages A and B, and TMs that recognize them, M A and M B. Want to Show: A TM M I that recognizes A intersect B. Construction: – M I (w) = //w is a string 1.Simulate running M A (w) – If it rejects, reject. If it accepts, go to step 2: 2.Simulate running M B (w) – If it accepts, accept. If it rejects, reject. Correctness: //this is for you to debate! Conclusion: M I is a TM that recognizes A intersect B, therefore A intersect B is Turing-recognizable, and Turing- recognizable languages are closed under intersection. QED. This proof is: (a)Correct (b)Incorrect

Prove that the class of Turing-decidable languages is closed under Intersection Given: Two decidable languages A and B, and TMs that decide them, M A and M B. Want to Show: A TM M I that decides A intersect B. Construction: – M I (w) = //w is a string 1.Simulate running M A (w) – If it rejects, reject. If it accepts, go to step 2: 2.Simulate running M B (w) – If it accepts, accept. If it rejects, reject. Correctness: //this is for you to debate! Conclusion: M I is a TM that decides A intersect B, therefore A intersect B is decidable, and decidable languages are closed under intersection. QED. This proof is: (a)Correct (b)Incorrect

Prove that the class of Turing-decidable languages is closed under Complement Given: A decidable language A, and a TM that decides it, M A. Want to Show: A TM M C that decides the complement of A. Construction: – M C (w) = //w is a string 1.Simulate running M A (w) – If it accepts, reject. If it rejects, accept. Correctness: //this is for you to debate! Conclusion: M C is a TM that decides the complement of A, therefore the complement of A is decidable, and decidable languages are closed under complement. QED. This proof is: (a)Correct (b)Incorrect

Prove that the class of Turing-recognizable languages is closed under Complement Given: A Turing-recognizable language A, and a TM that recognizes it, M A. Want to Show: A TM M C that recognizes the complement of A. Construction: – M C (w) = //w is a string 1.Simulate running M A (w) – If it accepts, reject. If it rejects, accept. Correctness: //this is for you to debate! Conclusion: M C is a TM that recognizes the complement of A, therefore the complement of A is Turing- recognizable, and Turing-recognizable languages are closed under complement. QED. This proof is: (a)Correct (b)Incorrect

Co-Turing-Recognizable Languages Our current classes of langauges: – Regular – Context-free – Turing-decidable (AKA just “decidable”) – Turing-recognizable (or r.e.) – co-Turing-recognizable (or co-r.e.) We now have the new class “co-Turing-recognizable” (or “co-r.e.” for short) – Language A is co-r.e. if the complement of A is r.e. 15

CARDINALITY INFINITY AND INFINITIES To infinity, and beyond! (really) 16

Set Theory and Sizes of Sets How can we say that two sets are the same size? Easy for finite sets--what about infinite sets? Georg Cantor ( ), who invented Set Theory, proposed a way of comparing the sizes of two sets that does not involve counting how many things are in each – Works for both finite and infinite SET SIZE EQUALITY: – Two sets are the same size if there is a bijective (one-to-one and onto) function mapping from one to the other – Intuition: neither set has any element “left over” in the mapping 17

One-to-one and Onto f is one-to-one but NOT onto. Does this prove that |N| ≠ |N|? Draw a function that is onto but not one-to-one. 18

One-to-one and Onto f is: a)One-to-One b)Onto c)Correspondence (both (a) and (b)) d)Neither 19

One-to-one and Onto f is: a)One-to-One b)Onto c)Correspondence (both (a) and (b)) d)Neither 20

It gets even weirder: Rational Numbers 21 1/11/21/31/41/51/6… 2/12/22/32/42/52/6… 3/13/23/33/43/53/6… 4/14/24/34/44/54/6… 5/15/25/35/45/55/6... 6/16/26/36/46/56/6 ………………… Q = {m/n | m,n are in N}

Sizes of Infinite Sets The number of Natural Numbers is equal to the number of positive Even Numbers, even though one is a proper subset of the other! – |N| = |E+|, not |N| = 2|E+| The number of Rational Numbers is equal to the number of Natural Numbers – |N| = |Q|, not |Q| ≈ |N| 2 But it gets even weirder than that: It might seem like Cantor’s definition of “same size” for sets is so overly broad, that any two sets of infinite size could be proven to be the “same size” – Not so!!!! 22

Thm. |R| != |N| Proof by contradiction: Assume |R| = |N|, so a correspondence f exists between N and R. 23 Want to show: no matter how f is designed (we don’t know how it is designed so we can’t assume anything about that), it cannot work correctly. Specifically, we will show a number z in R that can never be f(n) for any n, no matter how f is designed. Therefore f is not onto, a contradiction.

Thm. |R| != |N| Proof by contradiction: Assume a correspondence f exists between N and R. 24 nf(n) … … … …… We construct z as follows: z’s n th digit is the n th digit of f(n), PLUS ONE* (*wrap to 1 if the digit is 9) Below is an example f What is z in this example? a).244… b).134… c).031… d).245…

Thm. |R| != |N| Proof by contradiction: Assume a correspondence f exists between N and R. 25 nf(n) 1.d 1 1 d 1 2 d 1 3 d 1 4 … 2.d 2 1 d 2 2 d 2 3 d 2 4 … 3.d 3 1 d 3 2 d 3 3 d 3 4 … …… We construct z as follows: z’s n th digit is the n th digit of f(n), PLUS ONE* (*wrap to 1 if the digit is 9) Below generalized version of f(n) What is z? a).d 1 1 d 1 2 d 1 3 … b).d 1 1 d 2 2 d 3 3 … c).[d ] [d ] [d ] … d).[d ] [d ] [d ] …

Thm. |R| != |N| Proof by contradiction: Assume a correspondence f exists between N and R. 26 nf(n) 1.d 1 1 d 1 2 d 1 3 d 1 4 … 2.d 2 1 d 2 2 d 2 3 d 2 4 … 3.d 3 1 d 3 2 d 3 3 d 3 4 … …… How do we reach a contradiction? Must show that z cannot be f(n) for any n How do we know that z ≠ f(n) for any n? a)We can’t know if z = f(n) without knowing what f is and what n is b)Because z’s n th digit differs from n‘s n th digit c)Because z’s n th digit differs from f(i)’s n th digit

Thm. |R| != |N| 27 Proof by contradiction: Assume |R| = |N|, so a correspondence f exists between N and R. Want to show: f cannot work correctly. Let z = [z’s n th digit = (n th digit of f(n)) + 1]. Note that z is in R, but for all n in N, z != f(n). Therefore f is not onto, a contradiction. So |R| ≠ |N| |R| > |N|

Diagonalization 28 nf(n) 1.d 1 1 d 1 2 d 1 3 d 1 4 d 1 5 d 1 6 d 1 7 d 1 8 d 1 9 … 2.d 2 1 d 2 2 d 2 3 d 2 4 d 2 5 d 2 6 d 2 7 d 2 8 d 2 9 … 3.d 3 1 d 3 2 d 3 3 d 3 4 d 3 5 d 3 6 d 3 7 d 3 8 d 3 9 … 4.d 4 1 d 4 2 d 4 3 d 4 4 d 4 5 d 4 6 d 4 7 d 4 8 d 4 9 … 5.d 5 1 d 5 2 d 5 3 d 5 4 d 5 5 d 5 6 d 5 7 d 5 8 d 5 9 … 6.d 6 1 d 6 2 d 6 3 d 6 4 d 6 5 d 6 6 d 6 7 d 6 8 d 6 9 … 7.d 7 1 d 7 2 d 7 3 d 7 4 d 7 5 d 7 6 d 7 7 d 7 8 d 7 9 … 8.d 8 1 d 8 2 d 8 3 d 8 4 d 8 5 d 8 6 d 8 7 d 8 8 d 8 9 … 9.d 9 1 d 9 2 d 9 3 d 9 4 d 9 5 d 9 6 d 9 7 d 9 8 d 9 9 … ……

Some infinities are more infinite than other infinities 29 Natural numbers are called countable Any set that can be put in correspondence with N is called countable (ex: E+, Q) Real numbers are called uncountable Any set that can be put in correspondence with R is called “uncountable” But it gets even weirder… There are more than two categories!

Some infinities are more infinite than other infinities 30 |N| is called א 0 |E+| = |Q| = א 0 |R| is maybe א 1 Although we just proved that |N| < |R|, and nobody has ever found a different infinity between |N| and |R|, mathematicians haven’t proved that there are not other infinities between |N| and |R|, making |R| = א 2 or greater Sets exist whose size is א 0, א 1, א 2, א 3 … An infinite number of aleph numbers! An infinite number of different infinities

Famous People: Georg Cantor ( ) His theory of set size, in particular transfinite numbers (different infinities) was so strange that many of his contemporaries hated it – Just like many CSE 105 students! “scientific charlatan” “renegade” “corrupter of youth” “utter nonsense” “laughable” “wrong” “disease” “I see it, but I don't believe it!” –Georg Cantor 31 “The finest product of mathematical genius and one of the supreme achievements of purely intellectual human activity.” –David Hilbert

What does this have to do with computer science? Or Turing Machines? The set of all possible Turing Machines is countable The set of all possible languages is uncountable Therefore…. a)The language NATURAL = { | w is a natural number} is not Turing decidable b)Some languages are not Turing decidable c)Some languages are not Turing recognizable d)Some Turing Machines don’t recognize any language e)None or more than one of these That’s a start, but more diagonalization gets us a more specific result 32

PARADOXXODARAP Preparing for DIAGONALIZATION! 33 XODARAPPARADOX

Warm-up You can prove a language is Regular by drawing a DFA that recognizes the language. a)TRUE b)FALSE c)Not enough information to decide between (a) and (b) d)Other Dr. Lee wrote down number 5. a)TRUE b)FALSE c)Not enough information to decide between (a) and (b) d)Other 34

This sentence is false. a)TRUE b)FALSE c)Not enough information to decide between (a) and (b) d)Other 35

Liar’s Paradox “This sentence is false.” – This has been perplexing people since at least the Greeks in 4 th century BCE (2300 years!) What are some key features of this that make it a paradox? 36

Two more examples This sentence is 36 characters long. a)TRUE b)FALSE c)Not enough information to decide between (a) and (b) d)Other 37 This sentence is in French. a)TRUE b)FALSE c)Not enough info d)Other

The Barber A certain town has only one barber (a man). Every man in the town is clean-shaven. For each man m in the town, the barber shaves m if and only if m does not shave himself. Question: Does the barber shave himself? a)YES b)NO c)Not enough information d)Other 38

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. 39

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 40

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). Pop culture version: 41