Costas Busch - LSU1 PDAs Accept Context-Free Languages.

Slides:



Advertisements
Similar presentations
PDAs => CFGs Sipser 2.2 (pages ). Last time…
Advertisements

PDAs => CFGs Sipser 2.2 (pages ). Last time…
Introduction to Computability Theory
1 Introduction to Computability Theory Lecture7: PushDown Automata (Part 1) Prof. Amos Israeli.
Costas Busch - RPI1 Single Final State for NFAs. Costas Busch - RPI2 Any NFA can be converted to an equivalent NFA with a single final state.
Costas Busch - RPI1 Pushdown Automata PDAs. Costas Busch - RPI2 Pushdown Automaton -- PDA Input String Stack States.
Courtesy Costas Busch - RPI1 Non Deterministic Automata.
Fall 2006Costas Busch - RPI1 Regular Expressions.
1 … NPDAs continued. 2 Pushing Strings Input symbol Pop symbol Push string.
Courtesy Costas Busch - RPI1 Pushdown Automata PDAs.
Costas Busch - RPI1 NPDAs Accept Context-Free Languages.
Courtesy Costas Busch - RPI1 NPDAs Accept Context-Free Languages.
1 Converting NPDAs to Context-Free Grammars. 2 For any NPDA we will construct a context-free grammar with.
Fall 2006Costas Busch - RPI1 The Post Correspondence Problem.
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 2006Costas Busch - RPI1 Pushdown Automata PDAs.
1 Normal Forms for Context-free Grammars. 2 Chomsky Normal Form All productions have form: variable and terminal.
1 NFAs accept the Regular Languages. 2 Equivalence of Machines Definition: Machine is equivalent to machine if.
Fall 2006Costas Busch - RPI1 Non-Deterministic Finite Automata.
CS5371 Theory of Computation Lecture 8: Automata Theory VI (PDA, PDA = CFG)
Fall 2004COMP 3351 Another NFA Example. Fall 2004COMP 3352 Language accepted (redundant state)
Fall 2006Costas Busch - RPI1 PDAs Accept Context-Free Languages.
Costas Busch - LSU1 Non-Deterministic Finite Automata.
Prof. Busch - LSU1 Linear Grammars Grammars with at most one variable at the right side of a production Examples:
Prof. Busch - LSU1 Pumping Lemma for Context-free Languages.
Prof. Busch - LSU1 Pushdown Automata PDAs. Prof. Busch - LSU2 Pushdown Automaton -- PDA Input String Stack States.
Fall 2005Costas Busch - RPI1 Pushdown Automata PDAs.
1 Pushdown Automata PDAs. 2 Pushdown Automaton -- PDA Input String Stack States.
1 PDAs Accept Context-Free Languages. 2 Context-Free Languages (Grammars) Languages Accepted by PDAs Theorem:
Fall 2003Costas Busch - RPI1 Linear Grammars Grammars with at most one variable at the right side of a production Examples:
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 8 Mälardalen University 2010.
Pushdown Automata CS 130: Theory of Computation HMU textbook, Chap 6.
Pushdown Automata (PDAs)
Prof. Busch - LSU1 NFAs accept the Regular Languages.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 11 Midterm Exam 2 -Context-Free Languages Mälardalen University 2005.
1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 6 Mälardalen University 2010.
Regular Expressions Costas Busch - LSU.
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2010 with acknowledgement.
Costas Busch - LSU1 Pumping Lemma for Context-free Languages.
Formal Languages, Automata and Models of Computation
Grammar Set of variables Set of terminal symbols Start variable Set of Production rules.
1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 8 Mälardalen University 2011.
Costas Busch - LSU1 Linear Grammars Grammars with at most one variable at the right side of a production Examples:
Costas Busch - LSU1 The Post Correspondence Problem.
1 Chapter Pushdown Automata. 2 Section 12.2 Pushdown Automata A pushdown automaton (PDA) is a finite automaton with a stack that has stack operations.
CS 154 Formal Languages and Computability March 15 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
About Grammars Hopcroft, Motawi, Ullman, Chap 7.1, 6.3, 5.4.
Lecture 11  2004 SDU Lecture7 Pushdown Automaton.
6. Pushdown Automata CIS Automata and Formal Languages – Pei Wang.
Formal Languages, Automata and Models of Computation
PDAs Accept Context-Free Languages
Non Deterministic Automata
Reductions Costas Busch - LSU.
NPDAs Accept Context-Free Languages
Pushdown Automata PDAs
PDAs Accept Context-Free Languages
PDAs Accept Context-Free Languages
NPDAs Accept Context-Free Languages
DPDA Deterministic PDA
Non-Deterministic Finite Automata
Pumping Lemma for Context-free Languages
The Off-Line Machine Input File read-only (once) Input string
Undecidable problems:
Chapter 2 Context-Free Language - 01
DPDA Deterministic PDA
… NPDAs continued.
NFAs accept the Regular Languages
Normal Forms for Context-free Grammars
Presentation transcript:

Costas Busch - LSU1 PDAs Accept Context-Free Languages

Costas Busch - LSU2 Context-Free Languages (Grammars) Languages Accepted by PDAs Theorem:

Costas Busch - LSU3 Context-Free Languages (Grammars) Languages Accepted by PDAs Proof - Step 1: Convert any context-free grammar to a PDA with:

Costas Busch - LSU4 Context-Free Languages (Grammars) Languages Accepted by PDAs Proof - Step 2: Convert any PDA to a context-free grammar with:

Costas Busch - LSU5 Convert Context-Free Grammars to PDAs Proof - step 1

Costas Busch - LSU6 We will convert to a PDA such that: Take an arbitrary context-free grammar

