PDAs Accept Context-Free Languages

Slides:



Advertisements
Similar presentations
Chapter 5 Pushdown Automata
Advertisements

Prof. Busch - LSU1 Properties of Context-Free languages.
Costas Busch - RPI1 Pushdown Automata PDAs. Costas Busch - RPI2 Pushdown Automaton -- PDA Input String Stack States.
Courtesy Costas Busch - RPI1 Non Deterministic Automata.
1 … NPDAs continued. 2 Pushing Strings Input symbol Pop symbol Push string.
Costas Busch - RPI1 Undecidable problems for Recursively enumerable languages continued…
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.
Courtesy Costas Busch - RPI
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.
Fall 2004COMP 3351 Pushdown Automata PDAs. Fall 2004COMP 3352 Pushdown Automaton -- PDA Input String Stack States.
Fall 2006Costas Busch - RPI1 Pushdown Automata PDAs.
Courtesy Costas Busch - RPI1 Context-Free Languages.
1 Normal Forms for Context-free Grammars. 2 Chomsky Normal Form All productions have form: variable and terminal.
Fall 2006Costas Busch - RPI1 Non-Deterministic Finite Automata.
Courtesy Costas Busch - RPI1 Reducibility. Courtesy Costas Busch - RPI2 Problem is reduced to problem If we can solve problem then we can solve problem.
CS5371 Theory of Computation Lecture 8: Automata Theory VI (PDA, PDA = CFG)
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 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.
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.
Costas Busch - LSU1 Properties of Context-Free languages.
Formal Languages, Automata and Models of Computation
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.
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.
Costas Busch - LSU1 PDAs Accept Context-Free Languages.
Formal Languages, Automata and Models of Computation
Recursively Enumerable and Recursive Languages
Reductions Costas Busch - LSU.
NPDAs Accept Context-Free Languages
Simplifications of Context-Free Grammars
Pushdown Automata PDAs
Pushdown Automata PDAs
Pushdown Automata PDAs
PDAs Accept Context-Free Languages
PDAs Accept Context-Free Languages
Pushdown Automata PDAs
Chapter 7 PUSHDOWN AUTOMATA.
NPDAs Accept Context-Free Languages
DPDA Deterministic PDA
Non-Deterministic Finite Automata
Non-Deterministic Finite Automata
Decidable Languages Costas Busch - LSU.
Deterministic PDAs - DPDAs
The Post Correspondence Problem
The Off-Line Machine Input File read-only (once) Input string
Undecidable problems:
Properties of Context-Free languages
Chapter 2 Context-Free Language - 01
DPDA Deterministic PDA
… NPDAs continued.
The Chomsky Hierarchy Costas Busch - LSU.
Normal Forms for Context-free Grammars
Presentation transcript:

PDAs Accept Context-Free Languages Prof. Busch - LSU

Theorem: Context-Free Languages Languages Accepted by (Grammars) PDAs Prof. Busch - LSU

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

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

Convert Context-Free Grammars to PDAs Proof - step 1 Convert Context-Free Grammars to PDAs Prof. Busch - LSU

Take an arbitrary context-free grammar We will convert to a PDA such that: Prof. Busch - LSU

Conversion Procedure: For each For each production in terminal in Add transitions Prof. Busch - LSU

Example Grammar PDA Prof. Busch - LSU

Example: Input Time 0 Stack Prof. Busch - LSU

Derivation: Input Time 1 Stack Prof. Busch - LSU

Derivation: Input Time 2 Stack Prof. Busch - LSU

Derivation: Input Time 3 Stack Prof. Busch - LSU

Derivation: Input Time 4 Stack Prof. Busch - LSU

Derivation: Input Time 5 Stack Prof. Busch - LSU

Derivation: Input Time 6 Stack Prof. Busch - LSU

Derivation: Input Time 7 Stack Prof. Busch - LSU

Derivation: Input Time 8 Stack Prof. Busch - LSU

Derivation: Input Time 9 Stack Prof. Busch - LSU

Derivation: Input Time 10 Stack accept Prof. Busch - LSU

Convert PDAs to Context-Free Grammars Proof - step 2 Convert PDAs to Context-Free Grammars Prof. Busch - LSU

