1 Module 32 Pushdown Automata (PDA’s) –definition –Example We define configurations and computations of PDA’s We define L(M) for PDA’s.

Slides:



Advertisements
Similar presentations
Pushdown Automata Section 2.2 CSC 4170 Theory of Computation.
Advertisements

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 Chapter 12. Recognizing Context-Free Languages We need a device similar to an FSM except that it needs more power. The insight: Precisely.
1 Module 20 NFA’s with -transitions –NFA- ’s Formal definition Simplifies construction –LNFA- –Showing LNFA  is a subset of LNFA (extra credit) and therefore.
Pushdown Automata Part II: PDAs and CFG Chapter 12.
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 Module 32 Pushdown Automata (PDA’s) –definition –example.
Courtesy Costas Busch - RPI1 Pushdown Automata PDAs.
Module 28 Context Free Grammars Definition of a grammar G
1 Module 33 Pushdown Automata (PDA’s) –Another example.
1 Lecture 30 Pushdown Automata (PDA’s) –definition –example.
1 Normal Forms for Context-free Grammars. 2 Chomsky Normal Form All productions have form: variable and terminal.
1 Module 18 NFA’s –nondeterministic transition functions computations are trees, not paths –L(M) and LNFA LFSA subset of LNFA –Comparing computational.
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2009 with acknowledgement.
Lecture 18 NFA’s with -transitions –NFA- ’s Formal definition Simplifies construction –LNFA- –Showing LNFA  is a subset of LNFA and therefore a subset.
Fall 2004COMP 3351 Pushdown Automata PDAs. Fall 2004COMP 3352 Pushdown Automaton -- PDA Input String Stack States.
Fall 2006Costas Busch - RPI1 Pushdown Automata PDAs.
1 Lecture 16 NFA’s –nondeterministic transition functions computations are trees, not paths –L(M) and LNFA LFSA subset of LNFA –Comparing computational.
CS5371 Theory of Computation Lecture 8: Automata Theory VI (PDA, PDA = CFG)
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.
Finite State Machines Data Structures and Algorithms for Information Processing 1.
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.
CS490 Presentation: Automata & Language Theory Thong Lam Ran Shi.
Pushdown Automata CS 130: Theory of Computation HMU textbook, Chap 6.
Pushdown Automata (PDAs)
Pushdown Automata Part I: PDAs Chapter Recognizing Context-Free Languages Two notions of recognition: (1) Say yes or no, just like with FSMs (2)
Push-down Automata Section 3.3 Fri, Oct 21, 2005.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 11 Midterm Exam 2 -Context-Free Languages Mälardalen University 2005.
1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 6 Mälardalen University 2010.
Complexity and Computability Theory I Lecture #11 Instructor: Rina Zviel-Girshin Lea Epstein.
Lecture # 22. PDA of language {a n b n : n=0,1,2,3, …}
Chapter 7 Pushdown Automata
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.
1 Pushdown Automata There are context-free languages that are not regular. Finite automata cannot recognize all context-free languages.
CSCI 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Pushdown.
1 Pushdown Automata Definition Moves of the PDA Languages of the PDA Deterministic PDA’s.
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.
Push Down Automata Chapter 14. Introduction We have seen different types of languages so far –Regular Languages –Nonregular Languages –Context Free Languages.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Pushdown.
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.
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,
CS 154 Formal Languages and Computability March 10 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
CS 154 Formal Languages and Computability March 15 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
Theory of Computation Automata Theory Dr. Ayman Srour.
Lecture 11  2004 SDU Lecture7 Pushdown Automaton.
Pushdown Automata - like NFA-  but also has a stack - transition takes the current state, the current input symbol, and the top-of-the-stack symbol (which.
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.
6. Pushdown Automata CIS Automata and Formal Languages – Pei Wang.
Theory of Computation Pushdown Automata pda Lecture #10.
Pushdown Automata PDAs
Pushdown Automata PDAs
Pushdown Automata PDAs
Pushdown Automata PDAs
Pushdown Automata.
Pushdown Automata.
Pushdown Automata (PDA). Part 3
Recap lecture 37 New format for FAs, input TAPE, START, ACCEPT , REJECT, READ states Examples of New Format of FAs, PUSHDOWN STACK , PUSH and POP states,
Nondeterministic Finite State Automata (Dr. Torng)
More About Nondeterminism
Presentation transcript:

1 Module 32 Pushdown Automata (PDA’s) –definition –Example We define configurations and computations of PDA’s We define L(M) for PDA’s

2 Pushdown Automata Definition and Motivating Example

3 Pushdown Automata (PDA) In this presentation we introduce the PDA model of computation (programming language). –The key addition to a PDA (from an NFA-/\) is the addition of external memory in the form of an infinite capacity stack The word “pushdown” comes from the stacks of trays in cafeterias where you have to pushdown on the stack to add a tray to it.

4 NFA for {a m b n | m,n >= 0} What strings end up in each state of the above NFA? –I: –B: –C: Consider the language {a n b n | n >= 0}. This NFA can recognize strings which have the correct form, –a’s followed by b’s. However, the NFA cannot remember the relative number of a’s and b’s seen at any point in time. /\ a b IBC

5 PDA for {a n b n | n >=0 } * /\ a b IBC NFA Imagine we now have memory in the form of a stack which we can use to help remember how many a’s we have seen by pushing onto and popping from the stack When we see an a in state I, we do the following two actions: 1) We push an a on the stack. 2) We stay in state I. When we see a b in state B, we do the following two actions: 1) We pop an a from the stack. 2) We stay in state B. From state B, we allow a /\-transition to state C only if 1) The stack is empty. Finally, when we begin, the stack should be empty. IBC b;popa;push a /\;only if stack is empty PDA /\ Initialize stack to empty

