Lecture 14UofH - COSC 3340 - Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 14.

Slides:



Advertisements
Similar presentations
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
Advertisements

Theory of Computation CS3102 – Spring 2014 A tale of computers, math, problem solving, life, love and tragic death Nathan Brunelle Department of Computer.
Lecture 23UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 23.
Pushdown Automata (PDA)
Pushdown Automata Part II: PDAs and CFG Chapter 12.
PDAs => CFGs Sipser 2.2 (pages ). Last time…
PDAs => CFGs Sipser 2.2 (pages ). Last time…
Introduction to Computability Theory
1 Introduction to Computability Theory Lecture7: PushDown Automata (Part 1) Prof. Amos Israeli.
Lecture 3UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 3.
CS5371 Theory of Computation
Introduction to the Theory of Computation John Paxton Montana State University Summer 2003.
CS 310 – Fall 2006 Pacific University CS310 Pushdown Automata Sections: 2.2 page 109 October 11, 2006.
Transparency No. P2C3-1 Formal Language and Automata Theory Chapter 3 Pushdown Automata and Context-Free Languages.
Chap 2 Context-Free Languages. Context-free Grammars is not regular Context-free grammar : eg. G 1 : A  0A1substitution rules A  Bproduction rules B.
CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Lecture 4 Context-free grammars Jan Maluszynski, IDA, 2007
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2009 with acknowledgement.
January 14, 2015CS21 Lecture 51 CS21 Decidability and Tractability Lecture 5 January 14, 2015.
CS5371 Theory of Computation Lecture 8: Automata Theory VI (PDA, PDA = CFG)
January 15, 2014CS21 Lecture 61 CS21 Decidability and Tractability Lecture 6 January 16, 2015.
Lecture 9UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 9.
Fall 2006Costas Busch - RPI1 PDAs Accept Context-Free Languages.
Fall 2005Costas Busch - RPI1 Pushdown Automata PDAs.
1 Pushdown Automata PDAs. 2 Pushdown Automaton -- PDA Input String Stack States.
1 PDAs Accept Context-Free Languages. 2 Context-Free Languages (Grammars) Languages Accepted by PDAs Theorem:
CS 3240: Languages and Computation Pushdown Automata & CF Grammars NOTE: THESE ARE ONLY PARTIAL SLIDES RELATED TO WEEKS 9 AND 10. PLEASE REFER TO THE TEXTBOOK.
CSCI 2670 Introduction to Theory of Computing September 21, 2005.
نظریه زبان ها و ماشین ها فصل دوم Context-Free Languages دانشگاه صنعتی شریف بهار 88.
Lecture 2UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 2.
Pushdown Automata (PDA) Intro
CSCI 2670 Introduction to Theory of Computing September 20, 2005.
Pushdown Automata CS 130: Theory of Computation HMU textbook, Chap 6.
Pushdown Automata (PDAs)
Lecture Pushdown Automata. stack stack head finite control tape head tape.
Lecture 10UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 10.
Equivalence of Pushdown Automata and Context-Free Grammar Prof. Héctor Muñoz-Avila.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2010 with acknowledgement.
Lecture 11UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 11.
Formal Languages, Automata and Models of Computation
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Pushdown.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 2 Context-Free Languages Some slides are in courtesy.
Lecture 24UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 24.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Pushdown.
Pushdown Automata Hopcroft, Motawi, Ullman, Chap 6.
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 8 Mälardalen University 2011.
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.
CS 154 Formal Languages and Computability March 15 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
About Grammars Hopcroft, Motawi, Ullman, Chap 7.1, 6.3, 5.4.
Costas Busch - LSU1 PDAs Accept Context-Free Languages.
Theory of Computation Automata Theory Dr. Ayman Srour.
CS6800 Advance Theory of Computation Spring 2016 Nasser Alsaedi
Lecture 11  2004 SDU Lecture7 Pushdown Automaton.
COSC 3340: Introduction to Theory of Computation
COSC 3340: Introduction to Theory of Computation
Pushdown Automata (PDA). Part 2
COSC 3340: Introduction to Theory of Computation
COSC 3340: Introduction to Theory of Computation
COSC 3340: Introduction to Theory of Computation
COSC 3340: Introduction to Theory of Computation
Chapter 5 Pushdown Automata
COSC 3340: Introduction to Theory of Computation
COSC 3340: Introduction to Theory of Computation
COSC 3340: Introduction to Theory of Computation
Chapter 2 Context-Free Language - 01
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
COSC 3340: Introduction to Theory of Computation
COSC 3340: Introduction to Theory of Computation
Presentation transcript:

