Equivalence of Pushdown Automata and Context-Free Grammar Prof. Héctor Muñoz-Avila.

Slides:



Advertisements
Similar presentations
Theory of Computation CS3102 – Spring 2014 A tale of computers, math, problem solving, life, love and tragic death Nathan Brunelle Department of Computer.
Advertisements

Chapter 5 Pushdown Automata
C O N T E X T - F R E E LANGUAGES ( use a grammar to describe a language) 1.
Pushdown Automata CPSC 388 Ellen Walker Hiram College.
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 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 … NPDAs continued. 2 Pushing Strings Input symbol Pop symbol Push string.
Applied Computer Science II Chapter 2 : Context-free languages Prof. Dr. Luc De Raedt Institut für Informatik Albert-Ludwigs Universität Freiburg Germany.
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.
Costas Busch - RPI1 NPDAs Accept 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.
Courtesy Costas Busch - RPI1 NPDAs Accept Context-Free Languages.
CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Lecture 4 Context-free grammars Jan Maluszynski, IDA, 2007
1 Normal Forms for Context-free Grammars. 2 Chomsky Normal Form All productions have form: variable and terminal.
Fall 2004COMP 3351 NPDA’s Accept Context-Free Languages.
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2009 with acknowledgement.
1 Normal Forms for Context-free Grammars. 2 Chomsky Normal Form All productions have form: variable and terminal.
CS5371 Theory of Computation Lecture 8: Automata Theory VI (PDA, PDA = CFG)
1 Context-Free Languages. 2 Regular Languages 3 Context-Free Languages.
January 15, 2014CS21 Lecture 61 CS21 Decidability and Tractability Lecture 6 January 16, 2015.
Fall 2006Costas Busch - RPI1 PDAs Accept Context-Free Languages.
Today Chapter 2: (Pushdown automata) Non-CF languages CFL pumping lemma Closure properties of CFL.
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.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 7 Mälardalen University 2010.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 8 Mälardalen University 2010.
Pushdown Automata (PDA) Part 2 While I am distributing graded exams: Design a PDA to accept L = { a m b n : m  n; m, n > 0} MA/CSSE 474 Theory of Computation.
CSCI 2670 Introduction to Theory of Computing September 21, 2005.
Pushdown Automata CS 130: Theory of Computation HMU textbook, Chap 6.
Pushdown Automata (PDAs)
Design contex-free grammars that generate: L 1 = { u v : u ∈ {a,b}*, v ∈ {a, c}*, and |u| ≤ |v| ≤ 3 |u| }. L 2 = { a p b q c p a r b 2r : p, q, r ≥ 0 }
Context-free Languages
Equivalence of Pushdown Automata and Context-Free Grammars (1) Theorem. Given a context-free grammar CG = ( ,NT,R,S), then there is a pushdown automaton.
Equivalence of Pushdown Automata and Context-Free Grammars (1) Theorem. Given a context-free grammar CG = ( ,NT,R,S), then there is a pushdown automaton.
Prof. Busch - LSU1 NFAs accept the Regular Languages.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 11 Midterm Exam 2 -Context-Free Languages Mälardalen University 2005.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2010 with acknowledgement.
Lecture 14UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 14.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 2 Context-Free Languages Some slides are in courtesy.
Nondeterministic Finite Automata (NFAs). Reminder: Deterministic Finite Automata (DFA) q For every state q in Q and every character  in , one and only.
Pushdown Automata Hopcroft, Motawi, Ullman, Chap 6.
1.Draw a parse tree for the following derivation: S  C A C  C A b b  b b A b b  b b B b b  b b a A a a b b  b b a b a a b b 2. Show on your parse.
Grammar Set of variables Set of terminal symbols Start variable Set of Production rules.
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
Summary of Previous Class There are languages that are not decidable –(we have not proved this yet) Why not extend Turing machines just as we did with.
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.
Costas Busch - LSU1 PDAs Accept Context-Free Languages.
Lecture 11  2004 SDU Lecture7 Pushdown Automaton.
Recap: Nondeterministic Finite Automaton (NFA) A deterministic finite automaton (NFA) is a 5-tuple (Q, , ,s,F) where: Q is a finite set of elements called.
Formal Languages, Automata and Models of Computation
Deterministic FA/ PDA Sequential Machine Theory Prof. K. J. Hintz
NPDAs Accept Context-Free Languages
Pushdown Automata PDAs
PDAs Accept Context-Free Languages
Pushdown Automata PDAs
NPDAs Accept Context-Free Languages
CSE322 The Chomsky Hierarchy
Chapter 2 Context-Free Language - 01
… NPDAs continued.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
Normal Forms for Context-free Grammars
Presentation transcript:

