Recap lecture 41 Recap of PDA in conversion

  • Slides: 29
Download presentation
Recap lecture 41 Recap of PDA in conversion form, example of PDA in conversion

Recap lecture 41 Recap of PDA in conversion form, example of PDA in conversion form, joints of the machine, new pictorial representation of PDA in conversion form, summary table, row sequence, row language.

Note As has already been discussed that the Row language is the language whose

Note As has already been discussed that the Row language is the language whose alphabet = {Row 1, Row 2, …, Row 7}, for the example under consideration, so to determine the CFG of Row language, the nonterminals of this CFG are introduced in the following form Net(X, Y, Z) where X and Y are joints and Z is any STACK character. Following is an example of Net(X, Y, Z)

Example continued … PP Z PH a PH b PP If the above is

Example continued … PP Z PH a PH b PP If the above is the path segment between two joints then, the net STACK effect is same as POP Z. For a given PDA, some sets of all possible sentences Net(X, Y, Z) are true, while other are false. For this purpose every row of the summary table is examined whether the net effect of popping is exactly one letter. a

Example continued … Consider the Row 4 of the summary table developed for the

Example continued … Consider the Row 4 of the summary table developed for the PDA of the language {a 2 nbn} FROM Where TO Where READ What POP What PUSH What ROW Number READ 1 HERE b a -4 The nonterminal corresponding to the above row may be written as

Example continued … Net (READ 1, HERE, a) i. e. Row 4 is a

Example continued … Net (READ 1, HERE, a) i. e. Row 4 is a single Net row. Consider the following row from an arbitrary summary table FROM Where TO Where READ What POP What PUSH What ROW Number READ 9 READ 3 b b abb 11

Example continued … which shows that Row 11 is not Net style sentence because

Example continued … which shows that Row 11 is not Net style sentence because the trip from READ 9 to READ 3 does not pop one letter form the STACK, while it adds two letters to the STACK. However Row 11 can be concatenated with some other Net style sentences e. g. Row 11 Net(READ 3, READ 7, a)Net(READ 7, READ 1, b)Net(READ 1, READ 8, b)

Example continued … Which gives the nonterminal Net(READ 9, READ 8, b), now the

Example continued … Which gives the nonterminal Net(READ 9, READ 8, b), now the whole process can be written as Net(READ 9, READ 8, b) Row 11 Net(READ 3, READ 7, a) Net(READ 7, READ 1, b)Net(READ 1, READ 8, b) Which will be a production in the CFG of the corresponding row language.

Example continued … In general to create productions from rows of summary table, consider

Example continued … In general to create productions from rows of summary table, consider the following row in certain summary table FROM Where TO Where READ What POP What PUSH What ROW Number READx READy u w m 1 m 2…mn i then for any sequence of joint states S 1, S 2, …Sn, the production in the row language can be included as

Example continued … Net(READx, Sn, w) Rowi. Net(READy, S 1, m 1)…Net(Sn-1, Sn, mn)

Example continued … Net(READx, Sn, w) Rowi. Net(READy, S 1, m 1)…Net(Sn-1, Sn, mn) It may be noted that in CFG, in general, replacing a nonterminal with string of some other nonterminals does not always lead to a word in the corresponding CFL e. g. S X|Y, X ab, Y a. YY

Example continued … Here Y a. YY does not lead to any word of

Example continued … Here Y a. YY does not lead to any word of the language. Following are three rules of defining all possible productions of CFG of the row language 1. The trip starting from START state and ending in ACCEPT state with the NET style Net(START, ACCEPT, $) gives the production of the form S Net(START, ACCEPT, $)

2. From the summary table the row of the following form FROM Where TO

2. From the summary table the row of the following form FROM Where TO Where READ What POP What PUSH What ROW Number X Y anything z -- i Defines the productions of the form Net(X, Y, z) Rowi

3. For each row that pushes string of characters on to the STACK of