Lecture 14UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 14

UofH - COSC Dr. Verma 2 PDA’s and CFG’s For every CFG G there is a PDA M such that L(G) = L(M) For every PDA M there is a CFG G such that L(M) = L(G)

Lecture 14UofH - COSC Dr. Verma 3 CFG  PDA Given CFG G = (V, , R, S) Let PDA M = (Q, ,   V  {$}, , q start, {q accept }) – Q = {q start, q loop,q accept }  contains transitions for the form 1. ((q start, ,  ), (q loop, S$))   2. For each rule A  w  R(G) there is a transition ((q loop, , A),(q loop, w))   *** 3. For each symbol    ((q loop, ,  ), (q loop,  ))   4. ((q loop, , $), (q accept,  ))   q start q loop q accept ,  S$ , $   , A  w ,  

Lecture 14UofH - COSC Dr. Verma 4 CFG  PDA The PDA simulates a leftmost derivation of the string. 1. Place the marker symbol $ and the start variable on the stack. 2. Repeat the following steps forever (a)If the top of stack is a variable symbol A, nondeterministically select on of the rules for A and substitute A by the string on the right-hand side of the rule. (b)If the top of stack is terminal symbol , read the next symbol from the input and compare it to . If they match, repeat. If they do not match, reject on this branch of the nondeterminism. (c)If the top of stack is the symbol $, enter the accept state. Doing so accepts the input if it has all been read.

Lecture 14UofH - COSC Dr. Verma 5 Example: S  aSb |  Z is used instead of $ Instead of  q0 = q start q1 = q loop q2 = q accept

Lecture 14UofH - COSC Dr. Verma 6 JFLAP SIMULATION

Lecture 14UofH - COSC Dr. Verma 7 JFLAP SIMULATION

Lecture 14UofH - COSC Dr. Verma 8 JFLAP SIMULATION

Lecture 14UofH - COSC Dr. Verma 9 JFLAP SIMULATION

Lecture 14UofH - COSC Dr. Verma 10 JFLAP SIMULATION

Lecture 14UofH - COSC Dr. Verma 11 JFLAP SIMULATION

Lecture 14UofH - COSC Dr. Verma 12 JFLAP SIMULATION

Lecture 14UofH - COSC Dr. Verma 13 JFLAP SIMULATION

Lecture 14UofH - COSC Dr. Verma 14 JFLAP SIMULATION

Lecture 14UofH - COSC Dr. Verma 15 JFLAP SIMULATION

Lecture 14UofH - COSC Dr. Verma 16 JFLAP SIMULATION

Lecture 14UofH - COSC Dr. Verma 17 JFLAP SIMULATION

Lecture 14UofH - COSC Dr. Verma 18 JFLAP SIMULATION

Lecture 14UofH - COSC Dr. Verma 19 JFLAP SIMULATION

Lecture 14UofH - COSC Dr. Verma 20 JFLAP SIMULATION

Lecture 14UofH - COSC Dr. Verma 21 JFLAP SIMULATION

Lecture 14UofH - COSC Dr. Verma 22 JFLAP SIMULATION

Lecture 14UofH - COSC Dr. Verma 23 JFLAP SIMULATION

