Courtesy Costas Busch - RPI1 NPDAs Accept Context-Free Languages.

Slides:



Advertisements
Similar presentations
PDAs Accept Context-Free Languages
Advertisements

Chapter 5 Pushdown Automata
1 Pushdown Automata (PDA) Informally: –A PDA is an NFA-ε with a stack. –Transitions are modified to accommodate stack operations. Questions: –What is a.
Introduction to Computability Theory
1 Introduction to Computability Theory Lecture7: PushDown Automata (Part 1) Prof. Amos Israeli.
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.
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.
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.
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 8 Mälardalen University 2010.
Pushdown Automata (PDAs)
Definition Moves of the PDA Languages of the PDA Deterministic PDA’s Pushdown Automata 11.
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.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
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.
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.
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.
6. Pushdown Automata CIS Automata and Formal Languages – Pei Wang.
Formal Languages, Automata and Models of Computation
Recursively Enumerable and Recursive Languages
G. Pullaiah College of Engineering and Technology
PDAs Accept Context-Free Languages
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
Properties of Context-Free languages
Chapter 2 Context-Free Language - 01
DPDA Deterministic PDA
… NPDAs continued.
Normal Forms for Context-free Grammars
Push Down Automata Push Down Automata (PDAs) are L-NFAs with stack memory. Transitions are labeled by an input symbol together with a pair of the form.
Presentation transcript:

Courtesy Costas Busch - RPI1 NPDAs Accept Context-Free Languages

Courtesy Costas Busch - RPI2 Instantaneous Description Current state Remaining input Current stack contents

3 Properties of Instantaneous Description If an ID sequence is a legal computation for a PDA, then so is the sequence obtained by adding an additional string at the end of component number two.

4 Properties of Instantaneous Description If an ID sequence is a legal computation for a PDA, then so is the sequence obtained by adding an additional string at the bottom of component number three.

5 Properties of Instantaneous Description If an ID sequence is a legal computation for a PDA, and some tail of the input is not consumed, then removing this tail from all ID's result in a legal computation sequence.

6 Languages of PDA Acceptance by Final State Language of NPDA : Initial state Final state

7 Languages of PDA Acceptance by Empty Stack Language of NPDA : Initial state Any state

8 From Empty Stack to Final State If of some PDA Then there is a PDA such that

9 From Empty Stack to Final State Proof: Let

10 Property # 2

11 Then there is a PDA such that From Final State to Empty Stack If for some PDA

12 From Final State to Empty Stack Proof: Let

13 from Property # 2 of ID

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

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

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

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

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

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

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

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

Courtesy Costas Busch - RPI22 Grammar: NPDA:

Courtesy Costas Busch - RPI23 Grammar: A leftmost derivation:

Courtesy Costas Busch - RPI24 Input Stack Time 0 Derivation:

Courtesy Costas Busch - RPI25 Input Stack Time 0 Derivation:

Courtesy Costas Busch - RPI26 Input Stack Time 1 Derivation:

Courtesy Costas Busch - RPI27 Input Stack Time 2 Derivation:

Courtesy Costas Busch - RPI28 Input Stack Time 3 Derivation:

Courtesy Costas Busch - RPI29 Input Stack Time 4 Derivation:

Courtesy Costas Busch - RPI30 Input Stack Time 5 Derivation:

Courtesy Costas Busch - RPI31 Input Stack Time 6 Derivation:

Courtesy Costas Busch - RPI32 Input Stack Time 7 Derivation:

Courtesy Costas Busch - RPI33 Input Stack Time 8 Derivation:

Courtesy Costas Busch - RPI34 Input Stack accept Time 9 Derivation:

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

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

Courtesy Costas Busch - RPI37 Grammar generates string if and only if NPDA accepts

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

Courtesy Costas Busch - RPI39 Note: From CFG to PDA accepting by emptying stack Given any grammar We can construct a NPDA With

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

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

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

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

Courtesy Costas Busch - RPI44 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 [p i-1 Y i p i ] that would represent going from p i-1 to p i with the net effect of popping Y i.

45 To generate all those strings w that cause P to pop Z 0 from its stack while going from q 0 to p.

Courtesy Costas Busch - RPI46

47

48

49

Courtesy Costas Busch - RPI50 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 - RPI51 1)Modify the NPDA so that the stack is never empty Stack OK NOT OK

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

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

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

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

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

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

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

Courtesy Costas Busch - RPI59 Convert:

Courtesy Costas Busch - RPI60 Convert: symbols

Courtesy Costas Busch - RPI61 Convert: symbols Convert recursively

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

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

Courtesy Costas Busch - RPI64 For each transition We add production

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

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

Courtesy Costas Busch - RPI67 Example: Grammar production:

Courtesy Costas Busch - RPI68 Example: Grammar productions:

Courtesy Costas Busch - RPI69 Example: Grammar production:

Courtesy Costas Busch - RPI70 Resulting Grammar:

Courtesy Costas Busch - RPI71

Courtesy Costas Busch - RPI72 Derivation of string

Courtesy Costas Busch - RPI73 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 - RPI74 Therefore: if and only if is accepted by the NPDA

Courtesy Costas Busch - RPI75 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 - RPI76 Deterministic PDA DPDA

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

Courtesy Costas Busch - RPI78 Allowed transitions: (deterministic choices)

Courtesy Costas Busch - RPI79 Not allowed: (non deterministic choices)

Courtesy Costas Busch - RPI80 DPDA example

Courtesy Costas Busch - RPI81 The language is deterministic context-free

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

Courtesy Costas Busch - RPI83 Example of Non-DPDA (NPDA)

Courtesy Costas Busch - RPI84 Not allowed in DPDAs

Courtesy Costas Busch - RPI85 NPDAs Have More Power than DPDAs

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

Courtesy Costas Busch - RPI87 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)

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

Courtesy Costas Busch - RPI89 Language is context-free Context-free grammar for :

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

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

Courtesy Costas Busch - RPI92 DPDA with accepts

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

Courtesy Costas Busch - RPI94 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

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

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

Courtesy Costas Busch - RPI97 Modify Replace with

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

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

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