3. For each row that pushes string of characters on to the STACK of the form FROM TO READ POP PUSH ROW Where What Number READx READy u w m 1 m 2…mn then for any sequence of joint states S 1, S 2, …Sn, the production in the row language can be included as i

Net(READX, Sn, w) Rowi. Net(READY, S 1, m 1) …Net(Sn-1, Sn, mn) It may

Net(READX, Sn, w) Rowi. Net(READY, S 1, m 1) …Net(Sn-1, Sn, mn) It may be noted that this rule introduces new productions. It does not mean that each production of the form Nonterminal string of nonterminals helps in defining some word of the language.

Note Considering the example of PDA accepting the language {a 2 nbn: n=1, 2,

Note Considering the example of PDA accepting the language {a 2 nbn: n=1, 2, 3, …}, using rule 1, rule 2 and rule 3 the possible productions for the CFG of the row language are 1. S Net(START, ACCEPT, $) 2. Net(READ 1, HERE, a) Row 4 3. Net(HERE, READ 2, a) Row 5

4. Net(READ 2, HERE, a) Row 6 5. Net(READ 2, ACCEPT, $) Row 7

4. Net(READ 2, HERE, a) Row 6 5. Net(READ 2, ACCEPT, $) Row 7 6. Net(START, READ 1, $) Row 1 Net(READ 1, $) 7. Net(START, READ 2, $) Row 1 Net(READ 1, READ 2, $) 8. Net(START, HERE, $) Row 1 Net(READ 1, HERE, $)

9. Net(START, ACCEPT, $) Row 1 Net(READ 1, ACCEPT, $) 10. Net(READ 1, $)

9. Net(START, ACCEPT, $) Row 1 Net(READ 1, ACCEPT, $) 10. Net(READ 1, $) Row 2 Net( READ 1, a)Net(READ 1, $) 11. Net(READ 1, $) Row 2 Net( READ 1, READ 2, a)Net(READ 2, READ 1, $) 12. Net(READ 1, $) Row 2 Net( READ 1, HERE, a)Net(HERE, READ 1, $)

13. Net(READ 1, READ 2, $) Row 2 Net( READ 1, a)Net(READ 1, READ

13. Net(READ 1, READ 2, $) Row 2 Net( READ 1, a)Net(READ 1, READ 2, $) 14. Net(READ 1, READ 2, $) Row 2 Net( READ 1, READ 2, a)Net(READ 2, $) 15. Net(READ 1, READ 2, $) Row 2 Net( READ 1, HERE, a)Net(HERE, READ 2, $) 16. Net(READ 1, HERE, $) Row 2 Net( READ 1, a)Net(READ 1, HERE, $)

17. Net(READ 1, HERE, $) Row 2 Net( READ 1, READ 2, a)Net(READ 2,

17. Net(READ 1, HERE, $) Row 2 Net( READ 1, READ 2, a)Net(READ 2, HERE, $) 18. Net(READ 1, HERE, $) Row 2 Net( READ 1, HERE, a)Net(HERE, $) 19. Net(READ 1, ACCEPT, $) Row 2 Net( READ 1, a)Net(READ 1, ACCEPT, $) 20. Net(READ 1, ACCEPT, $) Row 2 Net( READ 1, READ 2, a)Net(READ 2, ACCEPT, $)

21. Net(READ 1, ACCEPT, $) Row 2 Net( READ 1, HERE, a)Net(HERE, ACCEPT, $)

21. Net(READ 1, ACCEPT, $) Row 2 Net( READ 1, HERE, a)Net(HERE, ACCEPT, $) 22. Net(READ 1, a) Row 3 Net( READ 1, a)Net(READ 1, a) 23. Net(READ 1, a) Row 3 Net( READ 1, READ 2, a)Net(READ 2, READ 1, a) 24. Net(READ 1, a) Row 3 Net( READ 1, HERE, a)Net(HERE, READ 1, a)

25. Net(READ 1, READ 2, a) Row 3 Net( READ 1, a)Net(READ 1, READ

25. Net(READ 1, READ 2, a) Row 3 Net( READ 1, a)Net(READ 1, READ 2, a) 26. Net(READ 1, READ 2, a) Row 3 Net( READ 1, READ 2, a)Net(READ 2, a) 27. Net(READ 1, READ 2, a) Row 3 Net( READ 1, HERE, a)Net(HERE, READ 2, a) 28. Net(READ 1, HERE, a) Row 3 Net( READ 1, a)Net(READ 1, HERE, a)

29. Net(READ 1, HERE, a) Row 3 Net( READ 1, READ 2, a)Net(READ 2,

29. Net(READ 1, HERE, a) Row 3 Net( READ 1, READ 2, a)Net(READ 2, HERE, a) 30. Net(READ 1, HERE, a) Row 3 Net( READ 1, HERE, a)Net(HERE, a) 31. Net(READ 1, ACCEPT, a) Row 3 Net( READ 1, a)Net(READ 1, ACCEPT, a) 32. Net(READ 1, ACCEPT, a) Row 3 Net( READ 1, READ 2, a)Net(READ 2, ACCEPT, a)

33. Net(READ 1, ACCEPT, a) Row 3 Net (READ 1, HERE, a)Net(HERE, ACCEPT, a)

33. Net(READ 1, ACCEPT, a) Row 3 Net (READ 1, HERE, a)Net(HERE, ACCEPT, a) Following is a left most derivation of a word of row language S Net(START, ACCEPT, $)………. using 1 Row 1 Net(READ 1, ACCEPT, $) … using 9 Row 1 Row 2 Net(RD 1, RD 2, a) Net(RD 2, AT, $) ……………using 20 Row 1 Row 2 Row 3 Net(RD 1, HERE, a)Net (RD 2, HERE, a)Net(RD 2, AT, $) ……… using 27

 Row 1 Row 2 Row 3 Row 4 Net(HERE, RD 2, a)Net(RD 2,

Row 1 Row 2 Row 3 Row 4 Net(HERE, RD 2, a)Net(RD 2, ACCEPT, $) using 2 Row 1 Row 2 Row 3 Row 4 Row 5 Net(HERE, ACCEPT, $) using 3 Row 1 Row 2 Row 3 Row 4 Row 5 Row 7 using 5 Which is the shortest word in the whole row language.

It can be observed that each left most derivation generates the sequence of rows

It can be observed that each left most derivation generates the sequence of rows of the summary table, which are both joint- and STACK- consistent. Note: So far the rules have been defined to create all possible productions for the CFG of the row language.

Note continued … Since in each row in the summary table, the READ column

Note continued … Since in each row in the summary table, the READ column contains and in addition to the letters of the alphabet of the language accepted by the PDA, so each word of the row language generates the word of the language accepted by the given PDA. Thus the following rule 4 helps in completing the CFG corresponding to the given PDA

4. Each row of the summary table defines a production of the form Rowi

4. Each row of the summary table defines a production of the form Rowi a Where in Rowi the READ column consists of letter a. Application of rule 4 to the summary table for the PDA accepting {a 2 nbn : n=1, 2, 3, …} under consideration adds the following productions

34. Row 1 35. Row 2 a 36. Row 3 a 37. Row 4

34. Row 1 35. Row 2 a 36. Row 3 a 37. Row 4 b 38. Row 5 39. Row 6 b 40. Row 7

Which shows that the word Row 1 Row 2 Row 3 Row 4 Row

Which shows that the word Row 1 Row 2 Row 3 Row 4 Row 5 Row 7 of the row language is converted to aab =abb

Summing Up Row language, nonterminals defined from summary table, productions defined by rows, rules

Summing Up Row language, nonterminals defined from summary table, productions defined by rows, rules for defining productions, all possible productions of CFG for row language of the example under consideration, CFG corresponding to the given PDA