… NPDAs continued.

Slides:



Advertisements
Similar presentations
Chapter 5 Pushdown Automata
Advertisements

Pushdown Automata Section 2.2 CSC 4170 Theory of Computation.
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.
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.
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.
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.
CS5371 Theory of Computation Lecture 8: Automata Theory VI (PDA, PDA = CFG)
1 Context-Free Languages. 2 Regular Languages 3 Context-Free Languages.
Fall 2006Costas Busch - RPI1 PDAs Accept 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:
1 Context-Free Languages. 2 Regular Languages 3 Context-Free Languages.
1 A Non Context-Free Language (We will prove it at the next class)
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.
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)
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.
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.
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2010 with acknowledgement.
Formal Languages, Automata and Models of Computation
1.Draw a parse tree for the following derivation: S  C A C  C A b b  b b A b b  b b B b b  b b a A a a b b  b b a b a a b b 2. Show on your parse.
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.
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.
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
PDAs Accept Context-Free Languages
Non Deterministic Automata
Busch Complexity Lectures: Turing Machines
Deterministic FA/ PDA Sequential Machine Theory Prof. K. J. Hintz
NPDAs Accept Context-Free Languages
CIS Automata and Formal Languages – Pei Wang
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.
Pushdown Automata PDAs
NPDAs Accept Context-Free Languages
Pushdown Automata Reading: Chapter 6.
Non-Deterministic Finite Automata
فصل دوم Context-Free Languages
Deterministic PDAs - DPDAs
Pushdown automata a_introduction.htm.
Properties of Context-Free languages
Chapter 2 Context-Free Language - 01
Principles of Computing – UFCFA3-30-1
Pushdown automata The Chinese University of Hong Kong Fall 2011
Normal Forms for Context-free Grammars
Presentation transcript:

… NPDAs continued

Pushing Strings Pop symbol Input symbol Push string

Example: input pushed string stack top Push

Another NPDA example NPDA

Execution Example: Time 0 Input Stack current state

Time 1 Input Stack

Time 3 Input Stack

Time 4 Input Stack

Time 5 Input Stack

Time 6 Input Stack

Time 7 Input Stack

Time 8 Input Stack accept

Formalities for NPDAs

Transition function:

Transition function:

Formal Definition Non-Deterministic Pushdown Automaton NPDA Final states States Input alphabet Stack start symbol Transition function Initial state Stack alphabet

Instantaneous Description Current state Current stack contents Remaining input

Example: Instantaneous Description Input Time 4: Stack

Example: Instantaneous Description Input Time 5: Stack

We write: Time 4 Time 5

A computation:

For convenience we write:

Formal Definition Language of NPDA : Initial state Final state

Example: NPDA :

NPDA :

Therefore: NPDA :

NPDAs Accept Context-Free Languages

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

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

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

Converting Context-Free Grammars to NPDAs

An example grammar: What is the equivalent NPDA?

Grammar: NPDA:

The NPDA simulates leftmost derivations of the grammar L(Grammar) = L(NPDA)

Grammar: A leftmost derivation:

NPDA execution: Time 0 Input Stack current state

Time 1 Input Stack

Time 2 Input Stack

Time 3 Input Stack

Time 4 Input Stack

Time 5 Input Stack

Time 6 Input Stack

Time 7 Input Stack

Time 8 Input Stack

Time 9 Input Stack

Time 10 Input Stack accept

In general: Given any grammar We can construct a NPDA With

Constructing NPDA from grammar : For any production For any terminal

Grammar generates string if and only if NPDA accepts

Therefore: For any context-free language there is an NPDA that accepts the same language

Converting NPDAs to Context-Free Grammars

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

Intuition: The grammar simulates the machine A derivation in Grammar : Current configuration in NPDA

A derivation in Grammar : terminals variables Input processed Stack contents in NPDA

Some Necessary Modifications First, we modify the NPDA: It has a single final state It empties the stack when it accepts the input Empty Stack Original NPDA

Second, we modify the NPDA transitions: all transitions will have form or

Example of a NPDA in correct form:

The Grammar Construction In grammar : Stack symbol Variables: states Terminals: Input symbols of NPDA

For each transition We add production

For each transition We add production For all states

Stack bottom symbol Start Variable: Start state final state

Example: Grammar production:

Example: Grammar productions:

Example: Grammar production:

Resulting Grammar:

Derivation of string

In general, in Grammar: if and only if is accepted by the NPDA

Explanation: By construction of Grammar: if and only if in the NPDA going from to the stack doesn’t change below and is removed from stack