Theorem 29 Given any PDA, there is another PDA that accepts exactly the same language with the additional property that whenever a path leads to ACCEPT,

Slides:



Advertisements
Similar presentations
Theory of Computation CS3102 – Spring 2014 A tale of computers, math, problem solving, life, love and tragic death Nathan Brunelle Department of Computer.
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.
C O N T E X T - F R E E LANGUAGES ( use a grammar to describe a language) 1.
Closure Properties of CFL's
COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf of Monash University.
1 Introduction to Computability Theory Lecture12: Decidable Languages Prof. Amos Israeli.
CS5371 Theory of Computation
CS 310 – Fall 2006 Pacific University CS310 Pushdown Automata Sections: 2.2 page 109 October 11, 2006.
Costas Busch - RPI1 NPDAs Accept Context-Free Languages.
Courtesy Costas Busch - RPI1 NPDAs Accept Context-Free Languages.
Fall 2004COMP 3351 NPDA’s Accept Context-Free Languages.
CS5371 Theory of Computation Lecture 8: Automata Theory VI (PDA, PDA = CFG)
January 15, 2014CS21 Lecture 61 CS21 Decidability and Tractability Lecture 6 January 16, 2015.
Fall 2006Costas Busch - RPI1 PDAs Accept Context-Free Languages.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 8 Mälardalen University 2010.
Chapter 7 PDA and CFLs.
Pushdown Automata (PDA) Intro
Pushdown Automata CS 130: Theory of Computation HMU textbook, Chap 6.
Pushdown Automata (PDAs)
Definition Moves of the PDA Languages of the PDA Deterministic PDA’s Pushdown Automata 11.
Lecture # 28 Theory Of Automata By Dr. MM Alam 1.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 11 Midterm Exam 2 -Context-Free Languages Mälardalen University 2005.
Lecture # 22. PDA of language {a n b n : n=0,1,2,3, …}
Lecture # 26 Theory Of Automata By Dr. MM Alam 1.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 2 Context-Free Languages Some slides are in courtesy.
Chomsky Normal Form.
Summary of Previous Class There are languages that are not decidable –(we have not proved this yet) Why not extend Turing machines just as we did with.
Pushdown Automata Chapter 12. Recognizing Context-Free Languages Two notions of recognition: (1) Say yes or no, just like with FSMs (2) Say yes or no,
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.
1 Section 12.2 Pushdown Automata A pushdown automaton (PDA) is a finite automaton with a stack that has stack operations pop, push, and nop. PDAs always.
Costas Busch - LSU1 PDAs Accept Context-Free Languages.
Lecture 11  2004 SDU Lecture7 Pushdown Automaton.
Lecture # 21.
Formal Languages, Automata and Models of Computation
Pushdown Automata.
Kleene’s Theorem and NFA
PDAs Accept Context-Free Languages
CSE 105 theory of computation
Pushdown automata Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
NPDAs Accept Context-Free Languages
PDA’s - A new format for FAs
PDAs Accept Context-Free Languages
Pushdown Automata.
Chapter 7 PUSHDOWN AUTOMATA.
Recap lecture 38 Example of PDA with table for running a string, Equivalent PDA, PDA for EVEN EVEN Language. Non-Derterministic PDA, Example of Non-Derterministic.
Pushdown Automata.
NPDAs Accept Context-Free Languages
Pushdown Automata Reading: Chapter 6.
فصل دوم Context-Free Languages
CS21 Decidability and Tractability
Chapter 2 Context-Free Language - 01
CSE 105 theory of computation
ReCap Chomsky Normal Form, Theorem regarding CNF, examples of converting CFG to be in CNF, Example of an FA corresponding to Regular CFG, Left most and.
Pushdown automata Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
… NPDAs continued.
Pushdown automata Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
Recap lecture 37 New format for FAs, input TAPE, START, ACCEPT , REJECT, READ states Examples of New Format of FAs, PUSHDOWN STACK , PUSH and POP states,
Recap lecture 40 Recap of example of PDA corresponding to CFG, CFG corresponding to PDA. Theorem, HERE state, Definition of Conversion form, different.
Conversion of CFG to PDA Conversion of PDA to CFG
PDA corresponding to CFG
Automata, Grammars and Languages
Pushdown automata Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
CSE 105 theory of computation
Pushdown automata Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Pushdown automata Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
CSE 105 theory of computation
Presentation transcript:

Theorem 29 Given any PDA, there is another PDA that accepts exactly the same language with the additional property that whenever a path leads to ACCEPT, the STACK and the TAPE contain only blanks.

Proof of Theorem 29 We present a constructive algorithm that will convert any PDA into a PDA with the property mentioned above. Whenever we have the machine part

