Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSCI 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Pushdown.

Similar presentations


Presentation on theme: "CSCI 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Pushdown."— Presentation transcript:

1 CSCI 3130: Automata theory and formal languages Andrej Bogdanov http://www.cse.cuhk.edu.hk/~andrejb/csc3130 The Chinese University of Hong Kong Pushdown automata Fall 2010

2 Motivation regular expression DFANFA syntactic computational CFGpushdown automaton syntactic computational is more powerful than

3 Pushdown automata versus NFA state control 0100 input NFA

4 Pushdown automata state control 0100 input pushdown automaton (PDA) … stack A PDA is like an NFA with but with an infinite stack

5 Pushdown automata state control 0100 input pushdown automaton (PDA) $ 01 stack … 1 As the PDA is reading the input, it can push / pop symbols from the top of the stack

6 Building a PDA L = { 0 n 1 n : n ≥ 1} state control We remember each 0 by pushing x onto the stack read 1 pop x read 0 push x pop $ push $ read 1 pop x When we see a 1, we pop an x from the stack We want to accept when we hit the stack bottom $ = special marker for bottom

7 A PDA in action L = { 0 n 1 n : n ≥ 1} state control 0001 input $ xx stack x … 11 read 0 push x read 1 pop x pop $ push $ pop x

8 Notation for PDAs read, pop / push read 1 pop x read 0 push x pop $ push $ read 1 pop x 1, x /  0,  / x , $ /  ,  / $ 1, x /  q0q0 q1q1 q2q2 q3q3

9 Definition of a PDA A pushdown automaton is (Q, , , , q 0, F) where: –Q is a finite set of states; –  is the input alphabet; –  is the stack alphabet –q 0 in Q is the initial state; –F  Q is a set of final states; –  is the transition function  : Q  (   {  })  (   {  }) → subsets of Q  (   {  }) stateinput symbol pop symbol statepush symbol

10 Example  : Q  (   {  })  (   {  }) → subsets of Q  (   {  })  (q 0, ,  ) = {(q 1, $ )}  (q 0, , $ ) = ∅  (q 0, , x ) = ∅  (q 0, 0,  ) = ∅...  = { 0, 1 }  = { $, x } 1, x /  0,  / x , $ /  ,  / $ 1, x /  q0q0 q1q1 q2q2 q3q3 stateinput symbol pop symbol statepush symbol

11 The language of a PDA A PDA is nondeterministic Multiple transitions on same pop/input allowed Transitions may but do not have to push or pop The language of a PDA is the set of all strings in  * that can lead the PDA to an accepting state


Download ppt "CSCI 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Pushdown."

Similar presentations


Ads by Google