1 91.304 Foundations of (Theoretical) Computer Science Chapter 5 Lecture Notes David Martin (with modifications by Karen Daniels) With thanks.

Slides:



Advertisements
Similar presentations
CS 345: Chapter 9 Algorithmic Universality and Its Robustness
Advertisements

Variants of Turing machines
Lecture 24 MAS 714 Hartmut Klauck
1 Pushdown Automata (PDA) Informally: –A PDA is an NFA-ε with a stack. –Transitions are modified to accommodate stack operations. Questions: –What is a.
THE CHURCH-TURING T H E S I S “ TURING MACHINES” Pages COMPUTABILITY THEORY.
C O N T E X T - F R E E LANGUAGES ( use a grammar to describe a language) 1.
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.
Foundations of (Theoretical) Computer Science Chapter 3 Lecture Notes (Section 3.2: Variants of Turing Machines) David Martin With.
February 6, 2015CS21 Lecture 141 CS21 Decidability and Tractability Lecture 14 February 6, 2015.
Reducibility 2 Theorem 5.1 HALT TM is undecidable.
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.
1 Introduction to Computability Theory Lecture11: Variants of Turing Machines Prof. Amos Israeli.
Introduction to Computability Theory
1 Introduction to Computability Theory Lecture7: PushDown Automata (Part 1) Prof. Amos Israeli.
CS5371 Theory of Computation
Reducibility A reduction is a way of converting one problem into another problem in such a way that a solution to the second problem can be used to solve.
Foundations of (Theoretical) Computer Science Chapter 1 Lecture Notes (more on Section 1.4) David Martin This work is licensed under.
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.1: Context-Free Grammars) David Martin With some.
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2009 with acknowledgement.
Foundations of (Theoretical) Computer Science
Foundations of (Theoretical) Computer Science Chapter 4 Lecture Notes (Section 4.1: Decidable Languages) David Martin With modifications.
Foundations of (Theoretical) Computer Science Chapter 1 Lecture Notes (Section 1.1: DFA’s) David Martin With some modifications.
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.3: Non-Context-Free Languages) David Martin With.
CS5371 Theory of Computation Lecture 8: Automata Theory VI (PDA, PDA = CFG)
February 4, 2015CS21 Lecture 131 CS21 Decidability and Tractability Lecture 13 February 4, 2015.
Foundations of (Theoretical) Computer Science Chapter 1 Lecture Notes (Section 1.4: Nonregular Languages) David Martin With some.
Foundations of (Theoretical) Computer Science Chapter 1 Lecture Notes (Section 1.2: NFA’s) David Martin With some modifications.
CS5371 Theory of Computation Lecture 12: Computability III (Decidable Languages relating to DFA, NFA, and CFG)
CSE202: Introduction to Formal Languages and Automata Theory Chapter 9 The Turing Machine These class notes are based on material from our textbook, An.
 Computability Theory Turing Machines Professor MSc. Ivan A. Escobar
TM Design Universal TM MA/CSSE 474 Theory of Computation.
Pushdown Automata (PDAs)
Turing Machines Chapter 17. Languages and Machines SD D Context-Free Languages Regular Languages reg exps FSMs cfgs PDAs unrestricted grammars Turing.
Pushdown Automata Chapters Generators vs. Recognizers For Regular Languages: –regular expressions are generators –FAs are recognizers For Context-free.
Foundations of (Theoretical) Computer Science Chapter 3 Lecture Notes (Section 3.1: Turing Machines) David Martin With some modifications.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
Automata & Formal Languages, Feodor F. Dragan, Kent State University 1 CHAPTER 3 The Church-Turing Thesis Contents Turing Machines definitions, examples,
 2005 SDU Lecture13 Reducibility — A methodology for proving un- decidability.
