Costas Busch - RPI1 NPDAs Accept Context-Free Languages.

Slides:



Advertisements
Similar presentations
PDAs Accept Context-Free Languages
Advertisements

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.
Courtesy Costas Busch - RPI1 NPDAs Accept Context-Free Languages.
Costas Busch - RPI1 Grammars. Costas Busch - RPI2 Grammars Grammars express languages Example: the English language.
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.
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.
Costas Busch - RPI1 The Pumping Lemma for 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.
Fall 2006Costas Busch - RPI1 PDAs Accept Context-Free Languages.
Costas Busch - LSU1 Non-Deterministic Finite Automata.
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:
1 A Non Context-Free Language (We will prove it at the next class)
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 7 Mälardalen University 2010.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 8 Mälardalen University 2010.
Pushdown Automata (PDAs)
Cs3102: Theory of Computation Class 6: Pushdown Automata Spring 2010 University of Virginia David Evans TexPoint fonts used in EMF. Read the TexPoint manual.
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.
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2010 with acknowledgement.
Costas Busch - LSU1 Properties of Context-Free languages.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 9 Mälardalen University 2006.
11 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 7 School of Innovation, Design and Engineering Mälardalen University 2012.
Formal Languages, Automata and Models of Computation
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 2 Context-Free Languages Some slides are in courtesy.
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 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.
Costas Busch - LSU1 PDAs Accept Context-Free Languages.
Formal Languages, Automata and Models of Computation
Recursively Enumerable and Recursive Languages
G. Pullaiah College of Engineering and Technology
PDAs Accept Context-Free Languages
Linear Bounded Automata LBAs
Reductions Costas Busch - LSU.
NPDAs Accept Context-Free Languages
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
Deterministic PDAs - DPDAs
The Post Correspondence Problem
Elementary Questions about Regular Languages
Properties of Context-Free languages
DPDA Deterministic PDA
… NPDAs continued.
Normal Forms for Context-free Grammars
Presentation transcript:

Costas Busch - RPI1 NPDAs Accept Context-Free Languages

Costas Busch - RPI2 Context-Free Languages (Grammars) Languages Accepted by NPDAs Theorem:

Costas Busch - RPI3 Context-Free Languages (Grammars) Languages Accepted by NPDAs Proof - Step 1: Convert any context-free grammar to a NPDA with:

Costas Busch - RPI4 Context-Free Languages (Grammars) Languages Accepted by NPDAs Proof - Step 2: Convert any NPDA to a context-free grammar with:

Costas Busch - RPI5 Converting Context-Free Grammars to NPDAs Proof - step 1

Costas Busch - RPI6 to an NPDA automaton We will convert any context-free grammar Such that: Simulates leftmost derivations of

Costas Busch - RPI7 Input processed Stack contents Input Stack leftmost variable Leftmost derivation Simulation of derivation

Costas Busch - RPI8 Input Stack Leftmost derivation Simulation of derivation string of terminals end of input is reached

Costas Busch - RPI9 An example grammar: What is the equivalent NPDA?

Costas Busch - RPI10 Grammar: NPDA:

Costas Busch - RPI11 Grammar: A leftmost derivation:

Costas Busch - RPI12 Input Stack Time 0 Derivation:

Costas Busch - RPI13 Input Stack Time 0 Derivation:

Costas Busch - RPI14 Input Stack Time 1 Derivation:

Costas Busch - RPI15 Input Stack Time 2 Derivation:

Costas Busch - RPI16 Input Stack Time 3 Derivation:

Costas Busch - RPI17 Input Stack Time 4 Derivation:

Costas Busch - RPI18 Input Stack Time 5 Derivation:

Costas Busch - RPI19 Input Stack Time 6 Derivation:

Costas Busch - RPI20 Input Stack Time 7 Derivation:

Costas Busch - RPI21 Input Stack Time 8 Derivation:

Costas Busch - RPI22 Input Stack accept Time 9 Derivation:

