1 91.304 Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2009 with acknowledgement.

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
Pushdown Automata Section 2.2 CSC 4170 Theory of Computation.
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,
CS21 Decidability and Tractability
1 Introduction to Computability Theory Lecture12: Decidable Languages Prof. Amos Israeli.
PDAs => CFGs Sipser 2.2 (pages ). Last time…
PDAs => CFGs Sipser 2.2 (pages ). Last time…
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
Introduction to Computability Theory
CFG => PDA Sipser 2 (pages ).
1 Introduction to Computability Theory Lecture7: PushDown Automata (Part 1) Prof. Amos Israeli.
CFG => PDA Sipser 2 (pages ). CS 311 Fall Formally… A pushdown automaton is a sextuple M = (Q, Σ, Γ, δ, q 0, F), where – Q is a finite set.
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.
Chap 2 Context-Free Languages. Context-free Grammars is not regular Context-free grammar : eg. G 1 : A  0A1substitution rules A  Bproduction rules B.
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.1: Context-Free Grammars) David Martin With some.
CS 310 – Fall 2006 Pacific University CS310 Pushdown Automata Sections: 2.2 page 109 October 9, 2006.
CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Lecture 4 Context-free grammars Jan Maluszynski, IDA, 2007
Fall 2004COMP 3351 NPDA’s Accept Context-Free Languages.
Fall 2006Costas Busch - RPI1 Pushdown Automata PDAs.
January 14, 2015CS21 Lecture 51 CS21 Decidability and Tractability Lecture 5 January 14, 2015.
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.
CS5371 Theory of Computation Lecture 8: Automata Theory VI (PDA, PDA = CFG)
Fall 2006Costas Busch - RPI1 PDAs Accept Context-Free Languages.
Prof. Busch - LSU1 Pushdown Automata PDAs. Prof. Busch - LSU2 Pushdown Automaton -- PDA Input String Stack States.
1 Pushdown Automata PDAs. 2 Pushdown Automaton -- PDA Input String Stack States.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
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.
Final Exam Review Cummulative Chapters 0, 1, 2, 3, 4, 5 and 7.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 8 Mälardalen University 2010.
CSCI 2670 Introduction to Theory of Computing September 21, 2005.
Pushdown Automata CS 130: Theory of Computation HMU textbook, Chap 6.
Pushdown Automata (PDAs)
Context-free Languages
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 11 Midterm Exam 2 -Context-Free Languages Mälardalen University 2005.
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.
Pushdown Accepters & Context-Free Grammars Sipser, Theorem 2.12 Denning, Chapter 8.
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.
PushDown Automata. What is a stack? A stack is a Last In First Out data structure where I only have access to the last element inserted in the stack.
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2010 with acknowledgement.
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.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen Department of Computer Science University of Texas-Pan American.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Pushdown.
Pushdown Automata Hopcroft, Motawi, Ullman, Chap 6.
Grammar Set of variables Set of terminal symbols Start variable Set of Production rules.
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
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.
Formal Languages, Automata and Models of Computation
CSE 105 theory of computation
CSE 105 theory of computation
Pushdown Automata PDAs
PDAs Accept Context-Free Languages
Chapter 2 Context-Free Language - 01
CSE 105 theory of computation
… NPDAs continued.
CSE 105 theory of computation
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
Pushdown automata The Chinese University of Hong Kong Fall 2011
CSE 105 theory of computation
CSE 105 theory of computation
CSE 105 theory of computation
Presentation transcript:

Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2009 with acknowledgement to: -Sipser Introduction to the Theory of Computation textbook and -Dr. David Martin

2 Overview  New computational model: Pushdown Automata (like NFA, but add a stack)  Definition, Examples  Equivalence with Context-Free Grammars Theorem 2.20: A language is context-free iff some pushdown automaton recognizes it. Lemma 2.21 ( ) If a language is context-free, then some pushdown automaton recognizes it. Lemma 2.27 ( ) If a pushdown automaton recognizes some language, then it is context-free.

3 Pushdown Automata Definition  Like NFA, but add a stack Source: Sipser Textbook

4 Pushdown Automata Definition  Formal Definition (6-tuple uses nondeterminism) : Source: Sipser Textbook

5 Pushdown Automata Definition  Formal Definition: Specification of F,  Source: Sipser Textbook

6 Pushdown Automata Examples Source: Sipser Textbook

7 Pushdown Automata Examples  Example 2.16 Source: Sipser Textbook

8 Pushdown Automata Examples  Example 2.18 Source: Sipser Textbook

9 Equivalence with Context-Free Grammars  Theorem 2.20: A language is context-free iff some pushdown automaton recognizes it.  Lemma 2.21 ( ) If a language is context- free, then some pushdown automaton recognizes it.  Lemma 2.27 ( ) If a pushdown automaton recognizes some language, then it is context- free. Source: Sipser Textbook