CS 203: Introduction to Formal Languages and Automata
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2010 with acknowledgement.
TM Design Macro Language D and SD MA/CSSE 474 Theory of Computation.
Lecture 17 Undecidability Topics:  TM variations  Undecidability June 25, 2015 CSCE 355 Foundations of Computation.
CSCI 2670 Introduction to Theory of Computing October 13, 2005.
1 Turing Machines and Equivalent Models Section 13.1 Turing Machines.
Lecture 16b Turing Machines Topics: Closure Properties of Context Free Languages Cocke-Younger-Kasimi Parsing Algorithm June 23, 2015 CSCE 355 Foundations.
Automata & Formal Languages, Feodor F. Dragan, Kent State University 1 CHAPTER 3 The Church-Turing Thesis Contents Turing Machines definitions, examples,
Unrestricted Grammars
Donghyun (David) Kim Department of Mathematics and Computer Science North Carolina Central University 1 Chapter 5 Reducibility Some slides are in courtesy.
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,
 2005 SDU Lecture11 Decidability.  2005 SDU 2 Topics Discuss the power of algorithms to solve problems. Demonstrate that some problems can be solved.
Foundations of (Theoretical) Computer Science Chapter 4 Lecture Notes (Section 4.2: The “Halting” Problem) David Martin With modifications.
CSCI 3130: Formal languages and automata theory Andrej Bogdanov The Chinese University of Hong Kong Decidable.
Theory of Computation Automata Theory Dr. Ayman Srour.
CS6800 Advance Theory of Computation Spring 2016 Nasser Alsaedi
Lecture 11  2004 SDU Lecture7 Pushdown Automaton.
February 1, 2016CS21 Lecture 121 CS21 Decidability and Tractability Lecture 12 February 1, 2016.
Pushdown Automata.
Pushdown Automata.
CSE 105 theory of computation
CSE 105 theory of computation
Turing Machines Acceptors; Enumerators
Jaya Krishna, M.Tech, Assistant Professor
Reducability Sipser, pages
CSE 105 theory of computation
CSE 105 theory of computation
Presentation transcript:

Foundations of (Theoretical) Computer Science Chapter 5 Lecture Notes David Martin (with modifications by Karen Daniels) With thanks to Giam Pecelli This work is licensed under the Creative Commons Attribution-ShareAlike License. To view a copy of this license, visit sa/2.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

2 Computation Histories  Recall the notion of configuration: (state, head_position, tape_contents).  In a deterministic TM every transition takes us from one configuration to the next.  The idea of "computation history" is based on sequences of configurations.

3 Computation Histories Definition 5.5: Let M be a TM and w a string: -An accepting computation history for M on w is a sequence of configurations C 1, C 2, …, C k, where C 1 is the start configuration of M on w, C k is an accepting configuration of M, and each C i ` C i+1 according to the rules of M. -A rejecting computation history for M on w is defined similarly, except that C k is a rejecting configuration for M.

4 Computation Histories Definition 5.6: A linear bounded automaton is a standard TM whose tape head is not allowed to move beyond the tape squares containing the input. Note: If the tape alphabet is larger than the input alphabet, the available memory can be increased by a constant factor - but the amount of memory remains a linear function of the length of the input.

5 Linear Bounded Automata  Example: (board work)  They are powerful: the following are LBAs: Decider for A DFA Decider for A CFG Decider for E DFA Decider for E CFG  Every CFL can be decided by an LBA.

6 Computation Histories Why bother? LBAs can be shown sufficient for the recognition of almost all "realistic" classes of languages, in particular CFLs: -roughly, your C program will compile (actually, parse, but who's counting?) in a ("small") constant multiple of the number of bytes necessary to store it in memory. Definition: A LBA = { h M, w i | M is an LBA that accepts w} Question: is A LBA decidable? The "general" problem (A TM ) is not…

7 Computation Histories Lemma 5.8: Let M be an LBA with q states and g symbols in the tape alphabet. Then there are exactly q*n*g n distinct configurations of M for a tape of length n. Proof. A configuration is uniquely determined 1. by the state M is in (q possibilities), 2. by the head position (n possibilities) and 3. by the tape contents (g n possibilities: g possibilities for each of the n tape positions).

8 Computation Histories Theorem 5.9. A LBA is decidable. Proof. We construct the following TM D: 1.On the first tape, store the input h M, w i. 2.On the second tape, copy w. 3.On the third tape write $1 q*n*g n (so, unary: D extracts q and g from M, n from w). Leave the head on the last 1. 4.Using the second tape, simulate M on w. 5.If M halts in the accepting or rejecting state with the head of tape 3 on a 1, accept or reject. 6.After each time an instruction of M is simulated, write a blank on tape 3 and move that head left. 7.If the head of tape 3 reaches $, reject.

9 Computation Histories Proof (continued). The reason why this works is that after q*n*g n configurations we must be repeating ourselves, and thus have fallen into a loop.QED

10 Computation Histories Theorem 5.10: E LBA = { h M i | M is an LBA where L(M) = ; } is undecidable. ( 0 ) Theorem 5.13: ALL CFG = { h G i | G is a CFG and L(G) = *} is undecidable. ( 0 )

11 Computation Histories Proof of 5.10 We'll show that NA TM · m E LBA. (textbook reduces from A TM )  On input h M, w i, the reduction will construct an LBA, say B = B h M,w i, such that M doesn't accept w iff L(B h M,w i ) is empty. We will not run B on anything, but we must show that we can construct such a B via a Turing Machine from any h M, w i.  We construct B so that it will accept input x iff x is an accepting computation history for M on w. An accepting computation history is a finite string of the form # C 1 # C 2 # … # C k # where 1.C 1 is the starting configuration of M with input w 2.for all i, the relation C i ` C i+1 holds, according to M 3.C k is an accepting configuration of M.