Costas Busch - RPI23 In general: Given any grammar We can construct a NPDA With

Costas Busch - RPI24 Constructing NPDA from grammar : For any production For any terminal

Costas Busch - RPI25 Grammar generates string if and only if NPDA accepts

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

Costas Busch - RPI27 Converting NPDAs to Context-Free Grammars Proof - step 2

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

Costas Busch - RPI29 Intuition:The grammar simulates the machine A derivation in Grammar : Current configuration in NPDA Input processedStack contents terminalsvariables

Costas Busch - RPI30 Some Necessary Modifications Modify (if necessary) the NPDA 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

Costas Busch - RPI31 1)Modify the NPDA so that the stack is never empty Stack OK NOT OK

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

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

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

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

Costas Busch - RPI36 $$ , Convert transitions as follows: halting state

Costas Busch - RPI37 NPDA , Empty the stack 2) Modify the NPDA so that it empties the stack and has a unique final state , , Old final states

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

Costas Busch - RPI39 Convert:

Costas Busch - RPI40 Convert: symbols

Costas Busch - RPI41 Convert: symbols Convert recursively

Costas Busch - RPI42 Example of a NPDA in correct form:

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

Costas Busch - RPI44 For each transition We add production

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

Costas Busch - RPI46 Start Variable: Stack bottom symbol Start state final state

Costas Busch - RPI47 Example: Grammar production:

Costas Busch - RPI48 Example: Grammar productions:

Costas Busch - RPI49 Example: Grammar production:

Costas Busch - RPI50 Resulting Grammar:

Costas Busch - RPI51

Costas Busch - RPI52 Derivation of string

Costas Busch - RPI53 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

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

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

Costas Busch - RPI56 Deterministic PDA DPDA

Costas Busch - RPI57 Deterministic PDA: DPDA Allowed transitions: (deterministic choices)

Costas Busch - RPI58 Allowed transitions: (deterministic choices)

Costas Busch - RPI59 Not allowed: (non deterministic choices)

Costas Busch - RPI60 DPDA example

Costas Busch - RPI61 The language is deterministic context-free

Costas Busch - RPI62 Definition: A language is deterministic context-free if there exists some DPDA that accepts it

Costas Busch - RPI63 Example of Non-DPDA (NPDA)

Costas Busch - RPI64 Not allowed in DPDAs

Costas Busch - RPI65 NPDAs Have More Power than DPDAs

Costas Busch - RPI66 Deterministic Context-Free Languages (DPDA) Context-Free Languages NPDAs Since every DPDA is also a NPDA It holds that:

Costas Busch - RPI67 We will actually show: We will show that there exists a context-free language which is not accepted by any DPDA Deterministic Context-Free Languages (DPDA) Context-Free Languages (NPDA)

Costas Busch - RPI68 The language is: We will show: is context-free is not deterministic context-free

Costas Busch - RPI69 Language is context-free Context-free grammar for :

Costas Busch - RPI70 is not deterministic context-free Theorem: The language (there is no DPDA that accepts )

Costas Busch - RPI71 Proof: Assume for contradiction that is deterministic context free Therefore: there is a DPDA that accepts

Costas Busch - RPI72 DPDA with accepts

Costas Busch - RPI73 DPDA with Such a path exists because of the determinism

Costas Busch - RPI74 The language is not context-free (we will prove this at a later class using pumping lemma for context-free languages) Fact 1: Regular languages Context-free languages

Costas Busch - RPI75 The language is not context-free Fact 2: (we can prove this using pumping lemma for context-free languages)

Costas Busch - RPI76 We will construct a NPDA that accepts: which is a contradiction!

Costas Busch - RPI77 Modify Replace with

Costas Busch - RPI78 The NPDA that accepts Connect final states of with final states of

Costas Busch - RPI79 Since is accepted by a NPDA it is context-free Contradiction! (since is not context-free)

Costas Busch - RPI80 Therefore: There is no DPDA that accepts End of Proof Not deterministic context free