Pushdown Automata CS 130: Theory of Computation HMU textbook, Chap 6.

Slides:



Advertisements
Similar presentations
Chapter 5 Pushdown Automata
Advertisements

Pushdown Automata Section 2.2 CSC 4170 Theory of Computation.
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,
CS21 Decidability and Tractability
Introduction to Computability Theory
1 Introduction to Computability Theory Lecture7: PushDown Automata (Part 1) Prof. Amos Israeli.
Costas Busch - RPI1 Pushdown Automata PDAs. Costas Busch - RPI2 Pushdown Automaton -- PDA Input String Stack States.
1 … NPDAs continued. 2 Pushing Strings Input symbol Pop symbol Push string.
Courtesy Costas Busch - RPI1 Pushdown Automata PDAs.
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 9, 2006.
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.
Fall 2004COMP 3351 Pushdown Automata PDAs. Fall 2004COMP 3352 Pushdown Automaton -- PDA Input String Stack States.
Fall 2006Costas Busch - RPI1 Pushdown Automata PDAs.
January 14, 2015CS21 Lecture 51 CS21 Decidability and Tractability Lecture 5 January 14, 2015.
CS 490: Automata and Language Theory Daniel Firpo Spring 2003.
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.
Fall 2005Costas Busch - RPI1 Pushdown Automata PDAs.
1 Pushdown Automata PDAs. 2 Pushdown Automaton -- PDA Input String Stack States.
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 8 Mälardalen University 2010.
CSCI 2670 Introduction to Theory of Computing September 21, 2005.
Pushdown Automata.
Pushdown Automata (PDAs)
Lecture Pushdown Automata. stack stack head finite control tape head tape.
Push-down Automata Section 3.3 Fri, Oct 21, 2005.
1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 6 Mälardalen University 2010.
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.
Grammars CS 130: Theory of Computation HMU textbook, Chap 5.
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2010 with acknowledgement.
CSCI 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Pushdown.
Formal Languages, Automata and Models of Computation
1 Pushdown Automata Definition Moves of the PDA Languages of the PDA Deterministic PDA’s.
Lecture 14 Push Down Automata (PDA) Topics:  Definition  Moves of the PDA  Languages of the PDA  Deterministic PDA’s June 18, 2015 CSCE 355 Foundations.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Pushdown.
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.
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.
Lecture 11  2004 SDU Lecture7 Pushdown Automaton.
CSCI 2670 Introduction to Theory of Computing September 22, 2004.
6. Pushdown Automata CIS Automata and Formal Languages – Pei Wang.
Formal Languages, Automata and Models of Computation
CSE 105 theory of computation
Pushdown Automata PDAs
Pushdown Automata PDAs
Pushdown Automata PDAs
Pushdown Automata PDAs
Chapter 7 PUSHDOWN AUTOMATA.
Context-Free Languages
فصل دوم Context-Free Languages
Pushdown automata a_introduction.htm.
Definition Moves of the PDA Languages of the PDA Deterministic PDA’s
Chapter 2 Context-Free Language - 01
Principles of Computing – UFCFA3-30-1
… NPDAs continued.
CSE 105 theory of computation
Pushdown automata The Chinese University of Hong Kong Fall 2011
CSE 105 theory of computation
Presentation transcript:

Pushdown Automata CS 130: Theory of Computation HMU textbook, Chap 6

PDAs: Pushdown Automata Same as Finite Automata (e.g., NFAs), but with the addition of a stack: On each transition, a stack is manipulated and monitored (operations: push, pop, inspect top, check for empty) Allows the automaton to “count” Definition will need to incorporate stack events When is a string acceptable?

PDA definition A pushdown automaton M is a tuple M = (Q, , , , q 0, Z 0, F), where: Q is a set of states  is the input alphabet  is the stack alphabet  : Q   +є    (Q   *)* is the state transition function mapping a (state, symbol, stack symbol) triple to a set of (state, string) pairs q 0 is the start state of M Z 0 is the starting stack symbol (initially on the stack) F  Q is the set of accepting states or final states of M

PDA transitions A transition between states q x and q y can be carried out in a PDA when a given next input symbol a is read and a given stack symbol X is on top of the stack When the transition to q y is carried out, the symbol X is replaced with a string w of stack symbols  (q x, a, X) contains the pair (q y, w) How are the stack operations push, pop, inspect top, and check if empty carried out? push Y on input a:  (q x, a, X) -> (q y, YX) pop Y:  (q x, a, X) -> (q y, є) How about inspect top and check if empty?

Example L = {a n b n : n >= 0} PDA M = ({q 0,q 1,q 2 }, {a,b}, {Z 0,X}, , q 0, Z 0, {q 2 })  defined (informally) as follows: On input a (from q 0 ) push X onto the stack On input b (from q 0 and q 1 ), pop X and transition to q1 (note: cannot transition if X is not on top of the stack) From q0 and q1, transition to final state q 2 if stack is “empty” (Z 0 is on top)

Transition function example  (q 0, a, Z 0 ) = {(q 0, XZ 0 )}  (q 0, a, X) = {(q 0, XX)}  (q 0, b, X) = {(q 1, є)}  (q 1, b, X) = {(q 1, є)}  (q 0, є, Z 0 ) = {(q 2, Z 0 )}  (q 1, є, Z 0 ) = {(q 2, Z 0 )}  (q 0, b, Z 0 ) =  (q 1, b, Z 0 ) =  (q 1, a, X) and many others are all equal to {} push X onto the stack on input a pop X from the stack on input b go to final state if Z 0 is on top

PDA diagram q0q0 q2q2 a, Z 0, XZ 0 a, X, XX q1q1 b, X, є є, Z 0, Z 0

Alternative diagram q0q0 q2q2 a, push X q1q1 b, pop X є, empty b, pop X

Accepting strings in a PDA By final state, just like in regular final automata Or by empty stack: string is acceptable once the stack is empty (Z 0 has been popped out), regardless of what state it is currently in These two “kinds” of PDAs are equivalent (proofs in section 6.2)

Equivalence between PDAs From PDA-by final state to PDA-by empty stack Add a state that empties the contents of the stack (one epsilon-transition back to itself that pops out any element) From each final state in the PDA add an epsilon-transition to this new state From PDA-by empty stack to PDA-by final state Add a separate final state For each transition that pops out Z 0, update it so that it transitions to the final state instead

Equivalence of PDAs and CFGs PDAs and CFGs describe the same set of languages (section 6.3) Proof requires: Construction from a grammar to an equivalent PDA Construction from a PDA to an equivalent grammar (this is harder: will not be covered in this course)

From CFG to PDA Given G = (V,T,P,S) Construct PDA M = ({q 0 }, T, V  T, , q 0, S, {}) Single-state PDA Input alphabet: terminal symbols in G Stack alphabet: terminals and non-terminals Starting stack symbol: S  is defined in terms of P

From CFG to PDA, continued  is defined as follows For each production N -> w in P: add (q 0, w) to  (q0, є, N) For each terminal symbol a:  (q0, a, a) = {(q 0, є)} The derivation of a string in G is simulated by input processing and stack operations in M

Equivalences PDA-by final statePDA-by empty stack Context free grammar All three models describe context free languages (CFLs)