Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSCI 2670 Introduction to Theory of Computing September 22, 2004.

Similar presentations


Presentation on theme: "CSCI 2670 Introduction to Theory of Computing September 22, 2004."— Presentation transcript:

1 CSCI 2670 Introduction to Theory of Computing September 22, 2004

2 2 Agenda Today –Pushdown automata Tomorrow –More on pushdown automata –Pumping lemma for CFG’s

3 September 22, 20043 Announcement Quiz tomorrow (9/23) –Deriving & defining CFG’s –Chomsky normal form Office hours changed today –2:15 – 3:15 (or by appointment)

4 September 22, 20044 Pushdown automata Similar to finite automata, but for CFG’s Finite automata are not adequate for CFG’s because we cannot keep track of what we’ve done –At any point, we only know the current state, not previous states Need memory –PDA’s are finite automata with a stack

5 September 22, 20045 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

6 September 22, 20046 Example read 0 & push 0 on stack read ε & push ε on stack read ε & push $ on stack read 1 & pop 0 off stack read ε & pop $ off stack Language accepted: {0 n 1 n | n  0}

7 September 22, 20047 Differences between PDA’s and NFA’s Transitions read a symbol of the string and push a symbol onto or pop a symbol off of the stack Stack alphabet is not necessarily the same as the alphabet for the language –e.g., $ marks bottom of stack in previous (0 n 1 n ) example

8 September 22, 20048 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.

9 September 22, 20049 Strings accepted by a PDA Let w be any string in  *. If 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

10 September 22, 200410 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

11 September 22, 200411 Example Nested parentheses ε,ε$ε,ε$ (, ε  ( ε,$  ε ),(  ε


Download ppt "CSCI 2670 Introduction to Theory of Computing September 22, 2004."

Similar presentations


Ads by Google