lecture # 22. pda of language {a n b n : n=0,1,2,3, …}

13
Lecture # 22 Lecture # 22

Upload: kathryn-cook

Post on 18-Jan-2016

222 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lecture # 22. PDA of language {a n b n : n=0,1,2,3, …}

Lecture # 22Lecture # 22

Page 2: Lecture # 22. PDA of language {a n b n : n=0,1,2,3, …}

PDA of language {aPDA of language {annbbnn : n=0,1,2,3, : n=0,1,2,3,

…}…}

Page 3: Lecture # 22. PDA of language {a n b n : n=0,1,2,3, …}

NoteNote: The process of running the : The process of running the string aaabbb can also be expressed string aaabbb can also be expressed in the following table in the following table

Page 4: Lecture # 22. PDA of language {a n b n : n=0,1,2,3, …}

Example contd. … Example contd. …

Page 5: Lecture # 22. PDA of language {a n b n : n=0,1,2,3, …}

Note Note

It may be noted that the TAPE alphabet It may be noted that the TAPE alphabet ΣΣ and STACK alphabet and STACK alphabet ΓΓ, may be different in , may be different in general and hence the PDA equivalent to general and hence the PDA equivalent to that accepting {athat accepting {annbbnn: n=0,1,2,3…} : n=0,1,2,3…} discussed above may be discussed above may be

Page 6: Lecture # 22. PDA of language {a n b n : n=0,1,2,3, …}

PDA of language {aPDA of language {annbbnn : n=0,1,2,3, : n=0,1,2,3, …}…}

Page 7: Lecture # 22. PDA of language {a n b n : n=0,1,2,3, …}

Nondeterministic PDA Nondeterministic PDA Like TGs and NFAs, if in a PDA there are more Like TGs and NFAs, if in a PDA there are more

than one outgoing edges at than one outgoing edges at READREAD or or POPPOP states with states with oneone label, then it creates label, then it creates nondeterminism and the PDA is called nondeterminism and the PDA is called nondeterministic PDA.nondeterministic PDA.

In nondeterministic PDA no edge is labeled by In nondeterministic PDA no edge is labeled by string of terminals or nonterminals, like that string of terminals or nonterminals, like that can be observed in TGs. Also if there is no can be observed in TGs. Also if there is no edge for any letter to be read from the TAPE, edge for any letter to be read from the TAPE, the machine crashes and the string is rejected.the machine crashes and the string is rejected.

Page 8: Lecture # 22. PDA of language {a n b n : n=0,1,2,3, …}

Nondeterministic PDA cont Nondeterministic PDA cont … …

In nondeterministic PDA a string may trace In nondeterministic PDA a string may trace more than one paths. If there exists at more than one paths. If there exists at least one path traced by a string leading least one path traced by a string leading to ACCEPT state, then the string is to ACCEPT state, then the string is supposed to be accepted, otherwise supposed to be accepted, otherwise rejected. rejected.

Following is an example of Following is an example of nondeterministic PDA nondeterministic PDA

Page 9: Lecture # 22. PDA of language {a n b n : n=0,1,2,3, …}
Page 10: Lecture # 22. PDA of language {a n b n : n=0,1,2,3, …}

Nondeterministic PDA Nondeterministic PDA continued … continued …

Here the nondeterminism can be observed Here the nondeterminism can be observed at state READ1. It can be observed that the at state READ1. It can be observed that the above PDA accepts the language above PDA accepts the language

EVENPALINDROME=EVENPALINDROME={{ΛΛ, aa, bb, aaaa, abba, baab, bbbb, …} , aa, bb, aaaa, abba, baab, bbbb, …}

Now the definition of PDA including the Now the definition of PDA including the possibility of nondeterminism may be given possibility of nondeterminism may be given as follows:as follows:

Page 11: Lecture # 22. PDA of language {a n b n : n=0,1,2,3, …}

PUSHDOWN AUTOMATON PUSHDOWN AUTOMATON (PDA) (PDA)

Pushdown Automaton (PDA), consists of the Pushdown Automaton (PDA), consists of the following following

1.1. An alphabet An alphabet ΣΣ of input letters. of input letters. 2.2. An input TAPE with infinite many locations An input TAPE with infinite many locations

in one direction. Initially the input string is in one direction. Initially the input string is placed in it starting from first cell, the placed in it starting from first cell, the remaining part of the TAPE is empty. remaining part of the TAPE is empty.

3.3. An alphabet An alphabet ΓΓ of STACK characters. of STACK characters. 4.4. A pushdown STACK which is initially A pushdown STACK which is initially

empty, with infinite many locations in one empty, with infinite many locations in one direction. Initially the STACK contains direction. Initially the STACK contains blanks.blanks.

Page 12: Lecture # 22. PDA of language {a n b n : n=0,1,2,3, …}

PDA Continued ... PDA Continued ... 5.5. One START state with only one out-edge One START state with only one out-edge

and no in-edge. and no in-edge. 6.6. Two halt states Two halt states i.e. i.e. ACCEPT and REJECT ACCEPT and REJECT

states, with in-edges and no out-edges. states, with in-edges and no out-edges. 7.7. A PUSH state that introduces characters A PUSH state that introduces characters

onto the top of the STACK. onto the top of the STACK. 8.8. A POP state that reads the top character A POP state that reads the top character

of the STACK, (may contain more than of the STACK, (may contain more than one out-edges with same label).one out-edges with same label).

9.9. A READ state that reads the next unused A READ state that reads the next unused letter from the TAPE, (may contain more letter from the TAPE, (may contain more than one out-edges with same label). than one out-edges with same label).

Page 13: Lecture # 22. PDA of language {a n b n : n=0,1,2,3, …}

Turing Machine Turing Machine The mathematical models (FAs, TGs, PDAs) The mathematical models (FAs, TGs, PDAs)

that have been discussed so far can decide that have been discussed so far can decide whether a string is accepted or not by them whether a string is accepted or not by them i.ei.e. these models are language identifiers. . these models are language identifiers.

However, there are still some languages However, there are still some languages which can’t be accepted by them which can’t be accepted by them e.g.e.g. there there does not exist any FA or TG or PDA does not exist any FA or TG or PDA accepting any non-CFLs. accepting any non-CFLs.

Alan Turing developed the machines called Alan Turing developed the machines called Turing machines, which accept some non-Turing machines, which accept some non-CFLs as well, in addition to CFLs.CFLs as well, in addition to CFLs.