12 Computation Histories  One can build the initial string q 0 w into B h M,w i so the check can be performed.  One can check that the last configuration contains the accepting state - just scan down the input string of configurations.  One can check that each configuration follows legally from the previous one: check that they are identical except for the changes implied by the transition function of M. Move back and forth marking with a dot the positions just compared. When we find differences (they can be only over three adjacent characters), we check that they meet the requirements of the transitions of M.

13 Computation Histories  If all conditions are satisfied, then B h M,w i accepts this proposed computation history x, otherwise it rejects. It should be reasonably clear that a)Given as input, the reduction can produce a B h M,w i as output with this behavior. b)Such a B h M,w i is always an LBA (why?). And now: 2 NA TM, M doesn't accept w, there is no accepting computation history for M on w, B h M,w i does not accept any input, B h M,w i 2 E LBA QED

14 Computation Histories Theorem 5.13 ALL CFG = { h G i | G is a CFG and L(G) = *} is undecidable. Proof. Will show that NA TM · m ALL CFG using computation histories: given h M, w i construct a CFG G h M,w i that generates all strings, M does not accept w. If M does accept w, G h M,w i will not generate one string: the accepting computation history for M on w. We must show that we can construct this G h M,w i via a TM (the reduction) when it is given h M,w i as input. Again, an accepting computation history of M on w is a finite string of the form # C 1 # C 2 # … # C k # where 1.C 1 is the starting configuration of M with input w 2.for all i, the relation C i ` C i+1 holds, according to M 3.C k is an accepting configuration of M

15 Computation Histories For a string not to be an accepting configuration history for M on w, at least one of the three conditions must fail. If M does not accept w, no such computation history exists, thus all strings fail, and G h M,w i would generate all strings. We construct the grammar G h M,w i using the results that establish equivalence between CFGs and PDAs (all the constructions are algorithmic - thus TM performable, so we are OK).

16 Computation Histories The reduction constructs a PDA D h M,w i. It is nondeterministic, so at start we have 3 branches. This machine will accept strings that are not accepting computation histories: 1. One branch checks if the beginning of the input is C 1. Accepts if not. 2. One branch checks if the end C k contains q accept. Accepts if not. 3. One branch scans the input until it decides (non- deterministically) that is has reached a C i. It pushes the contents of C i onto the stack, and verifies that the stack contents match C i+1 except for the modifications due to the transition. Accepts if not.

