Cs3102: Theory of Computation Class 6: Pushdown Automata Spring 2010 University of Virginia David Evans TexPoint fonts used in EMF. Read the TexPoint manual.

Slides:



Advertisements
Similar presentations
Lecture 10: Context-Free Languages Contextually David Evans
Advertisements

David Evans cs302: Theory of Computation University of Virginia Computer Science Lecture 13: Turing Machines.
Pushdown Automata Section 2.2 CSC 4170 Theory of Computation.
Pushdown Automata Chapter 12. Recognizing Context-Free Languages We need a device similar to an FSM except that it needs more power. The insight: Precisely.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
CS21 Decidability and Tractability
NFAs Sipser 1.2 (pages 47–54). CS 311 Fall Recall… Last time we showed that the class of regular languages is closed under: –Complement –Union.
PDAs => CFGs Sipser 2.2 (pages ). Last time…
PDAs => CFGs Sipser 2.2 (pages ). Last time…
CFG => PDA Sipser 2 (pages ).
NFAs Sipser 1.2 (pages 47–54). CS 311 Mount Holyoke College 2 Recall… Last time we showed that the class of regular languages is closed under: –Complement.
CFG => PDA Sipser 2 (pages ). CS 311 Fall Formally… A pushdown automaton is a sextuple M = (Q, Σ, Γ, δ, q 0, F), where – Q is a finite set.
Costas Busch - RPI1 Pushdown Automata PDAs. Costas Busch - RPI2 Pushdown Automaton -- PDA Input String Stack States.
1 … NPDAs continued. 2 Pushing Strings Input symbol Pop symbol Push string.
Courtesy Costas Busch - RPI1 Pushdown Automata PDAs.
CS 310 – Fall 2006 Pacific University CS310 Pumping Lemma Sections:1.4 page 77 September 27, 2006.
Costas Busch - RPI1 NPDAs Accept Context-Free Languages.
Courtesy Costas Busch - RPI1 NPDAs Accept Context-Free Languages.
CS 310 – Fall 2006 Pacific University CS310 Pushdown Automata Sections: 2.2 page 109 October 9, 2006.
1 Converting NPDAs to Context-Free Grammars. 2 For any NPDA we will construct a context-free grammar with.
1 Normal Forms for Context-free Grammars. 2 Chomsky Normal Form All productions have form: variable and terminal.
Fall 2004COMP 3351 NPDA’s Accept Context-Free Languages.
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2009 with acknowledgement.
Fall 2004COMP 3351 Pushdown Automata PDAs. Fall 2004COMP 3352 Pushdown Automaton -- PDA Input String Stack States.
CS 490: Automata and Language Theory Daniel Firpo Spring 2003.
Today Chapter 1: RE = Regular Languages, nonregular languages RL pumping lemma Chapter 2: Context-Free Languages (CFLs)
Today Chapter 2: (Pushdown automata) Non-CF languages CFL pumping lemma Closure properties of CFL.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
1 Pushdown Automata PDAs. 2 Pushdown Automaton -- PDA Input String Stack States.
CS 3240: Languages and Computation Pushdown Automata & CF Grammars NOTE: THESE ARE ONLY PARTIAL SLIDES RELATED TO WEEKS 9 AND 10. PLEASE REFER TO THE TEXTBOOK.
Cs3102: Theory of Computation Class 10: DFAs in Practice Spring 2010 University of Virginia David Evans.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 8 Mälardalen University 2010.
Cs3102: Theory of Computation Class 2: Problems and Finite Automata Spring 2010 University of Virginia David Evans TexPoint fonts used in EMF. Read the.
Cs3102: Theory of Computation Class 4: Nondeterminism Spring 2010 University of Virginia David Evans TexPoint fonts used in EMF. Read the TexPoint manual.
Pushdown Automata (PDAs)
Context-free Languages Chapter 2. Ambiguity.
Push-down Automata Section 3.3 Fri, Oct 21, 2005.
CSCI 2670 Introduction to Theory of Computing September 22, 2005.
Cs3102: Theory of Computation Class 14: Turing Machines Spring 2010 University of Virginia David Evans.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 11 Midterm Exam 2 -Context-Free Languages Mälardalen University 2005.
Pushdown Automata Chapters Generators vs. Recognizers For Regular Languages: –regular expressions are generators –FAs are recognizers For Context-free.
Cs3102: Theory of Computation Class 8: Non-Context-Free Languages Spring 2010 University of Virginia David Evans.
Cs3102: Theory of Computation Class 5: Non-Regular Languages Spring 2010 University of Virginia David Evans TexPoint fonts used in EMF. Read the TexPoint.
Chapter 7 Pushdown Automata
PushDown Automata. What is a stack? A stack is a Last In First Out data structure where I only have access to the last element inserted in the stack.
Exercise 1 Consider a language with the following tokens and token classes: ID ::= letter (letter|digit)* LT ::= " " shiftL ::= " >" dot ::= "." LP ::=
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2010 with acknowledgement.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 9 Mälardalen University 2006.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
1 Pushdown Automata There are context-free languages that are not regular. Finite automata cannot recognize all context-free languages.
CSCI 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Pushdown.
Grammar Set of variables Set of terminal symbols Start variable Set of Production rules.
Regular Languages Chapter 1 Giorgi Japaridze Theory of Computability.
CS 154 Formal Languages and Computability March 10 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
CS 154 Formal Languages and Computability March 15 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
Lecture 11  2004 SDU Lecture7 Pushdown Automaton.
Recap: Nondeterministic Finite Automaton (NFA) A deterministic finite automaton (NFA) is a 5-tuple (Q, , ,s,F) where: Q is a finite set of elements called.
6. Pushdown Automata CIS Automata and Formal Languages – Pei Wang.
Pushdown Automata PDAs
Pushdown Automata PDAs
PDAs Accept Context-Free Languages
NPDAs Accept Context-Free Languages
Intro to Theory of Computation
Non-Deterministic Finite Automata
Non Deterministic Automata
Context-Free Grammars
Principles of Computing – UFCFA3-30-1
… NPDAs continued.
Chapter 1 Regular Language
Presentation transcript:

