cs 3102 Theory of Computation Class 6 Pushdown



























- Slides: 27
cs 3102: Theory of Computation Class 6: Pushdown Automata Spring 2010 University of Virginia David Evans
Menu • Revisiting and Reversing the Pumping Lemma • Recognizing Non-Regular Languages • Pushdown Automata
Revisiting the Pumping Lemma If input string is longer than |Q|, some state must repeat. y qi q 0 z x If A is a regular language, then there is some number p (the pumping length) where for any string s A and |s| p , s may be divided into three pieces, s = xyz , such that |y|> 0, |xy| p , and for any i 0, xy iz A. qz
y qi q 0 x z Pumping Game for Language A 1. Player 1: picks p 2. Player 2: picks s A and |s| p 3. Player 1: picks x, y, z, |y|> 0, |xy| p , s = xyz 4. Player 2: picks i 0 Player 1 wins if xy iz A, Player 2 wins if xy iz A If Player 1 can always win: A is regular If Player 2 can always win: A is not regular What if Player 2 picks an s A? qz
y qi q 0 x z Pump-Priming Game for Language A 1. Player 1: picks p 2. Player 2: picks s A and |s| p 3. Player 1: picks x, y, z, |y|> 0, |xy| p , s = xyz 4. Player 2: picks i 0 Player 1 wins if xy iz A, Player 2 wins if xy iz A If Player 1 can always win: A is regular If Player 2 can always win: A is not regular qz
A = { w | w has more 0 s than 1 s } Pump-Priming Game for Language A 1. Player 1: picks p 2. Player 2: picks s A and |s| p 3. Player 1: picks x, y, z, |y|> 0, |xy| p , s = xyz 4. Player 2: picks i 0 Player 1 wins if xy iz A, Player 2 wins if xy iz A If Player 1 can always win: A is regular
A Complementary View • Regular Languages are closed under complement : if A is regular, then Ā is regular Proof sketch: DFA M = (Q, , , q 0, F) recognizes A. DFA M = (Q, , , q 0, Q F) recognizes Ā. • Thus, Player 2 wins by showing either A or Ā is non-regular.
All Languages Regular Languages an b n ww R s Can be recognized by some DFA Finite Languages What do we need to add to a DFA to recognize some non-regular languages?
DFA + Counter? A = a nb n
DFA + Counter? A = a nb n a, count = count + 1 count = 0 b, count = count 1 Accept if count == 0.
DFA + Stack = Deterministic Pushdown Automaton A = a nb n
DFA + Stack = Deterministic Pushdown Automaton A = a nb n b, pop a a, push a b, pop a Accept if stack is empty.
Formalizing DPDA Note: Sipser only defines Nondeterministic PDA and calls it PDA.
DPDA Transitions Inputs: state, alphabet symbol or ε, popped stack symbol or ε Outputs: state, stack symbol to push or ε q 1 a, ε A q 2 It is a deterministic machine: must always follow possible ε-input transition.
Deterministic Pushdown Automaton A = a nb n Bottom of stack marker q 0 ε, ε $ a, ε + q 1 b, + ε This looks like nondeterminism, but is not: must always take possible ε-transitions a state with an (ε, h) transitions cannot have any other (a, h) transitions; a state with a (a, ε) transition, cannot have any other (a, h) transitions q 2 ε, $ ε q 3
A = { w | w has more 0 s than 1 s }
Computing Model for DPDA + + push + + + pop + + + $ $ $ First, we need to model the stack!
Modeling the Stack
Modeling the Stack This would be a normal way to define a stack, but not what we use!
DPDA Computation Model
No push or pop: Push only: Pop only: Push and pop: This rule actually covers all four cases if we make
Dealing with -transitions Remember the NFA DFA proof?
DPDA Computing Model where Where E is the forced-follow -transitions function defined by:
Acceptance: PDA accepts w when: Accepting State Model Empty Stack Model Is the set of languages accepted by DPDAs with each model the same? A good, original proof is worth a challenge bonus. (Finding a published proof is not. )
Henceforth: assume DPDA is Accepting-State DPDA Power of DPDAs L(DPDA) L(DFA) ? 1. Prove there is some DPDA that recognizes every regular language. Construct DPDA from DFA by adding empty stack transitions: 2. Prove there is some language that can be recognized by a DPDA that cannot be recognized by any PDA.
All Languages DPDA Languages (Accepting State) an b n Regular Languages Can be recognized by some DFA s Finite Languages
Charge • Thursday: – Non-equivalence of NPDA and DPDA – Context-Free Grammars • Next Tuesday: – PS 2 Due – Languages that cannot be recognized by NPDA



