6 Formal PDA definition PDA M = (Q, , , q 0, Z, A,  ) Modified elements –  is the stack alphabet Z is a special character that is initially on the stack Often used to represent an empty stack –  is modified as follows Pop to read the top character on the stack Stack update action –What to push back on the stack –If we push /\, then the net result of the action is a pop

7 Example PDA Q = {I, B, C}  = {a,b}  = {Z, a} q 0 = I Z is the initial stack character A = {C}  : S aTopStNSstack update IaaIpush aa IaZIpush aZ I/\aBpush a I/\ZBpush Z BbaBpush /\ B/\ZCpush Z IBC b;a;/\ a;a; aa a;Z; aZ /\;Z;Z /\;a;a /\;Z;Z Example PDA Initialize stack to only contain Z

8 Computing with PDA’s * Configurations change compared with NFA-/\’s –Configuration components: current state remaining input to be processed stack contents Computations are essentially the same as with NFA-/\’s given the modified configurations –Determining which transitions of a PDA can be applied to a given configuration is more complicated though

9 Computation Graph of PDA Computation graph for this PDA on the input string aabb (I,aabb,Z) (C,aabb,Z) (B,bb,aaZ) (B,abb,aZ)(I,bb,aaZ) (I,abb,aZ) (B,aabb,Z) (B,b,aZ)(B,/\,Z) (C,/\,Z) Q = {I, B, C}  = {a,b}  = {Z, a} q 0 = I Z is the initial stack character A = {C}  : S aTopStNSstack update IaaIpush aa IaZIpush aZ I/\aBpush a I/\ZBpush Z BbaBpush /\ B/\ZCpush Z

10 Definition of |- Input string aabb (I, aabb, Z) |- (I,abb,aZ) (I, aabb, Z) |- (B, aabb, Z) (I, aabb, Z) |- 2 (C, aabb, Z) (I, aabb, Z) |- 3 (B, bb, aaZ) (I, aabb, Z) |- * (B, abb, aZ) (I, aabb, Z) |- * (B, /\, Z) (I, aabb, Z) |- * (C, /\, Z) IBC b;a;/\ a;a; aa a;Z; aZ /\;Z;Z /\;a;a /\;Z;Z (I,aabb,Z) (C,aabb,Z) (B,bb,aaZ) (B,abb,aZ)(I,bb,aaZ) (I,abb,aZ) (B,aabb,Z) (B,b,aZ) (B,/\,Z) (C,/\,Z)

11 Acceptance and Rejection M accepts string x if one of the configurations reached is an accepting configuration (q 0, x, Z) |- * (f, /\  ),f in A,  in  * Stack contents can be anything M rejects string x if all configurations reached are either not halting configurations or are rejecting configurations IBC b;a;/\ a;a; aa a;Z; aZ /\;Z;Z /\;a;a /\;Z;Z Input string aabb (I,aabb,Z) (C,aabb,Z) (B,bb,aaZ) (B,abb,aZ)(I,bb,aaZ) (I,abb,aZ) (B,aabb,Z) (B,b,aZ) (B,/\,Z) (C,/\,Z) Not an accepting configuration since input not completely processed Not an accepting configuration since state is not accepting An accepting configuration

12 Defining L(M) and LPDA L(M) (or Y(M)) –The set of strings ? N(M) –The set of strings ? LPDA –Language L is in language class LPDA iff ? M accepts string x if one of the configurations reached is an accepting configuration (q 0, x, Z) |- * (f, /\  ),f in A,  in  * Stack contents can be anything M rejects string x if all configurations reached are either not halting configurations or are rejecting configurations

13 Deterministic PDA’s A PDA is deterministic if its transition function satisfies both of the following properties –For all q in Q, a in  union {/\}, and X in , the set  (q,a,X) has at most one element –For all q in Q and X in G, if  (q, /\, X) { }, then  (q,a,X) = { } for all a in  A computation graph is now just a path again Our default assumption is that PDA’s are nondeterministic

14 Two forms of nondeterminism Trans Current Input Top of Next Stack # State Char. Stack State Update q 0 a Z q 0 aZ 2 q 0 a Z q 0 aa 3 q0 /\ Z q0 aZ 4 q0 a Z q0 aa

15 LPDA and DCFL A language L is in language class LPDA if and only if there exists a PDA M such that L(M) = L A language L is in language class DCFL (Deterministic Context-Free Languages) if and only if there exists a deterministic PDA M such that L(M) = L To be proven –LPDA = CFL –CFL is a proper superset of DCFL

16 PDA Comments Note, we can use the stack for much more than just a counter See examples in chapter 7 for some details