CSCI 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Pushdown automata Fall 2010
Motivation regular expression DFANFA syntactic computational CFGpushdown automaton syntactic computational is more powerful than
Pushdown automata versus NFA state control 0100 input NFA
Pushdown automata state control 0100 input pushdown automaton (PDA) … stack A PDA is like an NFA with but with an infinite stack
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
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
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
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
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
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
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