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
Lecture 24 MAS 714 Hartmut Klauck
Advertisements

CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
Pushdown Automata Chapter 12. Recognizing Context-Free Languages Two notions of recognition: (1) Say yes or no, just like with FSMs (2) Say yes or no,
Pushdown Automata Chapter 12. Recognizing Context-Free Languages We need a device similar to an FSM except that it needs more power. The insight: Precisely.
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.
Programming Languages Wrap-up. Your Toolkit Object-oriented Imperative Functional Logic.
Recap CS605: The Mathematics and Theory of Computer Science.
1 CSC3130 Formal Languages and Automata Theory Tutorial 9 Undecidable Problem KN Hung SHB 1026.
CS21 Decidability and Tractability
1 Introduction to Computability Theory Lecture14: Recap Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture12: Decidable Languages Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture12: Reductions Prof. Amos Israeli.
Introduction to Computability Theory
CS5371 Theory of Computation
61 Nondeterminism and Nodeterministic Automata. 62 The computational machine models that we learned in the class are deterministic in the sense that the.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
CS 302: Discrete Math II A Review. An alphabet Σ is a finite set (e.g., Σ = {0,1}) A string over Σ is a finite-length sequence of elements of Σ For x.
Lecture 3 Goals: Formal definition of NFA, acceptance of a string by an NFA, computation tree associated with a string. Algorithm to convert an NFA to.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
1 Polynomial Time Reductions Polynomial Computable function : For any computes in polynomial time.
CS5371 Theory of Computation Lecture 6: Automata Theory IV (Regular Expression = NFA = DFA)
Lecture 3 Goals: Formal definition of NFA, acceptance of a string by an NFA, computation tree associated with a string. Algorithm to convert an NFA to.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
Final Exam Review Cummulative Chapters 0, 1, 2, 3, 4, 5 and 7.
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.
Formal Language Finite set of alphabets Σ: e.g., {0, 1}, {a, b, c}, { ‘{‘, ‘}’ } Language L is a subset of strings on Σ, e.g., {00, 110, 01} a finite language,
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 7 Mälardalen University 2010.
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.
CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
1 Unit 1: Automata Theory and Formal Languages Readings 1, 2.2, 2.3.
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.
Theory of Computation, Feodor F. Dragan, Kent State University 1 Regular expressions: definition An algebraic equivalent to finite automata. We can build.
Introduction to CS Theory Lecture 3 – Regular Languages Piotr Faliszewski
CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
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.
Cs3102: Theory of Computation Class 24: NP-Completeness Spring 2010 University of Virginia David Evans.
CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
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,
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2010.
CHAPTER 1 Regular Languages
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 11 Midterm Exam 2 -Context-Free Languages Mälardalen University 2005.
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.
Pushdown Automata Chapters Generators vs. Recognizers For Regular Languages: –regular expressions are generators –FAs are recognizers For Context-free.
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.
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.
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2010 with acknowledgement.
CSCI 2670 Introduction to Theory of Computing October 13, 2005.
Nondeterministic Finite Automata (NFAs). Reminder: Deterministic Finite Automata (DFA) q For every state q in Q and every character  in , one and only.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
Pushdown Automata Chapter 12. Recognizing Context-Free Languages Two notions of recognition: (1) Say yes or no, just like with FSMs (2) Say yes or no,
1 Chapter Pushdown Automata. 2 Section 12.2 Pushdown Automata A pushdown automaton (PDA) is a finite automaton with a stack that has stack operations.
Computability. Turing Machines Read input letter & tape letter, write tape letter, move left or right.
CSE 105 theory of computation
PDAs Accept Context-Free Languages
CSE 105 theory of computation
CSE 2001: Introduction to Theory of Computation Fall 2013
CSE 105 theory of computation
Jaya Krishna, M.Tech, Assistant Professor
Deterministic PDAs - DPDAs
CS21 Decidability and Tractability
Instructor: Aaron Roth
MA/CSSE 474 Theory of Computation Nondeterminism NFSMs.
CSE 105 theory of computation
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