Lecture 14UofH - COSC Dr. Verma 24 JFLAP SIMULATION

Lecture 14UofH - COSC Dr. Verma 25 JFLAP SIMULATION

Lecture 14UofH - COSC Dr. Verma 26 JFLAP SIMULATION

Lecture 14UofH - COSC Dr. Verma 27 JFLAP SIMULATION

Lecture 14UofH - COSC Dr. Verma 28 JFLAP SIMULATION

Lecture 14UofH - COSC Dr. Verma 29 JFLAP SIMULATION

Lecture 14UofH - COSC Dr. Verma 30 JFLAP SIMULATION

Lecture 14UofH - COSC Dr. Verma 31 JFLAP SIMULATION

Lecture 14UofH - COSC Dr. Verma 32 Idea of PDA  CFG First, we simplify our task by modifying P slightly to give it the following three features 1. It has a single accept state, q accept. 2. It empties its stack before accepting. 3. Each transition either pushes a symbol onto the stack (a push move) or pops one off the stack (a pop move), but does not do both at the same time.

Lecture 14UofH - COSC Dr. Verma 33 PDA  CFG Suppose P = {Q, , , Δ, q 0, {q accept }} to construct G. The variables of G are {A pq | p, q  Q}. A pq generates all the strings that can take P from p with an empty stack to q with an empty stack. Two possibilities occur during P’s computation on x. Either the symbol popped at the end is the symbol pushed at the beginning or not. First, simulated by Type 1 rules on next slide and the second by Type 2 rules.

Lecture 14UofH - COSC Dr. Verma 34 PDA  CFG The start variable is A q0qaccept. Now we describe G’s rules. – [Type 1] For each p, q, r, s  Q, t  , and a, b   , if ((p, a,  ), (r, t)) is in Δ and ((s, b, t), (q,  )) is in Δ, put the rule A pq  aA rs b in G. – In other words, find pairs of transitions in the PDA such that the first transition in the pair pushes a symbol t and the second transition pops the same symbol t. Each such pair of transitions gives a Type 1 rule. The states p, q, r, s, and the symbols a, b are determined by looking at the transitions in the pair.

Lecture 14UofH - COSC Dr. Verma 35 PDA  CFG – [Type 2] For each p, q, r  Q put the rule A pq  A pr A rq in G. – [Type 3] Finally, for each p  Q put the rule A pp   in G.

Lecture 14UofH - COSC Dr. Verma 36 Example Let M be the PDA for {a n b n | n > 0} – Note that n cannot be 0, which makes the example a little simpler. M = {{p, q}, {a, b}, {a}, , p, {q}}, where  = {((p, a,  ),(p, a)),((p, b, a), (q,  )),((q, b, a),(q,  ))} p q

Lecture 14UofH - COSC Dr. Verma 37 Example: contd. CFG, G = (V, {a, b}, A pq, R) corresponding to M has V = {A pp, A pq, A qp, A qq }. R contains the following rules: Type I: – A pq  aA pp b – A pq  aA pq b Type II: – A pp  A pp A pp | A pq A qp – A pq  A pp A pq | A pq A qq – A qp  A qp A pp | A qq A qp – A qq  A qp A pq | A qq A qq Type III: – A pp   – A qq   We can discard all rules containing the variables A qq and A qp. And we can also simplify the rules containing A pp and get the grammar with just two rules A pq  ab and A pq  aA pq b.

Lecture 14UofH - COSC Dr. Verma 38 JFLAP SIMULATION

Lecture 14UofH - COSC Dr. Verma 39 JFLAP SIMULATION

Lecture 14UofH - COSC Dr. Verma 40 JFLAP SIMULATION

Lecture 14UofH - COSC Dr. Verma 41 JFLAP SIMULATION

Lecture 14UofH - COSC Dr. Verma 42 JFLAP SIMULATION

Lecture 14UofH - COSC Dr. Verma 43 JFLAP SIMULATION