1 Module 32 Pushdown Automata (PDA’s) –definition –example.

Slides:



Advertisements
Similar presentations
Chapter 5 Pushdown Automata
Advertisements

Pushdown Automata Section 2.2 CSC 4170 Theory of Computation.
1 Pushdown Automata (PDA) Informally: –A PDA is an NFA-ε with a stack. –Transitions are modified to accommodate stack operations. Questions: –What is a.
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.
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 We define configurations and computations of PDA’s We define L(M) for PDA’s.
1 … NPDAs continued. 2 Pushing Strings Input symbol Pop symbol Push string.
Courtesy Costas Busch - RPI1 Pushdown Automata PDAs.
CS 310 – Fall 2006 Pacific University CS310 Pushdown Automata Sections: 2.2 page 109 October 9, 2006.
1 Module 33 Pushdown Automata (PDA’s) –Another example.
1 Lecture 30 Pushdown Automata (PDA’s) –definition –example.
Fall 2004COMP 3351 Pushdown Automata PDAs. Fall 2004COMP 3352 Pushdown Automaton -- PDA Input String Stack States.
Fall 2006Costas Busch - RPI1 Pushdown Automata PDAs.
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.
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)
Lecture Pushdown Automata. stack stack head finite control tape head tape.
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.
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.
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.
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,
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 10 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
1 Section 12.2 Pushdown Automata A pushdown automaton (PDA) is a finite automaton with a stack that has stack operations pop, push, and nop. PDAs always.
Theory of Computation Automata Theory Dr. Ayman Srour.
Theory of Languages and Automata By: Mojtaba Khezrian.
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.
Formal Languages, Automata and Models of Computation
Theory of Computation Pushdown Automata pda Lecture #10.
CSE 105 theory of computation
Pushdown Automata PDAs
Push-down Automata Section 3.3 Wed, Oct 27, 2004.
Pushdown Automata PDAs
Pushdown Automata PDAs
Pushdown Automata PDAs
Pushdown Automata (PDA). Part 3
CSE 105 theory of computation
… NPDAs continued.
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,
Presentation transcript:

1 Module 32 Pushdown Automata (PDA’s) –definition –example

2 Pushdown Automata Definition and Motivating Example

3 PDA’s In this presentation we introduce the PDA model of computation (programming language). –We first begin with an example NFA –We augment this NFA with external memory in the form of a counter –We then transform the counter into a stack to produce a PDA We define configurations and computations of these new computational models We define L(M) for these new computational models

4 NFA for {a m b n | m,n >= 0} * What strings end up in each state of the above NFA? –A: –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 ABC

5 NFA + for {a n b n | n >=0 } /\ a b ABC NFA a;add 1 ABC b;substract 1 /\ /\;only if count 0 Initialize count 0 NFA + Imagine we now have memory in the form of a counter which we can increment or decrement every time we see an input character. When we see an a in state A, we do the following two actions: 1) We increment the counter value by 1. 2) We stay in state A. When we see a b in state B, we do the following two actions: 1) We decrement the counter value by 1. 2) We stay in state B. From state B, we allow a /\-transition to state C only if 1) The counter has value 0. Finally, when we begin, the counter should have value 0.

6 Defining Configurations of NFA + a;add 1 ABC b;substract 1 /\ /\;only if count 0 Initialize count 0 NFA + The following information needs to be recorded in a configuration of a computation of an NFA + M on an input string x. 1) Current state 2) Remaining input to be processed 3) Current counter value Note, the counter is NOT part of the input. It is part of the computational model. Its current value needs to be recorded in a configuration.

7 Computation Graph of NFA + a;add 1 ABC b;substract 1 /\ /\;only if count 0 Initialize count 0 NFA + Computation graph for this NFA + on the input string aabb (A,aabb,0) (C,aabb,0)(B,bb,2) (B,abb,1)(A,bb,2)(B,aabb,0) (A,abb,1) (B,b,1)(B,/\,0) (C,/\,0)

8 Questions about NFA + * a;add 1 ABC b;substract 1 /\ /\;only if count 0 Initialize count 0 NFA + 1) Why can this NFA + accept {a n b n | n >= 0}? That is, how do we get around the Myhill-Nerode Theorem? 2) What happens if the counter has a finite capacity? For example, it can only go up to 10. Can some NFA + still accept {a n b n | n >= 0}? 3) Suppose that we have a stack data structure instead of a counter. Can we do anything we could with the counter?