TODAY, HOW DO WE COPE WITH INTRACTABLE PROBLEMS? While P vs NP is still a mystery 2

Mapping Reducibility and NP-Completeness There are a class of problems that are known to be in NP (can be solved in polynomial time using nondeterminism), but no deterministic polynomial time algorithm has ever been discovered to solve any of them – Boolean equation satisfiability – Traveling salesman – Various graph problems (Clique, Independent Set, …) – Various scheduling optimization problems – FreeCell (Windows game), Sudoku – Map coloring Amazingly, all these problems can be to each other This means that a polynomial-time solution to ONE is a polynomial time solution to ALL !! 3

NP-Complete Problems No deterministic polynomial-time algorithm is known for any of the NP-complete problems But there are many NP-complete problems that we need answers to! Work-around: – Use randomization with a variety of sometimes very sophisticated optimization techniques to “guesstimate” the best answer we can – Examples: Genetic Algorithms, Simulated Annealing 4

Traveling Salesperson Genetic algorithm iteratively searches for better and better solutions – Some offspring/mutations prove to be beneficial, others not – More genetic algorithm: – This one evolves car designs, with their “fitness” evaluated according to a particular terrain – 5

REDUCTIONS FROM ATM ONE MORE EXAMPLE Relevant both to Homework and Final Exam 6

How do we design Z? I hope you have a better understanding now of the “big picture,” but now the question is, “OK, but how do I do that?” For many languages you want to show are undecidable* (*options for some other languages are discussed on a later slide), there are a few simple steps: – Z(s): 1.(optional—it just makes it easier for me personally to think about Z’s design) reject any strings that are “extra” so you only have a few strings left to deal with 2.If needed, accept a few strings that will make L(Z) not have the property M T tests for (you may not need step 2, if L(Z) = {} is an L(Z) that does not have the property M T tests for) 3.Accept more strings if M(w) accepts (if M(w) rejects then reject)— make sure that step 3 will make L(Z) have the property M T tests for (could involve accepting all strings if M(w) accepts—the following examples show this—or only accepting particular strings if M(w) accepts) On the next two slides, Z is labeled with these 1,2,3 steps so you can see how it works

Thm. REGULAR TM = { | M is a TM and L(M) is a regular language} is undecidable Proof by contradiction: (Reduce from A TM.) Assume REGULAR TM is decidable by TM M R. Use M R to construct TM D ATM that decides A TM. D ATM ( ): – Construct a TM Z: – Z(x): 1.(n/a) 2.If x has the form 0 n 1 n for some n >=0, then accept. 3.Run M(w). If it accepts, accept. If it rejects, reject. – Run M R (Z). If it accepts then accept, otherwise reject. D ATM decides ATM. [correctness argument] But A TM is undecidable, a contradiction. So the assumption is false and T is undecidable. QED. 8 What is L(Z)? (a) Σ * (b) {“0 n 1 n ”} (c) { w | w = 0 n 1 n for some n >= 0} if M(w) accepts, otherwise Σ * (d) { w | w = 0 n 1 n for some n >= 0} if M(w) does not accept, otherwise Σ * (e) { w | w = 0 n 1 n for some n >= 0} if M(w) accepts, otherwise empty set

Thm. T = { | M is a TM that accepts w R whenever it accepts w} is undecidable Proof by contradiction: (Reduce from A TM.) Assume T is decidable by TM M T. Use M T to construct TM D ATM that decides A TM. D ATM ( ): – String Z = “Z(x): \n” + “If x != “01” and x != “10” then reject \n” + “If x == “01” accept \n” + “ ??? ”; – Run M T (Z). If it accepts then accept, otherwise reject. But A TM is undecidable, a contradiction. So the assumption is false and T is undecidable. QED. 9 How do we finish Z? (a)Run M(w), if it accepts then accept. If it rejects then reject (might loop in which case obviously Z loops). (b)Run M(w), if it accepts then reject. If it rejects then accept (might loop in which case obviously Z loops).

