Download presentation
Presentation is loading. Please wait.
Published byPhebe White Modified over 9 years ago
1
CSCI 2670 Introduction to Theory of Computing September 21, 2005
2
September 23, 20042 Agenda Yesterday –Pushdown automata Today –Quiz –More on pushdown automata –Pumping lemma for CFG’s
3
September 23, 20043 Finite automata and PDA schematics State control a a b b State control a a b b xyzxyz FA PDA Stack: Infinite LIFO (last in first out) device
4
September 23, 20044 Definition of pushdown automaton A pushdown automaton is a 6-tuple (Q, , , ,q 0,F), where Q, , , and F are all finite sets, and 1.Q is the set of states 2. is the input alphabet 3. is the stack alphabet 4. : Q ε ε P (Q ε ) is the transition function 5.q 0 Q is the start state, and 6.F Q are the accept states.
5
September 23, 20045 Strings accepted by a PDA Let w be a string in * and P a PDA. w is in L(P) iff w can be written w=w 1 w 2 …w n, where each w i ε, and there exist r 0,r 1,…,r n Q and s 0,s 1,…,s n * satisfying the following: 1.r 0 =q 0 and s 0 =ε -M starts in the start state with an empty stack 2.(r i+1,b) (r i,w i+1,a), where s i =at and s i+1 =bt for some a,b ε and t * -M moves according to transition rules for the state, input and stack 3.r m F -accept state occurs at input end
6
September 23, 20046 A closer look at the transition rule (r i+1,b) (r i,w i+1,a), where s i =at and s i+1 =bt for some a,b ε and t * –The top symbol is Pushed if a=ε and b ε Popped if a ε and b=ε Changed if a ε and b ε Unchanged if a=ε and b=ε –Symbols below the top of the stack may be considered, but not changed This is t’s role
7
September 23, 20047 Example Find for the PDA that accepts all strings in {0,1} * with the same number of 0’s and 1’s 1.Need to keep track of “equilibrium point” with a $ on the stack 2.If stack top is not $, it contains the symbol currently dominating in the string
8
September 23, 20048 Example Find for the PDA that accepts all strings in {0,1} * with the same number of 0’s and 1’s 3.Push a symbol on the stack as its read if 1.It matches the top of the stack, or 2.The top of stack is $ 4.Pop the symbol off the top of the stack if you read a 0 and the top of stack is 1 or vice versa
9
September 23, 20049 Example ε,ε$ε,ε$ 0,$ 0$ 0,0 00 0,11 1 0,1$ $ 1,$ 1$ 1,1 11 1,00 0 1,0$ $ ε,$ ε
10
September 23, 200410 Example ε,ε$ε,ε$ 0,$ 0$ 0,0 00 0,1 ε 1,$ 1$ 1,1 11 1,0 ε ε,$ ε This PDA is equivalent to the one on the previous slide
11
September 23, 200411 Example Nested parentheses ε,ε$ε,ε$ (, ε ( ε,$ ε ),( ε
12
September 23, 200412 Equivalence of PDA’s and CFG’s Theorem: A language is context free if and only if some pushdown automaton recognizes it Proved in two lemmas – one for the “if” direction and one for the “only if” direction
13
September 23, 200413 CFG’s are recognized by PDA’s Lemma: If a language is context free, then some pushdown automaton recognizes it Proof idea: Construct a PDA following CFG rules
14
September 23, 200414 Constructing the PDA You can read any symbol in when that symbol is at the top of the stack –Transitions of the form a,a ε The rules will be pushed onto the stack – when a variable A is on top of the stack and there is a rule A w, you pop A and push w You can go to the accept state only if the stack is empty
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.