17 Computation Histories The only problem is that we would be trying to match potentially unbounded strings such as C i # C i+1, and that's something we can't do in a PDA, because stacks are LIFO structures. Yet if adjacent configurations were written in reverse order of each other, it would be easy to do. This turns out to be a non-issue. For each normal accepting computation history # C 1 # C 2 # C 3 # C 4 # … # C k # there is another string that is the same except that it reverses every other component: # C 1 # C 2 R # C 3 # C 4 R # … # C k # So our PDA D h M,w i will just assume that its input is in this form rather than the ordinary form of a computation history. Then we convert our PDA into the CFG G h M,w i, and we're done. QED

18 Part of Homework  Prove that EQ CFG is undecidable. Textbook Exercise 5.1, p Recall:  EQ CFG = { | G and H are CFGs and L(G) = L(H) }

19 Landscape at end of Chapter 5 ALL FIN Each point is a language in this Venn diagram. REG RPP CFL CFPP 00 11 NA TM ALL -  1 EQ CFG  0 E LBA  0 ALL CFG  0 ? PCP  0 HALT TM  1 -  0 REGULAR TM  1 EQ TM  1 E TM  1 A TM  1 -  0 A 10  1 - 0 A DFA  0 A NFA  0 A REX  0 E DFA  0 EQ DFA  0 A CFG  0 E CFG  0 A LBA  0

20 A natural undecidable language  Post’s Correspondence Problem concerns dominos of the form a a cb b ab aa where each domino has a “top” and a “bottom” chosen from an underlying alphabet .  An instance of the problem is a finite set P={[t 1,b 1 ], [t 2,b 2 ],..., [t k,b k ]} of dominos Each t i and b i is a nonempty string over  (in other words, a member of  + ) Think of each instance P as an alphabet You can form domino strings over the alphabet P

21 Post’s Correspondence Problem  Let ={a,b,c} and P 1 ={[b,ca], [a,ab], [ca,a], [abc,c]}. Sample domino string over P 1 : ca abc a c  A domino string is a match if the concatenation of characters on its top row is equal to the concatenation of characters on its bottom row.  Repetitions of dominos are permitted.  The example above is not a match, because caabc  ac.  But we can find a match using this instance P 1. One thing we know for sure: each match must begin with same char on top & bottom...

22 abacaabaabaabcca abcaabaabcaabcabca

23 Post’s Correspondence Problem  An instance P contains a match if there is some nonempty domino string formed from P that is a match  Definition PCP = { | P is an instance that contains a match }  Theorem 5.15 PCP   0

24 Proof outline Proof Define the Modified PCP: MPCP={ | P is an instance that contains a match that begins with the domino d 1 2 P } We’ll show that A TM · m MPCP · m PCP. Most of the work is in the first reduction, which we’ll call f. The idea is that 2 A TM exactly when M goes from its initial configuration on input w into an accepting one: 2 A TM, q 0 w ` * x q acc y for some x,y 2  * We’ll construct the reduction f so that it transforms into an instance of MPCP in which a match actually describes an accepting computation history of M on w. The match is not a one-for-one rewriting of the computation history, but it's quite close.

25 Definition of reduction f A.f: input x B.if x is not of form where M is a TM, then print out some fixed string that we know isn’t in MPCP and halt C.modify M=(Q,,,,q 0,q acc,q rej ) so that: A.it still recognizes the same language as before B.but it never attempts to move left of its leftmost tape cell (substitute right-then-left motion instead) D.construct P={d 1, ,d k } using rules 1-7 (on next slides...) E.print and halt

26 Rule 1 of 7: initial configuration  This is the initial domino and it describes M's initial configuration: # #q 0 w#  This is the only domino that is bottom-heavy, meaning that it has more characters on the bottom than on the top  To get a match, there must also be dominos in the kit that are top-heavy to compensate  But most of the dominos will be perfectly balanced  This is the only domino that depends on the string w. The rest are either constant or depend on M alone. d 1 = old config on top new config on bottom

27 Example TM M {1,2,3} ={1,2,3,$, t } q0q0 q1q1 q rej q acc / $, R $ / $, R 3 / 3, L 1 / 2, R 2 / 1, L t / 3, R / R unlabeled transitions point to q rej transitions out of q acc and q rej are never actually taken... Here  on transition label represents any character of tape alphabet. Also, / R represents  R.

Rule 1: # #q 0 w# Rule 2:q 0 1 q 0 2 q 0 3 q 0 $ q 0 t Right moves$q 1 $q 1 $q 1 $q 1 $q 1 q 1 1 q 1 t q 1 $ 2q 1 3q 1 $q rej q acc 1 q acc 2 q acc 3 q acc $ q acc t 1q acc 2q acc 3q acc $q acc t q acc Rule 3: 1q 1 2 2q 1 2 3q 1 2 $q 1 2 t q 1 2 Left movesq 1 11 q 1 21 q 1 31 q 1 $1 q 1 t 1 1q 1 3 2q 1 3 3q 1 3 $q 1 3 t q 1 3 q acc 13 q acc 23 q acc 33 q acc $3 q acc t 3 Rule 4:1 2 3 $ t Copying1 2 3 $ t Rule 5: Separators# # # t # Rule 6:1q acc q acc 1 2q acc q acc 2 3q acc q acc 3 $q acc q acc $ t q acc q acc t Acceptorsq acc q acc q acc q acc q acc q acc q acc q acc q acc q acc Rule 7:q acc ## Finisher# Example kit for

29 Rule 2 of 7: right moves  Suppose (q, a) = (r,b,R). Then we want to ensure that a matched set of dominos can include this computation history snippet: … qa … ` … br … (state is now r, a is now b, moved to the right)  So, for all a,b 2  and q 2 Q-{q rej } and r 2 Q and (q, a) = (r,b,R), we add the following domino to the set P: qa old config br new config  Note: If q rej appears in a configuration, then we want to prevent a match, so we exclude dominos that might help make a partial match grow towards a full match.  Note: If q acc appears in a configuration, then we'll use rules 6 and 7 to proceed towards a match.  Note: #It's in the domino alphabet but not the TM alphabet.

