Lecture # 28 Theory Of Automata By Dr. MM Alam 1.

Slides:



Advertisements
Similar presentations
Theory Of Automata By Dr. MM Alam
Advertisements

C O N T E X T - F R E E LANGUAGES ( use a grammar to describe a language) 1.
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,
COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf of Monash University.
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 Pushdown Automata PDAs.
CS 310 – Fall 2006 Pacific University CS310 Pushdown Automata Sections: 2.2 page 109 October 9, 2006.
Fall 2004COMP 3351 Pushdown Automata PDAs. Fall 2004COMP 3352 Pushdown Automaton -- PDA Input String Stack States.
Fall 2006Costas Busch - RPI1 Pushdown Automata PDAs.
CS5371 Theory of Computation Lecture 8: Automata Theory VI (PDA, PDA = CFG)
Prof. Busch - LSU1 Pushdown Automata PDAs. Prof. Busch - LSU2 Pushdown Automaton -- PDA Input String Stack States.
Fall 2005Costas Busch - RPI1 Pushdown Automata PDAs.
Theory Of Automata By Dr. MM Alam
CSCI 2670 Introduction to Theory of Computing September 21, 2005.
Pushdown Automata.
Pushdown Automata (PDA) Intro
Pushdown Automata (PDAs)
Pushdown Automata Part I: PDAs Chapter Recognizing Context-Free Languages Two notions of recognition: (1) Say yes or no, just like with FSMs (2)
Complexity and Computability Theory I Lecture #11 Instructor: Rina Zviel-Girshin Lea Epstein.
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.
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.
Lecture 04: Theory of Automata:08 Transition Graphs.
1 Section 13.1 Turing Machines A Turing machine (TM) is a simple computer that has an infinite amount of storage in the form of cells on an infinite tape.
1 Turing Machines and Equivalent Models Section 13.1 Turing Machines.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 2 Context-Free Languages Some slides are in courtesy.
Push Down Automata Chapter 14. Introduction We have seen different types of languages so far –Regular Languages –Nonregular Languages –Context Free Languages.
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 10 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
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.
Theory Of Automata By Dr. MM Alam
CS6800 Advance Theory of Computation Spring 2016 Nasser Alsaedi
Lecture 11  2004 SDU Lecture7 Pushdown Automaton.
Pushdown Automata - like NFA-  but also has a stack - transition takes the current state, the current input symbol, and the top-of-the-stack symbol (which.
CSCI 2670 Introduction to Theory of Computing September 22, 2004.
Recap: Nondeterministic Finite Automaton (NFA) A deterministic finite automaton (NFA) is a 5-tuple (Q, , ,s,F) where: Q is a finite set of elements called.
Lecture # 21.
Pushdown Automata.
Theory Of Automata By Dr. MM Alam
Theory of Computation Pushdown Automata pda Lecture #10.
CSE 105 theory of computation
Pushdown automata Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
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,
Theory Of Automata By Dr. MM Alam
PDA’s - A new format for FAs
Pushdown Automata PDAs
Pushdown Automata PDAs
Pushdown Automata PDAs
Pushdown Automata PDAs
Pushdown Automata.
Theory of Computation Lecture #27-28.
Pushdown Automata.
COSC 3340: Introduction to Theory of Computation
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
Pushdown automata Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Pushdown automata The Chinese University of Hong Kong Fall 2011
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.
Pushdown automata Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
CSE 105 theory of computation
COSC 3340: Introduction to 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:

Lecture # 28 Theory Of Automata By Dr. MM Alam 1

Lecture 27 recap Chomsky Normal Form conversion in JFLAP Push Down Automata Definition PDA Symbols 2

Adding A Pushdown Stack A PUSHDOWN STACK is a place where input letters can be stored until we want to refer to them again. It holds the letters it has been fed in a long line. The operation PUSH adds a new letter to the line. The new letter is placed on top of the STACK, and all the other letters are pushed back (or down) accordingly. Before the machine begins to process an input string the STACK is presumed to be empty, which means that every storage location in it initially contains a blank. 3

Adding A Pushdown Stack If the STACK is then fed the letters a, b, c, d by this sequence of instructions: PUSH a PUSH b PUSH c PUSH d Then top letter in the STACK is d, the second is c, the third is b, and the fourth is a. If we now execute the instruction: PUSH b the letter b will be added to the STACK on the top. The d will be pushed down to position 2, the c to position 3, the other b to position 4, and the bottom a to position 5. If the STACK is then fed the letters a, b, c, d by this sequence of instructions: PUSH a PUSH b PUSH c PUSH d Then top letter in the STACK is d, the second is c, the third is b, and the fourth is a. If we now execute the instruction: PUSH b the letter b will be added to the STACK on the top. The d will be pushed down to position 2, the c to position 3, the other b to position 4, and the bottom a to position 5. 4

Adding A Pushdown Stack One pictorial representation of a STACK with these letters in it is shown below. Beneath the bottom a we presume that the rest of the STACK, which, like the INPUT TAPE, has infinitely many storage locations, holds only blanks. b d c b a Δ 5

Adding A Pushdown Stack How the following PDA is working: 6 b a

Adding A Pushdown Stack Its operation on the input string aaabbb. We begin by assuming that this string has been put on the TAPE. Δ a a ab b b Δ TAPE STACK 7

Adding A Pushdown Stack Its operation on the input string aaabbb. We begin by assuming that this string has been put on the TAPE. a a ab b b Δ a Δ STACK TAPE 8

Adding A Pushdown Stack We now read another a and proceed as before along the a edge to push it into the STACK. Again we are returned to the READ box. Again we read an a (our third), and again this a is pushed onto the STACK. a a ab b b Δ a a a Δ STACK TAPE 9

Adding A Pushdown Stack After the third PUSH a, we are routed back to the same READ state again. This time, we read the letter b. This means that we take the b edge out of this state down to the lower left POP. a a ab b b Δ a a Δ STACK TAPE 10

Adding A Pushdown Stack The b road from the second READ state now takes us back to the edge feeding into the POP state. So we pop the STACK again and get another a. The STACK is now down to only one a. The a line from POP takes us again to this same READ. There is only one letter left on the input TAPE, a b. a Δ STACK a a ab b b Δ TAPE 11

Adding A Pushdown Stack We read it and leave the TAPE empty, that is, all blanks. However, the machine does not yet know that the TAPE is empty. It will discover this only when it next tries to read the TAPE and finds Δ. a a ab b b Δ Δ TAPE 12

Adding A Pushdown Stack Let 13

Adding A Pushdown Stack 14

Example The PALINDROMEX, language of all words of the form s X reverse(s) where s is any string in (a + b)*. The words in this language are { X aXa bXb aaXaa abXba baXab bbXbb aaaXaaa aabXbaa... } They all contain exactly one X, and this X marks the middle ofthe word. We can build a deterministic PDA that accepts the language PALINDROMEX. It has the same basic structure as the PDA we had for the language {a n b n }. 15

Adding A Pushdown Stack Example In the first part of the machine the STACK is loaded with the letters from the input string just as the initial a's from a n b n were pushed onto the STACK. The letters go into the STACK first letter on the bottom, second letter on top of it, and so on till the last letter pushed in ends up on top. When we read the X we know we have reached the middle of the input. 16

Adding A Pushdown Stack Example We can then begin to compare the front half of the word (which is reversed in the STACK) with the back half (still on the TAPE) to see that they match. We begin by storing the front half of the input string in the STACK with this part of the machine. 17

Adding A Pushdown Stack Example If we READ an a, we PUSH an a. If we READ a b, we PUSH a b, and on and on until we encounter the X on the TAPE. After we take the first half of the word and stick it into the STACK, we have reversed the order of the letters and it looks exactly like the second half of the word. For example, if we begin with the input string abbXbba 18

Adding A Pushdown Stack Example At the moment we are just about to read the X we have: ab bX bba Δ b b a Δ 19

Adding A Pushdown Stack Example When we read the X we do not put it into the STACK. It is used up the process of transferring us to phase two. In order to reach ACCEP these two should be the same letter for letter, down to the blanks.: 20

Adding A Pushdown Stack Example 21

Adding A Pushdown Stack Example 2 Consider the language: EVENPALINDROME = {s reverse(s), where s is in (a + b)*} = { A aa bb aaaa abba baab bbbbaaaaaa... } This is the language of all palindromes with an even number of letters. One machine to accept this language is shown on next slide: 22

Adding A Pushdown Stack Example 2 23

Adding A Pushdown Stack The first letter of the second half of the word is read in READ 1, Then we immediately go to the POP that compares the character read with what is on top of the STACK. After this we cycle READ 2 -->POP-READ 2 -->POP--->.... b a bb a b Δ Δ 24

Adding A Pushdown Stack We can trace the path by which this input STATESTACKTAPE STARTΔ...babbabΔ... READ 1 Δ...babbabΔ … PUSH b bΔ...babbabΔ … READ 1 bΔ...babbabΔ … PUSH a abΔ...babbabΔ … READ 1 abΔ..babbabΔ … PUSH b babΔ..babbabΔ … READ 1 babΔbabbabΔ … 25

Adding A Pushdown Stack If we are going to accept this input string this is where we must make the jump out of the left circuit into the right circuit. The trace continues: STATESTACKTAPE POP 2 abΔ...babbabΔ... READ 2 abΔ...babbabΔ … POP 1 bΔ...babbabΔ … READ 2 bΔ...babbabΔ … POP 2 Δ...babbabΔ … READ 2 Δ...babbabΔ … 26

Adding A Pushdown Stack If we are going to accept this input string this is where we must make the jump out of the left circuit into the right circuit. The trace continues: STATESTACKTAPE POP 2 ab READ 1...babbabΔ... READ 2 abΔ...babbabΔ … POP 1 bΔ...babbabΔ … READ 2 bΔ...babbabΔ … POP 2 Δ...babbabΔ … READ 2 Δ...babbabΔ … 27

Adding A Pushdown Stack We have just read the first of the infinitely many blanks on the TAPE.): STATESTACKTAPE POP 3 Δ... (Popping a blank from an empty stack still leaves blanks) babbabΔ... (Reading a blank from from an empty an empty tape still stack still leaves leaves blanks) ACCEPTΔ...babbabΔ … 28