REVIEWING FOR THE FINAL EXAM Review 10

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 and lexicographic/alphabetic issue) 5.Prove a language is undecidable by reduction from some other language (like problem #4 on HW#4) 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) 11

Topics not on the exam Tuesday’s lecture on P/NP was largely enrichment – You will not be asked to prove from scratch that A B – You should know basic facts about what P and NP are, and why it’s a “Big Deal” PCP (5.2 in the book), entire Chapter 6 Reductions via computation histories, writing proofs using linear-bounded automata Exclusions for midterm still apply (i.e., no GNFA, no changing grammar to CNF) 12

Terminology check: “Run A TM on input M,w” What should you write instead of the above? (Assume the context is trying to test if M accepts w) a)“Run A TM on input ” b)“Run on input ” c)“Run M ATM, a TM that recognizes language A TM, on input M,w” d)“Run M ATM, a TM that recognizes language A TM, on input ” 13

Study suggestions Review lecture slides – T/F, multiple choice, drawing taken mostly from lecture Review homework – Proofs taken from homework – Some T/F, multiple choice questions incorporate proof concepts from homework Practice exam Book is there if you need more clarification of a topic – Poring over every detail of Chapters 1-5,7 in their entirety likely to be a very unproductive use of time 14

FINAL EXAM WHOLE-COURSE REVIEW Review

True (a) or False (b)? Language A = {w | “0101” is a substring of w}. It is possible to build a TM that recognizes (but does not decide) A. 16

True (a) or False (b)? Language A = {w | the first character of w is ‘1’ and the last character is ‘0’}. It is possible to build a TM that recognizes (but does not decide) A. 17

What did we do in this class? We examined a series of abstracted models of computation machines – Started with the most limited – Moved towards the most versatile Along the way, – Learned how to use each model as a handy tool in your programming life (e.g. RegExp) – Became intimate with the contours of each model’s limitations and powers – Proved things about the limitations, about the powers, and about the relationships between models

Remember this slide? 19

Which is the best description of the language recognized by the DFA M 2 ? (Σ = {a,b}) a)Starts with b and ends with b b)Starts with a and ends with b c)b‘s followed by a’s M2:M2:

Tracing in an NFA What are the two sequences of states on the input “100”? a)(q0,q0,q1,q2[accept]), (q0,q1,q2[accept]) b)(q0,q0,q1,q2[accept]), (q0,q1,q2[reject]) c)(q0,q0,q1,q2[reject]), (q0,q1,q2[reject]) “100”

Thm. The class of regular languages is closed under the union operation. Given two regular languages L1, L2, with DFAs M1, M2 – M1 = (Q1,Σ,δ1,q 0 1,F1) – M2 = (Q2,Σ,δ2, q 0 2,F2) We want to construct a DFA M = (Q,Σ,δ, q 0,F), s.t.: – Q = Q1 x Q2 – δ = – q 0 = – F = M recognizes L1 U L2 A DFA recognizes L1 U L2, then L1 U L2 must be regular Our working example: A generalized proof form: ab (r1,q1)(r2,q2)(r2,q1) (r1,q2)(r2,q2)(r2,q3) (r1,q3)(r2,q3) (r2,q1)(r1,q2)(r1,q1) (r2,q2)(r1,q2)(r1,q3) (r2,q3)(r1,q3)

Thm. The class of regular languages is closed under the union operation. Our working example: A generalized proof form: a)q0 = (r1,q1) b)q0 = (q 0 1, q 0 2) c)q0 = {(r1,q1)} d) None of the above ab (r1,q1)(r2,q2)(r2,q1) (r1,q2)(r2,q2)(r2,q3) (r1,q3)(r2,q3) (r2,q1)(r1,q2)(r1,q1) (r2,q2)(r1,q2)(r1,q3) (r2,q3)(r1,q3) Given two regular languages L1, L2, with DFAs M1, M2 – M1 = (Q1,Σ,δ1,q 0 1,F1) – M2 = (Q2,Σ,δ2, q 0 2,F2) We want to construct a DFA M = (Q,Σ,δ, q 0,F), s.t.: – Q = Q1 x Q2 – δ = – q 0 = – F = M recognizes L1 U L2 A DFA recognizes L1 U L2, then L1 U L2 must be regular