Equivalence of Pushdown Automata and Context-Free Grammar Prof. Héctor Muñoz-Avila

Two Crucial Concepts Nondeterministic computation –Give us flexibility for constructing devices and understanding the power/limitations of these devices Induction –Allow us to prove statements that otherwise would be hard to see why they are true In this class(es), we will illustrate these two powerful concepts once more

Class Convention regarding Transitions in Pushdown Automata Strictly speaking, Transitions have the form: –  :(Q × (   {e}) × (   {e}) )   ( Q × (   {e}) ) (q’,  ))   ((q, , )) We are going to allow to pop and push words in (   {e})* –Can we represent a transition that pops/pushes words in (   {e})* with transitions that pop/pushes characters in (   {e}) ? –Careful: order of pushing/popping individual characters matter! –To avoid confusion, view the stack as a word and push/pop as adding/removing strings prefix from that word qq’ ,  

My Solution of the Homework Construct a pushdown automaton for words in {a,b} such that the number of a’s is twice the number of b’s –3 states –Pushing marker for bottom of stack –….

Equivalence of Pushdown Automata and Context-Free Grammars (part I) Theorem. (Lemma 2.21) Given a context-free grammar CG = ( ,V,R,S), then there is a pushdown automaton PA = (Q, , , ,s,F) such that L(CG) = L(PA) Construction: e, e  e, e  S (for each rule terminal  in  ) ,   e e, C  w (for each rule C  w in R) (this rule needs to be expanded) e,  e q

Sketch of the Proof S   1 T 1  1 where  1,  1 are in  * and T 1 is in (   V)*   1  2 T 2  2  1 where  2 is in in  * and T 2 is in (   V)* (taking the leftmost non terminal in T 1 ) … (always taking the leftmost non terminal)   1  2…  n  n …  1 (s,  1  2 …  n  n  1, e)  (q,  1  2 …  n  n  1, S)  (q,  1  2 …  n  n  1,  1 T 1  1 )  * (q,  2 …  n  n  1, T 1  1 )  (q,  2 …  n  n  1,  2 T 2  2  1 )  * (q,  3 …  n  n  2  1,T 2  2  1 )  * (q, e,e) (Excluded for simplicity)

Equivalence of Pushdown Automata and Context-Free Grammars (Part II) Theorem. (Lemma 2.27) Given a pushdown automata PA = (Q, , , ,s,F) then, there exists a context-free grammar CG = ( ,V,R,S) such that L(PA) = L(CG) Assumptions: 1.PA has only one accepting state 2.Stack is empty when accepting a word 3.Each transitions pops XOR pushes one element in the stack

Constructing the Grammar CG (1) CG will contain the variables: A pq for every two states p and q in PA A pq generates a word w PA empty-process w from p to q PA empty-process w from p to q –w is given as input starting on state p with empty stack –then PA will nondeterministically process all characters in w ending with the empty word in state q and the empty stack

Constructing the Grammar CG (2) We are going to construct three kinds of rules for CG: –A pq  aA rs b for all p, q, r, s in Q, all a, b in (   {e}), and all t in  such that the following two transitions occur in the PA: –A pq  A pr A rq for all p, q, r in Q – A pp  e for all p in Q pr a, e  t sq b, t  e That’s it! Can you see it?

Proving that CG is equivalent to PA (1) If A pq generates a word w then PA empty-process w from p to q Proof by induction on # steps in A pq  * w Basis: # steps is 1 Induction: holds for k # steps, need to prove for k+1 # steps –Two sub-cases depending of which rule was applied first: A pq  aA rs b or A pq  A pr A rq

Proving that CG is equivalent to PA (2) If PA empty-process w from p to q then A pq generates a word w Proof by induction on # steps in processing w Basis: # steps is 0 Induction: holds for k # steps, need to prove for k+1 # steps –Two sub-cases depending on the following: Stack is empty only at the beginning and at the end of process or Stack gets empty somewhere in-between

Corollary Let s be the start state in PA Let f be the accepting state in PA Therefore, A sf is the start variable in CG We just proved that: A sf generates a word w if and only if PA accepts w

Homework Show that if L 1 and L 2 are context-free languages then: –L 1  L 2 is a context-free language –L 1 L 2 is a context-free language (hint: if L 1 and L 2 are context free, then there is two grammars G 1 generating L 1 and G 2 generating L 2. How can you combine G 1 and G 2 to generate the union and concatenation?)