10 Equivalence with Context-Free Grammars  Lemma 2.21 ( ) If a language is context- free, then some pushdown automaton recognizes it. Proof Idea: Produce a pushdown automaton P from the context-free grammar G for the context-free language.  If G generates w, then P accepts its input w by checking if there’s a derivation for w. Each step of derivation yields an intermediate string.  Keep only part of this string on the stack.  (see next slide for illustration) Nondeterminism guesses sequence of correct substitutions for a derivation. Source: Sipser Textbook

11 Equivalence with Context-Free Grammars: Lemma 2.21 ( )  Proof Idea (again): Produce a pushdown automaton P from the context-free grammar G for the context-free language.  Each step of derivation yields an intermediate string. Keep only part of this string on the stack. Source: Sipser Textbook

12 Equivalence with Context-Free Grammars: Lemma 2.21 ( )  Proof Idea (again): Produce a pushdown automaton P from the context-free grammar G for the context-free language. Source: Sipser Textbook

13 Equivalence with Context-Free Grammars: Lemma 2.21 ( )  Proof Idea (again): Produce a pushdown automaton P from the context-free grammar G for the context-free language.  Substituting string on right-hand side of a rule. means when P is in state q, a is next input symbol, and s is symbol on top of stack, P reads a, pops s, pushes u onto stack and goes to state r. Source: Sipser Textbook

14 Equivalence with Context-Free Grammars: Lemma 2.21 ( )  Proof Idea (again): Produce a pushdown automaton P from the context-free grammar G for the context-free language. Source: Sipser Textbook Recall informal description of P :

15 Equivalence with Context-Free Grammars: Lemma 2.21 ( )  Proof Idea (again): Produce a pushdown automaton P from the context-free grammar G for the context-free language.  Example: Source: Sipser Textbook

16 Equivalence with Context-Free Grammars: Lemma 2.27 ( )  Lemma 2.27 ( ) If a pushdown automaton P recognizes some language, then it is context-free. Proof Idea:  Design grammar G that does more: Create variable A pq for each pair of states p and q in P.  A pq generates all strings taking P from p with empty stack to q with empty stack (overkill!) To support this, first modify P so that:  It has a single accept state q accept.  It empties its stack before accepting.  Each transition either pushes a symbol onto the stack or pops one off the stack (not simultaneous). Source: Sipser Textbook

17 Equivalence with Context-Free Grammars: Lemma 2.27 ( )  Lemma 2.27 ( ) If a pushdown automaton P recognizes some language, then it is context-free. Proof Idea (continued): Design grammar G that does more (continued):  Understand how P operates on strings (e.g. string x ): First move must be a push (why?) Last move must be a pop (why?) Intermediate moves: 2 cases  Case 1: Symbol popped at end is symbol pushed at beginning.  Case 2: Otherwise, pushed symbol pushed at start is pushed somewhere in between. Source: Sipser Textbook

18 Equivalence with Context-Free Grammars: Lemma 2.27 ( )  Lemma 2.27 ( ) If a pushdown automaton P recognizes some language, then it is context-free. Recall: means when P is in state q, a is next input symbol, and s is symbol on top of stack, P reads a, pops s, pushes u onto stack and goes to state r. Source: Sipser Textbook

19 Equivalence with Context-Free Grammars: Lemma 2.27 ( )  Lemma 2.27 ( ) If a pushdown automaton P recognizes some language, then it is context-free. Source: Sipser Textbook

20 Equivalence with Context-Free Grammars: Lemma 2.27 ( )  Lemma 2.27 ( ) If a pushdown automaton P recognizes some language, then it is context-free. Source: Sipser Textbook

21 Equivalence with Context-Free Grammars: Lemma 2.27 ( )  Lemma 2.27 ( ) If a pushdown automaton P recognizes some language, then it is context-free. Show construction (previous 3 slides) works by proving:  A pq generates x iff x can bring P from state p with empty stack to state q with empty stack.  Claim 2.30: If A pq generates x, then x can bring P from state p with empty stack to state q with empty stack. Proof is by induction on number of steps in deriving x from A pq. (see textbook for details)  Claim 2.31: If x can bring P from state p with empty stack to state q with empty stack, then A pq generates x. Proof is by induction on number of steps in computation of P that goes from state p to state q with empty stacks on input x. (see textbook for details) Source: Sipser Textbook

22 A Consequence of Lemma 2.27  Corollary 2.32: Every regular language is context free. Proof Idea:  Every regular language is recognized by a finite automaton.  Every finite automaton is a pushdown automaton that ignores its stack.  Lemma 2.27 (rephrased): Every pushdown automaton can be associated with a context-free grammar.  Now apply transitivity. Source: Sipser Textbook

23 Picture so far ALL FIN Each point is a language in this Venn diagram REG RPP B = { 0 n 1 n | n ¸ 0 } { 0101,  } 0 * (101)* F = { a i b j c k | i1 or j=k } CFL Does this exist? Source: Dr. David Martin