Courtesy Costas Busch - RPI For any NPDA we will construct a context-free grammar with Courtesy Costas Busch - RPI

Courtesy Costas Busch - RPI Intuition: The grammar simulates the machine A derivation in Grammar : terminals variables Input processed Stack contents Current configuration in NPDA Courtesy Costas Busch - RPI

Courtesy Costas Busch - RPI From NPDA to CFG Lets look at how a PDA can consume and empty the stack. We shall define a grammar with variables of the form [pi-1 Yi pi] that would represent going from pi-1 to pi with the net effect of popping Yi. Courtesy Costas Busch - RPI

To generate all those strings w that cause P to pop Z0 from its stack while going from q0 to p.

Courtesy Costas Busch - RPI

Some Necessary Modifications Modify (if necessary) the NPDA (accepting by reaching final state) so that: 1) The stack is never empty 2) It has a single final state and empties the stack when it accepts a string 3) Has transitions in a special form Courtesy Costas Busch - RPI

Courtesy Costas Busch - RPI Modify the NPDA so that the stack is never empty Stack OK OK NOT OK Courtesy Costas Busch - RPI

Courtesy Costas Busch - RPI Introduce the new symbol to denote the bottom of the stack Courtesy Costas Busch - RPI

Courtesy Costas Busch - RPI At the beginning push into the stack Original NPDA new initial state original initial state Courtesy Costas Busch - RPI

Courtesy Costas Busch - RPI In transitions: replace every instance of with Example: Courtesy Costas Busch - RPI

Courtesy Costas Busch - RPI Convert all transitions so that: if the automaton attempts to pop or replace it will halt Courtesy Costas Busch - RPI

Courtesy Costas Busch - RPI Convert transitions as follows: $ ® , l halting state Courtesy Costas Busch - RPI

Courtesy Costas Busch - RPI 2) Modify the NPDA so that it empties the stack and has a unique final state Empty the stack NPDA l ® , l ® , l ® , Old final states Courtesy Costas Busch - RPI

Courtesy Costas Busch - RPI 3) modify the NPDA so that transitions have the following forms: OR Courtesy Costas Busch - RPI

Courtesy Costas Busch - RPI Convert: Courtesy Costas Busch - RPI

Courtesy Costas Busch - RPI Convert: symbols Courtesy Costas Busch - RPI

Courtesy Costas Busch - RPI Convert: symbols Convert recursively Courtesy Costas Busch - RPI

Courtesy Costas Busch - RPI Example of a NPDA in correct form: Courtesy Costas Busch - RPI

The Grammar Construction In grammar : Stack symbol Variables: states Terminals: Input symbols of NPDA Courtesy Costas Busch - RPI

Courtesy Costas Busch - RPI For each transition We add production Courtesy Costas Busch - RPI

Courtesy Costas Busch - RPI For each transition We add productions For all possible states in the automaton Courtesy Costas Busch - RPI

Courtesy Costas Busch - RPI Stack bottom symbol Start Variable: Start state final state Courtesy Costas Busch - RPI

Courtesy Costas Busch - RPI Example: Grammar production: Courtesy Costas Busch - RPI

Courtesy Costas Busch - RPI Example: Grammar productions: Courtesy Costas Busch - RPI

Courtesy Costas Busch - RPI Example: Grammar production: Courtesy Costas Busch - RPI

Courtesy Costas Busch - RPI Resulting Grammar: Courtesy Costas Busch - RPI

Courtesy Costas Busch - RPI

Courtesy Costas Busch - RPI Derivation of string Courtesy Costas Busch - RPI

Courtesy Costas Busch - RPI In general: if and only if the NPDA goes from to by reading string and the stack doesn’t change below and then is removed from stack Courtesy Costas Busch - RPI

Courtesy Costas Busch - RPI Therefore: if and only if is accepted by the NPDA Courtesy Costas Busch - RPI

Courtesy Costas Busch - RPI Therefore: For any NPDA there is a context-free grammar that accepts the same language Context-Free Languages (Grammars) Languages Accepted by NPDAs Courtesy Costas Busch - RPI