cs3102: Theory of Computation Class 6: Pushdown Automata Spring 2010 University of Virginia David Evans TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A A A A AA

Menu Revisiting and Reversing the Pumping Lemma Recognizing Non-Regular Languages Pushdown Automata

Revisiting the Pumping Lemma q0q0 qzqz x y z If input string is longer than |Q|, some state must repeat. qiqi 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 i z  A.

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 i z  A, Player 2 wins if xy i z  A If Player 1 can always win: A is regular If Player 2 can always win: A is not regular q0q0 qzqz x y z qiqi What if Player 2 picks an s  A ?

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 i z  A, Player 2 wins if xy i z  A If Player 1 can always win: A is regular If Player 2 can always win: A is not regular q0q0 qzqz x y z qiqi

A = { w | w has more 0s than 1s } 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 i z  A, Player 2 wins if xy i z  A If Player 1 can always win: A is regular If Player 2 can always win: A is not 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.

s All Languages Regular Languages Can be recognized by some DFA Finite Languages anbnanbn ww R What do we need to add to a DFA to recognize some non-regular languages?

DFA + Counter? A = a n b n

DFA + Counter? count = 0 A = a n b n a, count = count + 1 b, count = count  1 Accept if count == 0.

DFA + Stack = Deterministic Pushdown Automaton A = a n b n

DFA + Stack = Deterministic Pushdown Automaton a, push a b, pop a Accept if stack is empty. A = a n b n

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 ε It is a deterministic machine: must always follow possible ε -input transition. It is a deterministic machine: must always follow possible ε -input transition. a, ε  A q1q1 q2q2

Deterministic Pushdown Automaton q1q1 q2q2 a, ε  + b, +  ε A = a n b n Bottom of stack marker q0q0 b, +  ε ε, ε  $ q3q3 ε, $  ε 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

A = { w | w has more 0s than 1s }

Computing Model for DPDA First, we need to model the stack! $ push + $ pop + $ + + +

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 E is the forced-follow  -transitions function defined by: where

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.)

Power of DPDAs L(DPDA)  L(DFA) ? 1. Prove there is some DPDA that recognizes every regular language. 2. Prove there is some language that can be recognized by a DPDA that cannot be recognized by any PDA. Construct DPDA from DFA by adding empty stack transitions: Henceforth: assume DPDA is Accepting-State DPDA

s All Languages Regular Languages Can be recognized by some DFA Finite Languages anbnanbn DPDA Languages (Accepting State)

Charge Thursday: – Non-equivalence of NPDA and DPDA – Context-Free Grammars Next Tuesday: – PS2 Due – Languages that cannot be recognized by NPDA