Rule 1: # #q 0 w# Rule 2:q 0 1 q 0 2 q 0 3 q 0 $ q 0 t Right moves$q 1 $q 1 $q 1 $q 1 $q 1 q 1 1 q 1 t q 1 $ 2q 1 3q 1 $q rej q acc 1 q acc 2 q acc 3 q acc $ q acc t 1q acc 2q acc 3q acc $q acc t q acc Rule 3: 1q 1 2 2q 1 2 3q 1 2 $q 1 2 t q 1 2 Left movesq 1 11 q 1 21 q 1 31 q 1 $1 q 1 t 1 1q 1 3 2q 1 3 3q 1 3 $q 1 3 t q 1 3 q acc 13 q acc 23 q acc 33 q acc $3 q acc t 3 Rule 4:1 2 3 $ t Copying1 2 3 $ t Rule 5: Separators# # # t # Rule 6:1q acc q acc 1 2q acc q acc 2 3q acc q acc 3 $q acc q acc $ t q acc q acc t Acceptorsq acc q acc q acc q acc q acc q acc q acc q acc q acc q acc Rule 7:q acc ## Finisher# Example kit for

31 Rule 3 of 7: left moves  Suppose (q, a) = (r,b,L). Then we want to ensure that a matched set of dominos can include this computation history snippet: … cqa … ` … rcb … (state is now r, a is now b, moved to the right, c is unchanged)  So, for all a,b,c 2  and q 2 Q-{q acc,q rej } and r 2 Q and (q, a) = (r,b,L), we add the following domino to the set P: cqa old config rcb new config  Note that we don't care what c is; we add in one domino for each choice of c.  Also, remember that M never tries to move left when it's at the left end of the tape. So there always is some character c to the left of the tape head when moving left, and so these dominos account for all of the possible left moves.

Rule 1: # #q 0 w# Rule 2:q 0 1 q 0 2 q 0 3 q 0 $ q 0 t Right moves$q 1 $q 1 $q 1 $q 1 $q 1 q 1 1 q 1 t q 1 $ 2q 1 3q 1 $q rej q acc 1 q acc 2 q acc 3 q acc $ q acc t 1q acc 2q acc 3q acc $q acc t q acc Rule 3: 1q 1 2 2q 1 2 3q 1 2 $q 1 2 t q 1 2 Left movesq 1 11 q 1 21 q 1 31 q 1 $1 q 1 t 1 1q 1 3 2q 1 3 3q 1 3 $q 1 3 t q 1 3 q acc 13 q acc 23 q acc 33 q acc $3 q acc t 3 Rule 4:1 2 3 $ t Copying1 2 3 $ t Rule 5: Separators# # # t # Rule 6:1q acc q acc 1 2q acc q acc 2 3q acc q acc 3 $q acc q acc $ t q acc q acc t Acceptorsq acc q acc q acc q acc q acc q acc q acc q acc q acc q acc Rule 7:q acc ## Finisher# Example kit for

33 Rule 4 of 7: the faraway tape  The left move and right move dominos determine what happens in the immediate vicinity of the tape head. The rest of the tape is unaffected by the transition.  So, for every a 2 , add this domino to the kit: a

Rule 1: # #q 0 w# Rule 2:q 0 1 q 0 2 q 0 3 q 0 $ q 0 t Right moves$q 1 $q 1 $q 1 $q 1 $q 1 q 1 1 q 1 t q 1 $ 2q 1 3q 1 $q rej q acc 1 q acc 2 q acc 3 q acc $ q acc t 1q acc 2q acc 3q acc $q acc t q acc Rule 3: 1q 1 2 2q 1 2 3q 1 2 $q 1 2 t q 1 2 Left movesq 1 11 q 1 21 q 1 31 q 1 $1 q 1 t 1 1q 1 3 2q 1 3 3q 1 3 $q 1 3 t q 1 3 q acc 13 q acc 23 q acc 33 q acc $3 q acc t 3 Rule 4:1 2 3 $ t Copying1 2 3 $ t Rule 5: Separators# # # t # Rule 6:1q acc q acc 1 2q acc q acc 2 3q acc q acc 3 $q acc q acc $ t q acc q acc t Acceptorsq acc q acc q acc q acc q acc q acc q acc q acc q acc q acc Rule 7:q acc ## Finisher# Example kit for

35 Rule 5 of 7: the # separators  Add these two dominos to the kit: # # old config # t # new config  These allow the separators to be carried along.  The second domino allows a blank to be added to the right of the tape

Rule 1: # #q 0 w# Rule 2:q 0 1 q 0 2 q 0 3 q 0 $ q 0 t Right moves$q 1 $q 1 $q 1 $q 1 $q 1 q 1 1 q 1 t q 1 $ 2q 1 3q 1 $q rej q acc 1 q acc 2 q acc 3 q acc $ q acc t 1q acc 2q acc 3q acc $q acc t q acc Rule 3: 1q 1 2 2q 1 2 3q 1 2 $q 1 2 t q 1 2 Left movesq 1 11 q 1 21 q 1 31 q 1 $1 q 1 t 1 1q 1 3 2q 1 3 3q 1 3 $q 1 3 t q 1 3 q acc 13 q acc 23 q acc 33 q acc $3 q acc t 3 Rule 4:1 2 3 $ t Copying1 2 3 $ t Rule 5: Separators# # # t # Rule 6:1q acc q acc 1 2q acc q acc 2 3q acc q acc 3 $q acc q acc $ t q acc q acc t Acceptorsq acc q acc q acc q acc q acc q acc q acc q acc q acc q acc Rule 7:q acc ## Finisher# Example kit for

37 Rule 6 of 7: accepter  For every a 2 , add these two dominos to the kit: aq acc q acc a old config q acc q acc new config  This means that when q acc appears in a configuration, the adjacent characters can be squeezed out, one configuration at a time, leading towards a match  These are the top-heavy dominos to match the initial, bottom-heavy one

Rule 1: # #q 0 w# Rule 2:q 0 1 q 0 2 q 0 3 q 0 $ q 0 t Right moves$q 1 $q 1 $q 1 $q 1 $q 1 q 1 1 q 1 t q 1 $ 2q 1 3q 1 $q rej q acc 1 q acc 2 q acc 3 q acc $ q acc t 1q acc 2q acc 3q acc $q acc t q acc Rule 3: 1q 1 2 2q 1 2 3q 1 2 $q 1 2 t q 1 2 Left movesq 1 11 q 1 21 q 1 31 q 1 $1 q 1 t 1 1q 1 3 2q 1 3 3q 1 3 $q 1 3 t q 1 3 q acc 13 q acc 23 q acc 33 q acc $3 q acc t 3 Rule 4:1 2 3 $ t Copying1 2 3 $ t Rule 5: Separators# # # t # Rule 6:1q acc q acc 1 2q acc q acc 2 3q acc q acc 3 $q acc q acc $ t q acc q acc t Acceptors q acc q acc q acc q acc q acc q acc q acc q acc q acc q acc Rule 7:q acc ## Finisher# Example kit for

39 Rule 7 of 7: finisher  Add this single domino to the kit: q acc ## #  You just need it. You'll see why…

Rule 1: # #q 0 w# Rule 2:q 0 1 q 0 2 q 0 3 q 0 $ q 0 t Right moves$q 1 $q 1 $q 1 $q 1 $q 1 q 1 1 q 1 t q 1 $ 2q 1 3q 1 $q rej q acc 1 q acc 2 q acc 3 q acc $ q acc t 1q acc 2q acc 3q acc $q acc t q acc Rule 3: 1q 1 2 2q 1 2 3q 1 2 $q 1 2 t q 1 2 Left movesq 1 11 q 1 21 q 1 31 q 1 $1 q 1 t 1 1q 1 3 2q 1 3 3q 1 3 $q 1 3 t q 1 3 q acc 13 q acc 23 q acc 33 q acc $3 q acc t 3 Rule 4:1 2 3 $ t Copying1 2 3 $ t Rule 5: Separators# # # t # Rule 6:1q acc q acc 1 2q acc q acc 2 3q acc q acc 3 $q acc q acc $ t q acc q acc t Acceptors q acc q acc q acc q acc q acc q acc q acc q acc q acc q acc Rule 7:q acc ## Finisher# Example kit for

41 Example TM {1,2,3} ={1,2,3,$, t } q0q0 q1q1 q rej q acc / $, R $ / $, R 3 / 3, L 1 / 2, R 2 / 1, L t / 3, R / R unlabeled transitions point to q rej transitions out of q acc and q rej are never actually taken...

42 Examples  On board. and

43 MPCP · m PCP via g 1.g: input where P is a PCP instance and t 1 /b 1 2 P  if input is not in this form then print some string known not to be in PCP and halt 2.Assuming P={t 1 /b 1, , t k /b k }, let Q = { ¤ t 1 / ¤ b 1 ¤, ¤ t 1 /b 1 ¤, ¤ t 2 / b 2 ¤, ¤ t 3 / b 3 ¤, , ¤ t k / b k ¤, + ¦ / ¦ } 3.Print and halt where +, ¦ are not in and *abc = +a+b+c (plusses before) abc* = a+b+c+ (plusses after) *abc* = +a+b+c+ (before & after) different from textbook, where * and 5-pointed star are used

44 Purpose of construction  Each domino has some + characters on the top Only one of them has + as the first character on the top and bottom: the one that includes t 1 and b 1  Starting with this domino ¤ t 1 / ¤ b 1 ¤, you end up with an excess of + characters on the bottom The only one that can balance it is + ¦ / ¦  Otherwise, the + characters line up between each character and don’t interfere  The effect is that P contains a match starting with t 1 /b 1 exactly when Q contains any match whatsoever (since any match in it must begin with ¤ t 1 / ¤ b 1 ¤ )  Hence MPCP · m PCP via g

45 Landscape at end of Chapter 5 ALL FIN Each point is a language in this Venn diagram. REG RPP CFL CFPP 00 11 NA TM ALL -  1 EQ CFG  0 E LBA  0 ALL CFG  0 ? PCP  0 HALT TM  1 -  0 REGULAR TM  1 EQ TM  1 E TM  1 A TM  1 -  0 A 10  1 - 0 A DFA  0 A NFA  0 A REX  0 E DFA  0 EQ DFA  0 A CFG  0 E CFG  0 A LBA  0