Proof of Theorem 29 (Contd.) we replace it with the following diagram: The new PDA formed accepts exactly the same language and finishes all successful paths with empty TAPE and empty STACK.

CFG = PDA Muhammad Amjad Iqbal

CFG = PDA We are now able to prove that the set of all languages accepted by PDAs is the same as the set of all languages generated by CFGs. We can prove this in two steps.

Theorem 30 and 31 Theorem 30: Given a CFG that generates the language L, there is a PDA that accepts exactly L. Theorem 31: Given a PDA that accepts the language L, there exists a CFG that generates exactly L.

Proof of Theorem 30 The proof will be by constructive algorithm. From Theorem 26 in Chapter 13 (page 278), we can assume that the CFG is in CNF. (We shall handle the problem of λ later.) Before we describe our algorithm, let us illustrate it on a particular example.

Example Consider the following CFG in CNF: S  SB | AB A  CC B  b C  a We now propose the following nondeterministic PDA where the STACK alphabet is Γ = {S, A, B, C} and the TAPE alphabet is only ∑ = {a, b}

We begin by pushing S onto the top of the STACK. We then enter the central POP state. Two things are possible when we pop the top of the STACK: We either replace the removed non-terminal with two other non-terminals, thereby simulating a production, Or we go to a READ state, which insists that we must read a specific terminal from the TAPE, or else it crashes. To get to ACCEPT, we must have encountered the READ states that wanted to read exactly the letters on the INPUT TAPE. We now show that doing this is equivalent to simulating a leftmost derivation of the input string in the given CFG.

Example Let’s consider a specific example. Let’s generate the word aab using leftmost derivation in the given CFG: Working string Production used S  AB S  AB  CCB A  CC  aCB C  a  aaB C  a aab B  b

Let us run this word (aab) on the proposed PDA, following the same sequence of productions in the leftmost derivation above.

We begin at START We push the symbol S on the STACK We then go to POP state. The first production we must simulate is S  AB. So, we POP S and then PUSH B and PUSH A:

We go back to POP. We now simulate A  CC by popping A and do PUSH C and PUSH C: Again, we go back to POP. This time, we must simulate C  a by poping C and reading a from the TAPE: We simulate another C  a:

We now re-enter the POP state and simulate the last production, B  b We now re-enter the POP state and simulate the last production, B  b. We POP B and READ b from the TAPE At this point the STACK is empty, and the blank ∆ is the only thing we can read next from the TAPE. Hence, we follow the path POP ∆ READ3 ∆ ACCEPT So, the word aab is accepted by the PDA.

It should also be clear that if any input string reaches the ACCEPT state in the PDA, that string must have got there by having each of its letters read via simulating the Chomsky production of the form Nonterminal  terminal This means that we have necessarily formed a complete leftmost derivation of this word through CFG productions with no nonterminals left over in the STACK. Therefore, every word accepted by this PDA is in the language generated by the CFG. We are now ready to present the algorithm to construct a PDA from a given CFG.

Algorithm Given a CFG in CNF as follows: X1  X2X3 X1  X3X4 X2  X2X2 … X3  a X4  a X5  b where the start symbol S = X1 and the other non-terminals are X2, X3, ...

Algorithm (contd.) We build the corresponding PDA as follows: We begin with

Algorithm (contd.) For each production of the form Xi  XjXk We include this circuit from the POP state back to itself:

Algorithm (contd.) For each production of the form Xi  b We include this circuit:

Algorithm (contd.) When the STACK is empty, which means that we have converted our last non-terminal to a terminal and the terminals have matched the INPUT TAPE, we add this path:

Algorithm contd. From the reasons and example above, we know that all words generated by the given CFG will be accepted by the PDA, and all words accepted by this PDA will have leftmost derivations in the given CFG. At the beginning we assumed that the CFG was in CNF. But there are some CFLs that cannot be put into CNF. These are the languages that include the word λ.

Algorithm contd. In this case, we can convert all productions into CNF and construct the PDA as described above. In addition, we must also include λ. This can be done by adding a simple circuit at the POP: This kills the non-terminal S without replacing it with anything. So, the next time we enter the POP, we get a blank and can proceed to accept the word.

Example The language PALINDROME (including λ) can be generated by the following CFG in CNF (plus one λ-production): S  AR1 | BR2 | AA | BB | a | b| λ R1  SA R2  SB A  a B  b Using the algorithm above, we build the following PDA that accepts exactly the same language:

The proof of Theorem 31 is not included in the syllabus; however, you are encouraged to read it from the text. Theorems 30 and 31 together prove that the set of all languages accepted by PDAs is the same as the set of all languages generated by CFGs.