Costas Busch - LSU7 production in terminal in Conversion Procedure: For each Add transitions

Costas Busch - LSU8 Grammar PDA Example

Costas Busch - LSU9 PDA simulates leftmost derivations Grammar Leftmost Derivation PDA Computation Scanned symbols Stack contents

Costas Busch - LSU10 Grammar Leftmost Derivation Production applied Terminals Leftmost variable Variables or terminals Terminals Variable Variables or terminals

Costas Busch - LSU11 Grammar Leftmost Derivation PDA Computation Production appliedTransition applied

Costas Busch - LSU12 Grammar Leftmost Derivation PDA Computation Transition applied Read from input and remove it from stack

Costas Busch - LSU13 Grammar Leftmost Derivation PDA Computation Last Transition applied All symbols have been removed from top of stack

Costas Busch - LSU14 Production applied The process repeats with the next leftmost variable And so on……

Costas Busch - LSU15 Input Stack Time 0 Example:

Costas Busch - LSU16 Input Stack Time 1 Derivation:

Costas Busch - LSU17 Input Stack Time 2 Derivation:

Costas Busch - LSU18 Input Stack Time 3 Derivation:

Costas Busch - LSU19 Input Stack Time 4 Derivation:

Costas Busch - LSU20 Input Stack Time 5 Derivation:

Costas Busch - LSU21 Input Stack Time 6 Derivation:

Costas Busch - LSU22 Input Stack Time 7 Derivation:

Costas Busch - LSU23 Input Stack Time 8 Derivation:

Costas Busch - LSU24 Input Stack Time 9 Derivation:

Costas Busch - LSU25 Input Stack accept Time 10 Derivation:

Costas Busch - LSU26 Grammar Leftmost Derivation PDA Computation

Costas Busch - LSU27 Grammar generates string PDA accepts In general, it can be shown that: If and Only if Therefore

Costas Busch - LSU28 Convert PDAs to Context-Free Grammars Proof - step 2

Costas Busch - LSU29 We will convert to a context-free grammar such that: Take an arbitrary PDA

Costas Busch - LSU30 First modify PDA so that: 1. The PDA has a single accept state 4. Each transition either pushes a symbol or pops a symbol but not both together 3. On acceptance the stack contains only stack symbol # (this symbol is not used in any transition) 2. Use new initial stack symbol #

Costas Busch - LSU31 PDA , , , Old accept states New accept state 1. The PDA has a single accept state PDA

Costas Busch - LSU32 PDA 2. Use new initial stack symbol # new initial stack symbol initial stack symbol of M Top of stack still thinks that Z is the initial stack PDA auxiliary stack symbol

Costas Busch - LSU33 Empty stack New accept state PDA Old accept state PDA 3. On acceptance the stack contains only stack symbol # (this symbol is not used in any transition)

Costas Busch - LSU34 4. Each transition either pushes a symbol or pops a symbol but not both together PDA

Costas Busch - LSU35 PDA Where is a symbol of the stack alphabet

Costas Busch - LSU36 PDA is the final modified PDA Note that the new initial stack symbol # is never used in any transition

Costas Busch - LSU37 Example:

Costas Busch - LSU38 Grammar Construction Variables: States of PDA

Costas Busch - LSU39 PDA Grammar Kind 1: for each state

Costas Busch - LSU40 PDA Grammar Kind 2: for every three states

Costas Busch - LSU41 PDA Grammar Kind 3: for every pair of such transitions

Costas Busch - LSU42 PDA Grammar Initial stateAccept state Start variable

Costas Busch - LSU43 Example: PDA

Costas Busch - LSU44 Grammar Kind 1: from single states

Costas Busch - LSU45 Start variable Kind 2: from triplets of states

Costas Busch - LSU46 Kind 3: from pairs of transitions

Costas Busch - LSU47 We need to prove that Suppose that a PDA is converted to a context-free grammar or equivalently

Costas Busch - LSU48 We need to show that if has derivation: Then there is an accepting computation in : (string of terminals) with input string

Costas Busch - LSU49 We will actually show that if has derivation: Then there is a computation in :

Costas Busch - LSU50 Therefore: Since there is no transition with the # symbol

Costas Busch - LSU51 Lemma: If (string of terminals) then there is a computation from state to state on string which leaves the stack empty:

Costas Busch - LSU52 Proof Intuition: Case 1: Case 2: Type 2 Type 3

Costas Busch - LSU53 Case 1: Type 2 Stack height Input string Generated by

Costas Busch - LSU54 Stack height Input string Generated by Case 2: Type 3

Costas Busch - LSU55 We formally prove this claim by induction on the number of steps in derivation: Formal Proof: number of steps

Costas Busch - LSU56 Induction Basis: (one derivation step) A Kind 1 production must have been used: Therefore, and This computation of PDA trivially exists:

Costas Busch - LSU57 Induction Hypothesis: derivation steps suppose it holds:

Costas Busch - LSU58 Induction Step: derivation steps We have to show:

Costas Busch - LSU59 derivation steps Case 1: Case 2: Type 2 Type 3

Costas Busch - LSU60 Case 1: Type 2 We can write At most steps steps

Costas Busch - LSU61 At most steps From induction hypothesis, in PDA: From induction hypothesis, in PDA:

Costas Busch - LSU62 since

Costas Busch - LSU63 Case 2: Type 3 We can write At most steps steps

Costas Busch - LSU64 At most steps From induction hypothesis, the PDA has computation:

Costas Busch - LSU65 And PDA Contains transitions Type 3 Grammar contains production

Costas Busch - LSU66

Costas Busch - LSU67 We know We also know Therefore:

Costas Busch - LSU68 since END OF PROOF

Costas Busch - LSU69 So far we have shown: With a similar proof we can show Therefore: