Presentation is loading. Please wait.

Presentation is loading. Please wait.

Push Down Automata Chapter 14. Introduction We have seen different types of languages so far –Regular Languages –Nonregular Languages –Context Free Languages.

Similar presentations


Presentation on theme: "Push Down Automata Chapter 14. Introduction We have seen different types of languages so far –Regular Languages –Nonregular Languages –Context Free Languages."— Presentation transcript:

1 Push Down Automata Chapter 14

2 Introduction We have seen different types of languages so far –Regular Languages –Nonregular Languages –Context Free Languages The following Venn diagram shows the domains of each of these languages Finite Langs Regular Langs CFLs Languages

3 Introduction Clearly the set of CFLs is larger as compared to that of RLs We have two machines to recognize the RLs All the CFLs that are also RLs can also be recognized by FAs and TGs What about the rest of CFLs? We need to have a new machine for them

4 Need for a Machine Sole requirement of a machine is not only the language recognition But some other major purposes are also served by a machine Machines provide great support in the analysis of the languages through their formal graphical representation They facilitate the discovery of important characteristics about languages FA gave a thorough insight into the RLs (Union, Intersection, Complement, Pumping Lemma etc.) all need extensive support of FAs and TGs

5 Push Down Automata PDA are the new machines resulted by some enhancement in the concept of FAs to recognize Context Free Languages Different pictorial representation Enhanced recognition features (explicit results about acceptance and rejection) Employ a stack data structure

6 PDA Elements –INPUT TAPE Infinite Sequential (left to right) Cells represented by Roman numerals ∆ stands for blank and represents the end of string –States START –Equivalent to – state of TG connected by Λ to any other state –No incoming arrow ACCEPT –Equivalent to a dead final state –Once entered can’t be left REJECT –Equivalent to non final dead state –Once Entered can’t be left even START REJECT ACCEPT

7 PDA Elements –States READ –Reads an input letter from the tape –Directed edges show the path to move after a certain character is read Read the next input letter b ∆ a

8 PDA The FA accepts the language of all strings that end in a -+ a b b a The corresponding PDA would be START ACCEPTREJECT READ b a b a ∆ ∆

9 PDA The edge from START state needs no label because START reads no letter The ACCEPT and REJECT states are also called halt states as once entered can’t be left

10 PDA Example –A language of strings with a double a - a b b a + a,b START REJECT READ b a a,b a ∆ ∆ ACCEPT ∆ READ b

11 PUSHDOWN STACK Pushdown store Input letters are stored on a pushdown stack until they are required again The operation PUSH adds a letter to the top of the stack The POP operation pops the top letter Before the machine begins to process an input string, the STACK is presumed to be empty

12 PUSHDOWN STACK When a letter is Popped each of the elements below moves one position up The empty locations of the stack are filled with ∆ as in case of the INPUT TAPE STACK has infinite length Only the top letter of the STACK can be read If the fourth letter is to be read then four POP operations are needed Popping an empty stack gives a ∆

13 PDA New elements –Operations PUSH POP ∆ a b PUSH a

14 PDA STACK The edges out of a POP are labeled the same way as in case of a read (one for each character so far) The branching can occur at POP states only i.e. the PUSH states have only a single outgoing edge Nevertheless a PUSH state may have multiple incoming edges

15 PDA START PUSH a REJECTACCEPTREJECT READ POPREAD POP a a a b b ∆ ∆ ∆ a,b ∆,b aaabbb∆∆∆∆∆∆∆∆ …. INPUT TAPE STACK

16 PDA Vs. FAs Both the machines though have finite states but PDAs have an unlimited storage capacity Besides PDAs can also keep a track of the number of times a particular character has been read or the number of times a particular state has been visited

17 PDA: A Formal Definition A pushdown automaton, PDA is a collection of eight things –An alphabet  of input letters –An input TAPE (infinite in one direction). The string of input letters is placed on the TAPE starting at cell i. The rest of the TAPE is filled with ∆. –An alphabet Г of STACK characters –A pushdown STACK (infinite in one direction). The STACK is empty initially –One START state that has only out-edges, no in-edges –Halt states of two kinds: some ACCEPT and some REJECT. Both of these have incoming edges but no outgoing edge –Finitely many nonbranching PUSH states that introduce characters onto the top of STACK. –Finitely many branching states of two kinds (may be non deterministic) READ states which read the next unused letter from the TAPE POP states which read the top character of the STACK

18 Practice Exercise… Language of all those strings that contains aaa. Language of all those strings that contains ab. a m b 2m c n where m,n are Natural numbers. a m b m+n c n whre m,n are natural numbers.

19 Cont……… a m b 3m c n d 2n whre m,n are natural numbers. Language of all palindrome Language of all non-palindrome Language of all those strings where number of a’s are twice than number of b’s Language of all those strings where number of letters are six in each word.


Download ppt "Push Down Automata Chapter 14. Introduction We have seen different types of languages so far –Regular Languages –Nonregular Languages –Context Free Languages."

Similar presentations


Ads by Google