9 PDA for {a n b n | n >= 0} a;add 1 ABC b;substract 1 /\ /\;only if count 0 Initialize count 0 NFA + Here is a pushdown automaton (PDA) for this language. A PDA is essentially an NFA augmented with an infinite capacity stack. The “pushdown” part of the name supposedly comes from the stacks trays in cafeterias where you have to pushdown on the stack to add a tray to it. In this example, only one character a is ever pushed onto the stack. ABC b;popa;push a /\;only if stack is empty PDA /\ Initialize stack to empty

10 Defining Configurations of PDA The following information needs to be recorded in a configuration of a computation of an PDA M on an input string x. 1) Current state 2) Remaining input to be processed 3) Current stack contents. Note again, the stack is NOT part of the input. It is part of the computational model. However, its current value needs to be recorded in a configuration. We will represent the stack contents by a string of characters. The leftmost character is on top of the stack. The rightmost character is at the bottom of the stack. We will represent an empty stack with the string /\. ABC b;popa;push a /\;only if stack is empty PDA /\ Initialize stack to empty

11 Computation Graph of PDA Computation graph for this PDA on the input string aabb (A,aabb,/\) (C,aabb,/\) (B,bb,aa) (B,abb,a)(A,bb,aa)(B,aabb,/\) (A,abb,a) (B,b,a)(B,/\,/\) (C,/\,/\) ABC b;popa;push a /\;only if stack is empty PDA /\ Initialize stack to empty

12 PDA for {a n b n | n >= 0} 1) The first black character is the current input symbol. 2) The second red character is the current top stack symbol. 3) The third string of characters is the stack update action. The stack character Z is a special character which we will always keep on the bottom of the stack. Note it is part of , though, so it may be used other places as well. ABC b;popa;push a /\;only if stack is empty PDA /\ Initialize stack to empty ABC b;a;pop a;a;push a a;Z; push a /\;Z;- /\;a;- /\;Z;- Our actual PDA Initialize stack to empty (only contains Z)

13 Computation Graph of PDA Computation graph for this PDA on the input string aabb (A,aabb,Z) (C,aabb,Z) (B,bb,aaZ) (B,abb,aZ)(A,bb,aaZ) (A,abb,aZ) (B,aabb,Z) (B,b,aZ)(B,/\,Z) (C,/\,Z) ABC b;a;pop a;a;push a a;Z; push a /\;Z;- /\;a;- /\;Z;- Our actual PDA Initialize stack to empty (only contains Z)

14 Formal Definition of PDA A PDA M = (Q, , , q 0, Z, A,  ) Items common to NFAs Q is the set of states  is the input alphabet q 0 is the initial state A is the set of accepting states Modified/New items  is the stack alphabet - Z is a special character in  - The stack always begins containing 1 Z  : modified as follows: pops/reads top stack symbol as well as current input character describes how to update stack note push /\ results in pop! Q = {I, B, C}  = {a,b}  = {Z, a} q 0 = I Z is the initial stack character A = {C} :: stateinputtop stacknext statestack 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 Our actual PDA Initialize stack to empty (only contains Z)

15 L(M) for a PDA Computation graph for this PDA on the input string aabb (A,aabb,Z) (A,abb,aZ) (B,aabb,  ) (C,aabb,  ) (B,abb,aZ)(A,bb,aaZ) (B,bb,aaZ) (B,b,aZ) (B,,Z) (C  ) A string x is in L(M) if and only if it there exists an accepting configuration (q, /\, anything) in the computation graph of M on x. An accepting configuration satisfies the following two conditions : 1) The PDA must be in an accepting state 2) The input string must be completely processed Note, the stack contents is unimportant. This is known as acceptance by final state. An accepting configuration. Not an accepting configuration because the remaining input string is not /\. Not an accepting configuration because the state B is not an accepting state. ABC b;a;- a;a;aa a;Z;aZ /\;Z;Z /\;a;a /\;Z;Z Our actual PDA Initialize stack to empty (only contains Z)

16 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

17 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 which is a proper superset of DCFL

18 PDA Comments Note, we can use the stack for much more than just a counter See examples in section 6.1 for some details