Pushdown Automata A pushdown automaton, PDA, is a collection of eight things 1.An alphabet Σ of input letters. 2.An input TAPE (infinite in one direction). Initially the letters is placed on the TAPE starting in cell i. The rest is blank. 3. An alphabet F of STACK characters. 29

Pushdown Automata 4. A pushdown STACK (infinite in one direction). Initially empty (contains all blanks). 5. One START state that has only out-edges, no in-edges. 30 Start

Pushdown Automata Halt states of two kinds: some ACCEPT and some REJECT. They have in-edges and no out-edge 7. Finitely many nonbranching PUSH states that introduce characters onto the top of the STACK. They are of the form 31 AcceptReject PUSH X

Pushdown Automata 8. Finitely many branching states of two kinds: (i) States that read the next unused letter from the TAPE (ii) States that read the top character of the STACK 32

Pushdown Automata Example Consider the language generated by the CFG: S → S + S I S * S | 4 The terminals are +, *, and 4 and the only nonterminal is S. 33

Pushdown Automata The following PDA accepts this language: 34

Pushdown Automata Example Trace the acceptance of * 4 35 STATESTACKTAPE STARTΔ4 +4 * 4 PUSH 1 SS4 +4 * 4 POPΔ4 +4 * 4 PUSH 2 SS4 +4 * 4 PUSH 3 ++ S4 +4 * 4 PUSH 4 SS + S4 +4 * 4

Pushdown Automata Example Trace the acceptance of * 4 (continued) 36 STATESTACKTAPE POP+S4 +4 * 4 READ 1 +S4 * 4 POPS4 * 4 READ 2 S4 * 4 POPΔ4 * 4 PUSH 5 SS4 * 4 PUSH 6 **S4 * 4 PUSH 7 SS*S4 * 4 POP*S4 * 4 READ 1 *S* 4

Pushdown Automata Example Trace the acceptance of * 4 (continued) 37 POPS* 4 READ 3 S4 POPΔ4 READ 1 ΔΔ POPΔΔ READ 4 ΔΔ ACCEPTΔΔ

Lecture 28 Summary Deterministic PDA Examples Non-Deterministic PDA Examples Thanks to Daniel I.A. cohen. The material for these slides has been taken from his book Automata Theory 38