Thm. The class of regular languages is closed under the union operation. Given two regular languages L1, L2, with DFAs M1, M2 – M1 = (Q1,Σ,δ1,q 0 1,F1) – M2 = (Q2,Σ,δ2, q 0 2,F2) We want to construct a DFA M = (Q,Σ,δ, q 0,F), s.t.: – Q = Q1 x Q2 – δ = – q 0 = – F = M recognizes L1 U L2 A DFA recognizes L1 U L2, then L1 U L2 must be regular Our working example: A generalized proof form: a)δ: Q1 x Q2  Q b)δ: Q1 x Q2 x Σ  Q c)δ((x,y),c) = (δ1(x,c), δ2(y,c)) d)δ((q1,r1), a) = (r2,q2) e)None of the above ab (r1,q1)(r2,q2)(r2,q1) (r1,q2)(r2,q2)(r2,q3) (r1,q3)(r2,q3) (r2,q1)(r1,q2)(r1,q1) (r2,q2)(r1,q2)(r1,q3) (r2,q3)(r1,q3)

Thm. The class of regular languages is closed under the union operation. Our working example: A generalized proof form: a)F = {(r1,q1), (r1,q2), (r2,q1), (r2q2), (r2,q3)} b)F = F1 x F2 c)F = F1 U F2 d)F = {(x,y) in Q | x in F1 or y in F2} e)None of the above ab (r1,q1)(r2,q2)(r2,q1) (r1,q2)(r2,q2)(r2,q3) (r1,q3)(r2,q3) (r2,q1)(r1,q2)(r1,q1) (r2,q2)(r1,q2)(r1,q3) (r2,q3)(r1,q3) Given two regular languages L1, L2, with DFAs M1, M2 – M1 = (Q1,Σ,δ1,q 0 1,F1) – M2 = (Q2,Σ,δ2, q 0 2,F2) We want to construct a DFA M = (Q,Σ,δ, q 0,F), s.t.: – Q = Q1 x Q2 – δ = – q 0 = – F = M recognizes L1 U L2 A DFA recognizes L1 U L2, then L1 U L2 must be regular

Regular Expressions Let L be the language of this regular expression: ((a U Ø) + b*)* Which of the following is NOT true of L? a)Some strings in L have equal numbers of a’s and b’s b)All strings in L have more b’s than a’s c)L contains “aaaaaa” d)a‘s never follow b’s in any string in L e)None of the above

Tracing in a Pushdown Automaton Which choice depicts a stack state that occurs at some point during the successful* processing of the string “abbbc” on the given PDA? a) b) c) d) e)None of the above * Ignore all nondeterministic paths that end in rejecting/getting stuck. top of stack bottom of stack  abbbc# bbb #λ #bbb

Executing a Transition, “yields” Suppose we have at TM s.t. Γ={0,1,_}, Q = {q x | 1≤x≤7} U {q acc,q rej }, and the transition function includes rules δ(q 1,1) = (q 3,0,R) and δ(q 1,0) = (q 3,1,L). We also have strings x,v,x,y in Γ*. Which configuration does the current configuration, x0q 1 1y, yield? a)xq 3 00y b)x01q 3 y c)x00q 3 y d)xq 3 11y e)None of the above or more than one of the above 28

P = NP ???????? P = languages decidable in polynomial number of steps on deterministic TM, NP = languages decidable in polynomial number of steps on non-deterministic TM P = NP? Perhaps the greatest theoretical computation question of our time – Most people suspect no, but it has never been proven… Bunch of problems in NP, don’t know if they are in P: – Boolean equation satisfiability – Traveling salesman – Various graph problems (Clique, Independent Set, …) – Various scheduling optimization problems – FreeCell (Windows game), Sudoku – Map coloring 29